• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Heroku, POSTGRESQL and too many connections

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, if I wrote on the wrong section or it's somehow off-topic let me apologize myself.

I'm running my application on Heroku and after a certain amount of "use" I get a 500 error on browser. Heroku logs reports this error:

I'm on a hobby tier profile on Heroku so I know that there are limited connections per single user (up to 20). I tried to set the duration of my session at 10 mins but the problem remains.

How can I solve it without manually restarting Heroku every time?
thanks in advance!
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seems you don't have too much options to resolve this issue.

More info about killing specific connections can be found here.
 
cristian zoccarato
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, thanks for quick reply.
As far as I understood, every time the user does some operation with database the connection counter add one until 20 is reached, then the app stops working.
So that means that there's nothing I can do by coding, right?

Also, that means that another user (for instance, a player on my game site) has to restart heroku by himself or what's done by me is enough?
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have no experience with Heroku at all.

First of all, your code should of course have proper resource management. Meaning you should (always) close your connection when you are finished. If you don't do this, this connection will be gone and can't be used anymore. If you have a pool of 20 database connections and you close a connection it will be returned to the pool, so it can be used for another query. If you don't close the connection properly, the connection will not be returned to the pool and your pool will have 19 database connections left.

But if you have 25 users which login at the same time, you'll already have an issue because you need 25 database connections but have only 20.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic