Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a coroutine monitoring the memory usage. #1

Open
kenashkov opened this issue May 12, 2020 · 1 comment
Open

Add a coroutine monitoring the memory usage. #1

kenashkov opened this issue May 12, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@kenashkov
Copy link
Member

Add a new callback with Swoole\Timer::tick() on every second.
If the memory usage reaches 85% of memory limit clear 20% of all caches.
The cleanup is to be performed by invoking the controller action:
GuzabaPlatform\AppServer\Monitor\Controllers\Responder::clear_all_caches()

An additional argument for supporting what percentage is to be cleared like on clear_query_cache() is to be added as well.

The call of Timer::tick() is to done at worker startup. This can be done with adding a callback to the worker "_after_start" event. This is to be done with:

self::CONFIG_DEFAULTS[
    'services' => [
        'Events'
    ],
];

self::get_service('Events')->add_class_callback(WorkerStart::class, '_after_start', [$instance, 'method_name']);

See Guzaba2\Orm\Store\Memory.php::__construct()

LATER:
In the callback the user needs to be set to the SYSTEM user (the user is to be created first) with CurrentUser::set()

@kenashkov kenashkov added the enhancement New feature or request label May 12, 2020
@kenashkov
Copy link
Member Author

Add a Kernel::log($message) when this is triggered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants