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

Deployment with 1 worker always consumes 0.1 cpu #152

Open
SnoozeFreddo opened this issue Dec 31, 2023 · 4 comments
Open

Deployment with 1 worker always consumes 0.1 cpu #152

SnoozeFreddo opened this issue Dec 31, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@SnoozeFreddo
Copy link

A basic deployment on AWS shows that socketify consumes 0.11-0.12 cpus while idle. The same applies locally while other applications almost don't consume any cpu at all.

@goteguru
Copy link

goteguru commented Jan 5, 2024

Confirmed. Exact figures depends on the hardware of course. In my case (oracle cloud / AMD EPYC) single process eats as high as ~4-8% while idle! In comparison same code with FastAPI/uvicorn consumes about 0.1-0.2% (while idle).

That's pretty high... (doesn't seem to be scalable).
(idle cpu usage is the same with pypy and cpython)

@cirospaciari cirospaciari self-assigned this Jan 12, 2024
@cirospaciari cirospaciari added the enhancement New feature or request label Jan 12, 2024
@leunga1000
Copy link
Contributor

I see this too, about .1 cpus consistently

@goteguru
Copy link

goteguru commented May 3, 2024

I see this too, about .1 cpus consistently

Author is aware of the problem, it might be a good idea to add some kind of config option.
For now, you can modify the source to reduce the idle load (in expense of reactivity after sleeping).

Look for Loop._keep_alive() here and increase the relaxed state callback time from 0.001 to something sensible according to you use-case:
https://github.com/cirospaciari/socketify.py/blob/main/src/socketify/loop.py

@leunga1000
Copy link
Contributor

Thanks for this, really helps! I have patched the method locally to reduce the cpu usage and will see how it affects functionality and performance.

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

4 participants