I am using Python Gevent's stream servers for communicating with another machine (remote) which sends concurrent TCP/IP requests (on an avg 60 req/sec). Nature of this communication is mostly IO bound (short text and then audio streams). I intend to use Postgresql to store the result of each communication (eg: filename received from the remote server).
I think its bad idea to invoke a new db connection for every greenlet spawned in Streamserver (pool size 90 so 90 req/sec max, that is the max I expect and avg 60 req/sec). Is it possible to have db connection pool which can be queued and every greenlet when starts running the handler function get a db connection from pool? Is there any tutorial that has worked for production systems? How would you suggest? I am using gevent 0.13.8 and postgres 9.1 with Python 2.7.3 on Ubuntu 10.04 64bit.