Rails application keeps timing out when attempting to connect to Postgresql DB
Posted
by
Corillian
on Server Fault
See other posts from Server Fault
or by Corillian
Published on 2013-10-25T06:26:16Z
Indexed on
2013/10/25
15:56 UTC
Read the original article
Hit count: 213
I'm hosting a postgresql database on a small windows azure Ubuntu 13.04 VM with a default postgresql.conf. I have a Rails application running on a medium windows azure Ubuntu 13.04 VM. When accessing the postgresql database the rails application is constantly timing out. In its database.yml I have the connection pool size set to 120 and the timeout set to 15 seconds. Despite this my rails logs are full of the following error message:
ActiveRecord::ConnectionTimeoutError: could not obtain a database connection within 5 seconds (waited 5.0023203 seconds). The max pool size is currently 120; consider increasing it.
My postgresql.conf has a max connection limit of 120, making it any larger prevents the server from being able to successfully restart. I've also made sure that ssl was off in the postgresql.conf per this article but beyond that I have no idea what's going on. My postgresql logs don't contain any info indicating something is going wrong. My website is getting ~1k hits per day so perhaps a small VM instance just isn't powerful enough? I appreciate any assistance!
[Edit1] The postgresql database is in a separate cloud service within the same affinity group. For example:
db small VM: mydatabase.cloudapp.net (Affinity Group US East)
forums medium VM: myforums.cloudapp.net (Affinity Group US East)
On the database server I have opened port 5432. The connection to the database server from the forums server is using its hostname. Is it possible that the DNS resolution is what's taking so long?
© Server Fault or respective owner