• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Heroku, POSTGRESQL and too many connections

 
cristian zoccarato
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • 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!
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • 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: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic