Skip to content

Comment on Handling 100 Requests per Second with Python and Django

Comments

100 requests per second? That is not too impressive. Yes, I know Python is their tool of choice, but it is probably the wrong tool for the problem at hand.

There are frameworks that can handle over a million requests per second (simple json output) or at least several 10,000 requests per second if DB queries are performed (even though on different hardware, but just compare the scale).

https://www.techempower.com/benchmarks/#section=data-r20&hw=... https://www.techempower.com/benchmarks/#section=data-r20&hw=...

I think, if performance is a strong requirement, they were better off with another programming language.

What if you already have your application written in python? Would you rewrite it using the right tool?

In their case, it seems the request in question involves a write to a PostgreSQL database. Depending on the database, 100 can be a lot of work.

They measured that the app spends about half its time waiting for the database.

There seems to be a whole lot of things to do before thinking of changing basic plumbing.

Perhaps then the title of the post could be "handling 100 writes per second with Postgres"

Or perhaps people could consider more than the title when commenting.

For simple queries Postgres can do thousands of requests per second on desktop hardware without any serious tuning. Of course if those are complex queries or if they need to handle a lot of data this can be much, much slower. But Postgres is not slow for simple queries.

If you look at these benchmark a bit more deeply, you'll see that there isn't anything that's as featured and robust as Django and that's more than 2/3 times as fast, which isn't much to justify a full rewrite. Django is at 4.4%, and Spring for example is at 9%. The exception would be ASP.NET Core, but I don't know enough about the ecosystem to judge it.

100 requests per second? That is not too impressive. Yes, I know Python is their tool of choice, but it is probably the wrong tool for the problem at hand.

I would imagine that even with Python, a fully asynchronous framework would be far better at requests-per-second than Django, but would require sacrificing features, since nothing async is yet at feature parity.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.