Janko
Janko

Reputation: 9335

How to benchmark the startup of my Rails app?

I put my Rails application on Heroku, and I see now that it has a very slow startup time. What I mean by this is that, when I first go to my website on Heroku (with a browser), it takes too much time to display the index page, but when I browse the website afterwards, the requests take normal time.

So how do I see what takes so much time on this "first" request?

Upvotes: 4

Views: 414

Answers (1)

user1027503
user1027503

Reputation:

it is normal, because you are not paying for your dyno and the first dyno will be idle out after a certain amount of time.

http://devcenter.heroku.com/articles/dynos

Apps that have only 1 web dyno will be idled out after a period of inactivity. The web dyno will be shut down. When a request comes in to an idled app your web dyno will be automatically spun back up, causing a few second delay for this first request. Subsequent requests will perform normally.

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

If you want to see what is going on, you can use the command (from you installation directory)

heroku logs

It will show the logs of your server.

In my staging enviroment, if I query now (when my dyno is idling) I can see in the logs

2012-02-18T12:17:24+00:00 heroku[web.1]: Unidling
2012-02-18T12:17:24+00:00 heroku[web.1]: State changed from down to created
2012-02-18T12:17:24+00:00 heroku[web.1]: State changed from created to starting

[.....]
2012-02-18T12:17:42+00:00 heroku[router]: GET [...] dyno=web.1 queue=0 wait=0ms service=9ms status=200 bytes=0

=> it took about 20 second to fullfill my first request.

Upvotes: 1

Related Questions