Currently am running backgroud jobs with sidekiq, while running its giving "ActiveRecord::ConnectionTimeoutError".
This is my current database.yml file,
production:
adapter: postgresql
encoding: unicode
database: app_production
username: password
password:
host: app.domain.com
pool: 25
This is is my sidekiq.yml file,
production:
concurrency: 25
timeout: 300
While running its giving connection timeout error
This error was am getting in the backgroud,
could not obtain a database connection within 5 seconds (waited 5.82230675 seconds). The max pool size is currently 25; consider increasing it.
connectTimeout = int. The timeout value used for socket connect operations. If connecting to the server takes longer than this value, the connection is broken. The timeout is specified in seconds and a value of zero means that it's disabled.
PostgreSQL Connection Limits 15 connections are reserved for the superuser to maintain the state and integrity of your database, and 100 connections are available for you and your applications. If the number of connections to the database exceeds the 100-connection limit, new connections fail and return an error.
If Django/psycopg2 have the correct domain name or IP address for the PostgreSQL server, and the correct port, the most common explanation for "Connection timed out" is that a firewall (typically on the PostgreSQL server) is filtering that traffic.
Maximum number of connections allowed to your postgres database is 25. But you have set your concurrency for sidekiq as 25. So if you have all the concurrent threads for sidekiq running, you will not have any database connection available for your app server.
Either reduce the sidekiq concurrency or increase the pool size(I recommend increasing the pool size).
Postgres allows 100 concurrent connections by default
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With