php - PostgreSQL permanent connection: usefull in my case? -


i have php application called get parameters running pg , nginx. page receives message , information. page b makes routing. page c calls external application curl. receive 1-2 millions requests per month when i'll go in production.

my question concerns pg_pconnect function. is connection reused if there calls different location? mean, better make simple connection , close everytime page a? (servers different locations call app) page b , c, script call them in infinite loop (waiting 10s if there no message handle). since requests come same location, worthy use permanent connection page b & c?

i hope explanation clear enough.

thanks!

in general, think in case, see benefits persistent connections. there drawbacks, these manageable long keep them in mind. may, however, want go further , consider actual connection pooler.

the big issue typically postgresql best when concurrent connections under approx 2 per cpu core plus 1 per disk spindle (due i/o wait time). isn't exact of course gives idea given hardware , resources expect.

the connection startup/teardown overhead not on linux/unix platforms, managing concurrency may critical keeping things running fast. start out persistent connections , move connection pooler if needed additional control there.

there major disadvantages there database operations cannot when others connected database. if ever need restore backup, may need make sure disconnect web app first.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -