On Friday, November 28, 2014 3:31:02 PM UTC+1, Lisandro wrote: > > I go back to this thread because today I ran with the same problem: > postgresql reaching max_connection limits and, therefor, some of my > websites throwing intermitent HTTP 500 errors (because web2py couldn't > connect to the database). > > To remind, we are talking of a VPS with multiple instances of web2py > running, all of them serving the same web2py app, each one connecting to a > different postgresql database (however the database structure is the same > accross all the databases). Each web2py instance is served by a lighttpd > virtual host through fastcgi. Each virtual host (that is, each web2py > instance) receives a different volume of traffic (that is obvious, they are > different websites with different public). > > The original problem (the one that caused I post this question in the > first place) was that the postgresql database server was reaching the > "max_connections" limit and, in consecuence, some of the websites were > throwing intermitent HTTP 500 errors (web2py couldn't connect to database). > > Then, the user oriented me with "pool_size" parameter of DAL constructor. > Thanks again! > I've been reading the web2py documentation about pooling [1] and I notice > that it says that "When the next http request arrives, web2py tries to > recycle a connection from the pool and use that for the new transaction. If > there are no available connections in the pool, a new connection is > established". > So, if I didn't get it wrong, I deduce that with web2py's pooling > mechanism I can't overcome the "max_connections" postgresql limit. That is > because, no matter the size of the pool, if the pool is full and the > website is receiving a lot of requests, new connetions will be created, and > eventually the database server will reach the "max_conectios" limit. >
no, you got it wrong again. pool_size=5 will create AT MOST 5 connections . if a 6th is needed, users will wait for a connection to be freed. if your postgresql accept at most 50 connections, do the math. Every db = DAL(, pool_size=5) lying around will create AT MOST 5 connections, and that means you can host 10 apps. If you need 50 apps, set pool_size=1 and let users wait, or set max_connections in postgres to a higher value. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.