Too few max connections and small shared buffer for PostgreSQL gear
Environment
Openshift Online 2.0.32
postgresql 9.2
python 2.6
redis
Issue
psycopg2 errors: psycopg2:OperationalError: FATAL: sorry, too many clients already
Looking at the postgresql.conf file on the Postgres gear, we could see that the max connections were set to only 10, shared buffer set to only 2MB, and effective_cache_size set to only 32.
Reading through the Postgres documentation, we could see that the default for max_connections is typically around 100, for shared_buffer it's typically 32MB, and effective_cache_size tis typically 128MB.
Resolution
Change connection limits per database:
http://www.postgresql.org/docs/9.2/static/sql-alterdatabase.html
ALTER DATABASE <name> WITH CONNECTION LIMIT 100
Root Cause
Postgress gears are not really tuned for production. We will try to improve this in a future version.
Created a bugzilla ticket to get it improved
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
