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.
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.