Hacker News new | past | comments | ask | show | jobs | submit login
Async Python is not faster (2020) (calpaterson.com)
3 points by tosh 6 months ago | hide | past | favorite | 1 comment



In the async_db.get_row() function, put a little asyncio.sleep(0.2) and then test again with hundreds of requests at once on a webserver with N workers and see what happens. Flask is going to run out of workers to handle the requests and Gunicorn is going to get backed up. The async frameworks are going to be happily able to accept lots of requests at once, including handling all the db connections concurrently. Hence the benefit of async.

Check your flamegraphs. A db-heavy request might spend 80%+ of its time in db operations. Any requests in excess of available workers are going to have to wait in line to even start their work!

If your work is CPU-bound, you're better off scaling out workers.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: