1

I have a Django app (music streaming service) running on a free hosting account on Heroku with a Postgres database with one web dyno. Yesterday I wrote a script that uploads mp3 files to Heroku, extract meta data, then upload it the files to Amazon S3. When I'm going through this process, I get this error when I try to refresh

could not fork new process for connection: Cannot allocate memory

or

FATAL:  remaining connection slots are reserved for non-replication superuser connections

When I go to postgres.heroku.com to see the statistics, here is what I have :

Plan    Dev
Status  available
Data Size   9.0 MB
Tables  0
PG Version  9.1.6
Created December 05, 2012 17:33

We have no users yet, in fact, I'm the only one using it at the moment. I'm sure we soon have to upgrade but I'm not sure with what to start. Should we start with the database, get more dynos, or what? I even started thinking of switching to MongoDB as the frequency of read and writing data to the database will be relatively high (incrementing the number of stars and listens per song, number of minutes listened by each user, etc etc).

Any suggestions?

Chris Travers
  • 25,424
  • 6
  • 65
  • 182
  • 1
    Seems you are having resource issues for postgres - see: http://stackoverflow.com/questions/11847144/heroku-psql-fatal-remaining-connection-slots-are-reserved-for-non-replication – Ross Dec 21 '12 at 10:43
  • 2
    With Dev databases you are limited to 20 connections: https://devcenter.heroku.com/articles/heroku-postgres-plans#starter-tier Make sure you are using connection pooling and reusing connections. – Ross Dec 21 '12 at 10:45
  • Any links on how to use connection pooling and reuse connections, I've never done that. Also, do you think it helps to add Memcached to lower the database access frequency? –  Dec 21 '12 at 10:57
  • How are you creating a connection to the database? How is django setup are you creating lots of threads / workers as that will make a connection per worker. – Ross Dec 21 '12 at 11:01
  • No, I have a standard django setup, that is, exactly how it is described in the Heroku documentation. I have `djcelery` installed but I'm not using it for now. Problem occurred only when I was uploading multiple files to Heroku, process it, and from there I upload it to S3. Maybe that's what is creating lots of threads??? –  Dec 21 '12 at 11:03
  • @MohamedTurki I had the same problem a couple days ago. I was also doing the same thing with S3, so that might be a culprit. – Bob Spryn Dec 26 '12 at 18:47
  • The problem was because I was consuming the 20 connections, also there was a problem with Heroku's end. Now it seems to be working fine, but eventually I'll have to upgrade. –  Dec 26 '12 at 20:15

0 Answers0