I found an odd article that says Django can handle 100 requests per second.
That’s way too small … I really doubt if that’s true.
I mean, then how could Instagram and Bitbucket use Django? they have to handle billions of requests per day.
While there are big companies like Bitbucket that claim they’re using Django,
there are still some weird benchmarks that say Django is super slow.
I’m not sure who’s right?
How can I make my Django app handle millions of requests per second?
Why is Djagno documentation missing these info?
I know Redis caching helps but I want to know more about server and hardware configs that can enable Django to handle massive amount of requests per second.
The diagrams from stack overflow architecture might give you some perspective. (1 million requests per second is no trivial task!)
The short answer is companies scale horizontally. They run many instances of their application behind some sort of load balancer. They have aggressive caching layers. Some requests don’t even go to django, they might be served through varnish or an nginx cache. They use multiple databases in replica configurations when databases become a bottleneck. They have a messaging queue such as rabbitmq with celery to run heavy processing jobs outside of the request cycle. They have a job scheduler such as celery beat to run scheduled tasks.
errrrr … 100 requests per second – sustained – is actually good (assuming just as well sustained and reasonable response times of course…). That means one fourth of stack overflow. How is that “way too small”?
It all depends on the kind of stuff you’re serving of course… anything database-heavy and/or more involved than serving a pre-generated json file, and read the comment from massover
Out of curiosity, what is the use case for “millions of requests per second”?
The point here is that these are not “Django-specific” topics, they’re general web-application scaling topics. They depend more upon the environment in which you’re running the application than the application itself.
Yes, Django does provide information for those portions under its control - template and session cacheing as two examples. They also touch on other related topics such as static file handling. But the key issues that @massover raises (load balancers, nginx cache, CDN for static files, database tuning and replication, etc) are completely outside of Django and Django’s control.
So if you want to research those items, don’t restrict yourself to Django-related sources. It goes far beyond that.
(And if you’re not already dealing with tens of thousands of requests per second, it’s extremely wasteful to try and engineer an architecture for millions of requests per second. This is not an issue needing to be addressed right away.)