Replies: 3 comments 3 replies
-
|
Hey! Based on your description, here are some "thoughts":
Also, if you have room for that, trying with 2x the workers and everything else unchanged might provide better results (we have a couple of Django services in Sentry where we use 8 workers per pod). That's what I can think of at the moment, let me know if you have further details to add. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Beta Was this translation helpful? Give feedback.
2 replies
-
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment








Uh oh!
There was an error while loading. Please reload this page.
-
Hi! Since you reached out, figured I'd take you up on this 😄
So basically we're right now running on https://github.com/nginx/unit but that project has been archived and even prior to archiving has been a bit unmaintained so there are a few things on master that never made it to releases. Other than that we're pretty happy with the performance we've been getting out of it.
We have a Django 4 stack running on unit and are using it in ASGI mode with 4 workers per pod (~1 CPU, 4GB RAM). We'd like to upgrade to Django 5 and for that we need to move to a different webserver due to some issues in unit. Naturally Granian came up as a candidate so we've spun up some tests around it.
We started with 4 workers simply because that's what we had before. Then based on reading in your docs ended up going down to 1 worker and instead scaling horizontally, so x4 our pods. We've experimented with runtime threads a bit, ultimately landed on 1 or 2 threads. Also probably read most of the discussions in this repo that revolve around Django, performance, etc 😅
1 worker @ 4 threads bumped the p95 by a lot so we reverted that

We have disabled keep-alive to get a more even distribution of requests from the reverse proxy, this has helped, but did not bring down p99 by a large amount.
Right now we have it running in production on a 90%/10% traffic split between old and new for one application. The issue we're running into is that we have a slightly elevated p95 and quite elevated p99 latency with the traffic that's hitting Granian compared to unit.
unit, 90% traffic, 7 days


Granian, 10% traffic, 7 days
And that's basically where we are sort of stuck right now. We've tried a few settings to see if we could get this down but it hasn't made "click" yet what we might be missing here.
We experimented with backlog/backpressure values (128, 1) and that made it slightly better, but not by a huge amount.
We've since worked out that part of the visual difference in latency is definitely also due to metric bucketing in the histogram. Based on logs we know it's not as bad as it looks, but Granian is definitely a bit slower for this app we're experimenting with and we're trying to figure out if we can do something about it or have to accept that it is what it is.
We think Djangos sync views are probably our main limiting factor (
sync_to_async(thread_sensitive=True))If you have any suggestions for what we can try or what else you'd need to know that'd be much appreciated 🙏
Beta Was this translation helpful? Give feedback.
All reactions