0

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?

Corillian
  • 101
  • 1
  • Can you please update your question, clarifying how your Azure deployment is set up? For example: Is the Postgresql VM in the same deployment as your web app, or is it in a separate deployment (e.g. everythingtogether.cloudapp.net, or webapp.cloudapp.net + dbserver.cloudapp.net)? If the latter, did you open public endpoints for each port needed for Postgresql on the dbserver's deployment? – David Makogon Oct 25 '13 at 13:09
  • What happens if you try to make a connection from the command line, using the same values for hostname etc as you're using in your config for the application? (And yes, DNS timeouts can certainly cause this problem given the current information in the question.) – Jenny D Oct 25 '13 at 14:40
  • It connects just fine. I just switched the forums VM to use the internal IP for the DB server to see if the DNS resolution is having an impact on the connection timeouts (it just occurred to me it could be a problem as I was typing my [Edit] above lol). – Corillian Oct 25 '13 at 15:12

1 Answers1

0

Using the windows azure internal IP address instead of the host name solved the problem. Apparently the cost of the DNS resolution is quite high.

Corillian
  • 101
  • 1