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

Are there max requests settings for Daphne? #403

Open
alamorre opened this issue Jan 30, 2022 · 6 comments
Open

Are there max requests settings for Daphne? #403

alamorre opened this issue Jan 30, 2022 · 6 comments

Comments

@alamorre
Copy link

alamorre commented Jan 30, 2022

I have this ASGI applicate with Django and Daphne, and I'm using the following command.

daphne -b 0.0.0.0 -p $PORT server.asgi:application

Is there a way to add --max-requests and --max-requests-jitter to actively prevent memory leaks?

Maybe something like:
daphne -b 0.0.0.0 -p $PORT --max-requests 1000 --max-requests-jitter 50 server.asgi:application

@carltongibson
Copy link
Member

Not currently, but it might be a good addition. 🤔

This is ref:

django/channels#1789

Were you able to investigate why you're seeing a leak there? Also did it stabilise at 4%? (In which case it may be the Python GC rather than a leak per se — for which it'd keep going up.)

@alamorre
Copy link
Author

alamorre commented Feb 2, 2022

It's really a verbatim implementation of the tutorial project in the docs. In production it leaks in the picture below.

That's why i think --max-requests with daphne would be awesome. We can let an image teardown before consuming too many resources.

Screen Shot 2022-02-01 at 7 36 47 PM

@alamorre
Copy link
Author

alamorre commented Feb 6, 2022

I created this draft PR #405

Please let me know if this is of interest. I'll polish the code and make some unit tests 👍

@WellingtonNico

This comment was marked as off-topic.

@carltongibson

This comment was marked as off-topic.

@carltongibson
Copy link
Member

The PR in #405 adds a shutdown, but it doesn't reload.

For that we'd need something like Django autoreloader's restart_with_reloader():

https://github.com/django/django/blob/747b417a220b0412ed806001a383959449aac6da/django/utils/autoreload.py#L270-L276

If someone wanted to take that on, it would be worth a look.

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

No branches or pull requests

3 participants