Why Heroku so slow?

Hi, I just deployed a simple crud (Rails 3.1) to heroku, and it takes more than 5 seconds to load the index page.

Does anyone know how to solve this?

Ps.: locally it takes less than 500 ms, and have more data at the database.

Thanks in advance.

Have you tried (in console)

$ heroku logs

It could help, but I have the same problem… sometimes. After that the application works fine

Javier Q.

That is weird, in the logs it looks like everything is working smoothly, but when I try to access it, takes me about 5 seconds.

Heroku put you app into a sleep mode when it’s no accessed in a certain amount of time. Sometimes when no one visited you application in the last several minutes and whoever access it, the app will bootstrap, this process can take several minutes. But this only occurs in the first request, subsequents request should run fast.

[]'s
Paulo Poiati

blog.paulopoiati.com

It could be the internet itself. Connections are not instantaneous.

Dieter Lunn
http://ubiety.ca

I can't be sure, but.. AFAIK

Does this only happen the first time the page is loaded?

Heroku unloads applications. Both when it's deployed, and after
periods of inactivity. The first load after it's been unloaded is
always slow.

It seems that (for example) if I access the app yesterday and then I access now, the server starts again (that’s what my log says)

I’ve never checked this before, but that make the access too slow (the first time)

I believe this to be the root issue. That's why things like reserved instances at AWS are sometimes better because they stay up all the time.

I understand the Google App engine is the same way. Makes it unusable for Grails apps because spinning up the JVM is so slow the app startup even times out causing no load at all.

That's normal behavior, it frees up memory on the server that's just sitting around doing nothing. That's also how Passenger works by default. It "intelligently" spawns and kills off instances.

But rest assured, if your application has more users accessing it, it won't be suspended.

Best regards

Peter De Berdt

And of course, there are people pinging their own “low traffic” app

as a work-around … Not sure what I have to think about that practice.

Is it costly/wasteful for the operator?

Peter

Off the top of my pointy little head, it seems that each one, if it's
a reasonably small app, as I'd expect most free ones to be, should be
negligible cost... but since so many people use Heroku for free, it's
likely to add up to something significant. Wouldn't be surprised if
Heroku starts forbidding it. However, there's no way they can really
detect what's a "just keep the app live" ping. Maybe they'll just ask
us nicely not to do it.

For paid ones, which are likely to be larger, maybe there would be
some cost... but then that's the customer's decision.

-Dave

maybe is something with the content that is heavy to load

It isn’t that, I’m sure.

It isn't that, I'm sure.

You have not (unless I missed it) confirmed whether it is only the
first time that you access the app after a period of inactivity that
you see the problem. If it is only on the first access then it is
just the time taken to start the app up as noted by other posters.

Colin

Sorry, it is just that I haven’t had time to test it from my home (with good internet connection), I’ve only tested at work (and at iPhone with 3G), so that might also be a problem.

But no, it is not just the first time. I was just waiting to answer until I had tested with a better connection.

Although I don’t think connection is the problem.

While on the subject does anyone know what heroku’s timeout is
before it brings down an app?

Adrian Caceres wrote in post #1044103:

While on the subject does anyone know what heroku's timeout is before it
brings down an app?

It will bring your app down after 1 hour of inactivity. Our problem was
also that the first request takes a lot of time because the application
has to start-up again.

We found a nice solution ( http://www.wekkars.com ) that just does what
we want, keep our application alive.

Dries Steenhouwer wrote in post #1054162:

Adrian Caceres wrote in post #1044103:

While on the subject does anyone know what heroku's timeout is before it
brings down an app?

It will bring your app down after 1 hour of inactivity. Our problem was
also that the first request takes a lot of time because the application
has to start-up again.

We found a nice solution ( http://www.wekkars.com ) that just does what
we want, keep our application alive.

Isn't this like pooing in your own nest?

The reason that apps are taken down is to share resources with apps that
need them.

If everyone pings their apps, the resource usage will (I am guessing?)
skyrocket, and we would either kiss goodbye to free services like
Heroku, or all suffer them getting slow when we need them.

I'm open to hearing why I'm wrong, but on face value this looks sick...

The other solution is, of course, to scale to more than 1 web dyno.

https://devcenter.heroku.com/articles/dynos#dyno-idling

"Apps that have more than 1 web dyno running are never idled out. Workers dynos are never idled out."

The goal should be to have monetized your app such that it makes sense to pay for some of the scalability that the Heroku platform makes possible.

Even Wekkars is setting themselves up to become a paid service. Then you'll have to weight the cost of the service that keeps your free service from idling against the cost of a service that doesn't get idled.

-Rob