Hacker News new | ask | show | jobs
by dagw 3333 days ago
In many non trivial cases I tend to find that I have to query several different databases to render a single page.
1 comments

depending on the latency of those database connections I've argued in the past that the overhead of adding asyncio context switching and boilerplate is more expensive than just hitting the two or three databases in serial (and if your web request is having to hit dozens of DB sources to serve one request, I think you've already lost the performance game :) ). When your one web request is contending with many other concurrent web requests in any case, doing the DB calls in serial just lets the CPU attend to other requests.
Do you think it make more sense to do async backend when we are moving to real-time ( meaning websocket-based connections ) web apps?
I've maintained that async is better suited towards web services and lightweight databases like redis, and is not useful for relational databases. However, it's very hard to get async to make your code actually "faster", as opposed to just handling very high throughout with less resources. If people stop saying "faster!", I'll go away.