jruby extremely slow postgres internet connection

  1 post   Feedicon  
Replies: 0 - Last Post: October 17, 2010 19:48
by: mkk7
showing 1 - 1 of 1
Posted: October 17, 2010 19:48 by mkk7

I have a strange problem with postgresql connections while using jruby (1.5.3) + rails3 + activerecord-jdbcpostgresql-adapter to connect a postgresql database over internet. It takes about one minute or more to execute a first database query, for example in rails console something like this: a=User.find(:first) where users is a simple table with a few records.

Another queries during the same rails console sessions are very fast, but it doesn't matter in my case because RoR projects (no matter the environment nor server used to deploy) are suffering from this slowness every time their pages are loaded.

The problem doesn't appear with a local database - only connecting over the internet causes the problem. I tried to forward postgresql ports using ssh, so I could connect to the internet postgresql database by pointing to the localhost - but with no success - slow again.

But when I use ruby1.8 and the pg gem there's no such problem, so the quality of a connection doesn't seem to be a problem.

What makes it even more strange for me is that connection is created very quickly after executing a query - I can see it in postgres logs and if there are postgres errors (like no pg_hba entry for a host) I see them immediately in rails console. When there are no errors and the result (even a very small one) is on its way - I have to wait.

The Postgres version I've tried: 8.1 (Debian Etch) 8.3 (Debian Lenny) 8.3 (Windows7)

Host machines used to connect to remote databases I've tried: Win7, Win7 x64, Ubuntu 10.10 (jruby 1.5.0)

Each of all above was in a different localization and the problem was always appearing.

Any ideas how to fix it? Does someone have similar experiences?
Replies: 0 - Last Post: October 17, 2010 19:48
by: mkk7
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2014, Oracle Corporation and/or its affiliates
(revision 20160708.bf2ac18)
Please Confirm