calpaterson / python-web-perf

Code for testing performance of popular python webservers
106 stars 21 forks source link

Number of connections in pool #4

Open lazitski-aliaksei opened 4 years ago

lazitski-aliaksei commented 4 years ago

Have you tried to increase number of connections in db connection pool for async apps? One async worker can yield much more queries to DB than one sync worker, so they might be waiting for connection from pool under high load.

calpaterson commented 4 years ago

Hi, I don't have good reason to think that Python was waiting for connections for very long (I'm using an external connection pooler, over a unix socket, and the query is extremely simple so the connection would not be held for long anyway).

If this were affecting throughput it would have manifested as less than maximum CPU usage - which I didn't observe.

Beyond that I don't think it's extremely reasonable to just up the allowed number of database connections. For one - there is a cost on the database side for every connection and adding more often just increases the amount of locking and whatnot that has to be done. 20 connections, divided by 4 cores really is quite a lot when they take nearly no time to open and close due to the pooler.

If you try it yourself, please do let me know! (Whether or not you find anything different from my tests.)