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

Why can a single worker process use multiple cores in a k8s environment? #3150

Closed
fighterhit opened this issue Feb 4, 2024 · 2 comments
Closed

Comments

@fighterhit
Copy link

Why can a single worker process use multiple cores in a k8s environment? According to my understanding, one python process can only use one core?

I test the program using the following config in k8s cluster:

# my pod command
gunicorn --workers 1 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000 --keep-alive 60 main:app
# pod resource yaml

resources:
  limits:
    cpu: "3"
    memory: 8Gi
  requests:
    cpu: "3"
    memory: 8Gi
# cat /sys/fs/cgroup/cpuset/cpuset.cpus 
11,58-59

1gunicorn-cpu

@benoitc
Copy link
Owner

benoitc commented Feb 4, 2024

Hi, uivicorn loop is probably using 1 core. Gunicorn with 1 worker may use 2 (1 for the arbiter , another for the worker). This depends on how the system will balance the tasks.

@benoitc benoitc closed this as completed Feb 4, 2024
@fighterhit
Copy link
Author

Hi, uivicorn loop is probably using 1 core. Gunicorn with 1 worker may use 2 (1 for the arbiter , another for the worker). This depends on how the system will balance the tasks.

Thanks @benoitc. Do you mean that the uivicorn loop uses 1 of the 3 cpu cores, and Gunicorn with 1 worker uses the remaining 2 cores? Does that mean that Gunicorn with 1 worker needs at least 2 CPUs?

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

No branches or pull requests

2 participants