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

Configurable Number of Gunicorn Workers #3347

Closed
sebastianjanisch opened this issue May 20, 2024 · 0 comments · Fixed by #3351
Closed

Configurable Number of Gunicorn Workers #3347

sebastianjanisch opened this issue May 20, 2024 · 0 comments · Fixed by #3351
Labels
bug Something isn't working

Comments

@sebastianjanisch
Copy link

Describe the bug
Number of workers are right now determined based on CPU count if redis is enabled.
This might not always be desired for instance if reflex runs as part of a k8s deployment and os.cpu_count() returns the number of cores on the node, not the pod.

To Reproduce
Steps to reproduce the behavior:

def get_num_workers() -> int:
"""Get the number of backend worker processes.
Raises:
Exit: If unable to connect to Redis.
Returns:
The number of backend worker processes.
"""
if (redis_client := prerequisites.get_redis_sync()) is None:
return 1
try:
redis_client.ping()
except RedisError as re:
console.error(f"Unable to connect to Redis: {re}")
raise typer.Exit(1) from re
return (os.cpu_count() or 1) * 2 + 1

Expected behavior
Being able to specify the number of workers through an env var.

Screenshots
If applicable, add screenshots to help explain your problem.

Specifics (please complete the following information):

  • Python Version:
  • Reflex Version: 0.5.0
  • OS:
  • Browser (Optional):

Additional context
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant