Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I want to speed up my Heroku app, should I add an extra Dyno or the first Worker?

Thanks.

share|improve this question

migrated from stackoverflow.com Mar 29 '11 at 23:16

This question came from our site for professional and enthusiast programmers.

add comment

3 Answers

see my response in this post - Dynos do not increase performance

share|improve this answer
    
What about a Worker? –  andkjaer Mar 28 '11 at 19:02
    
nope, they just add background jobs so you can process in the background, eg sending emails, interacting with external services etc. –  John Beynon Mar 29 '11 at 6:01
    
but by moving the requests to a worker then you're freeing up dynos to do other requests. –  John Beynon Mar 29 '11 at 7:57
add comment

Things have changed a tad bit since this was originally answered. I also think they are missing a vital point:

The different dyno sizes do offer different CPU performance characteristics, and will aid a little in a high-CPU situations, but ideally you should consider offloading work to a background worker as a first step in optimization, as well as optimizing the code.

  • In production, you should always have at least two 1 x dynos or one 2 x dyno. When you run the "production check" on Heroku, it will complain if you're running the free 1 dyno account. This is because free accounts do not stay in stand-by, but when inactive for a while the dyno is shutdown and then when a request comes in it has to start the dyno from scratch and load the environment before it can even begin serving the request. This will of course add a massive delay. See: Dyno sleeping for more information, and consider Dyno Redundancy too.

So to sum it up. If you have only one dyno then you should add another one, or opt to use a 2 x dyno to prevent idle sleeping (and possibly increasing redundancy). Some CPU performance can be obtained through adjusting the dyno sizes, but the main ways to really boost CPU intensive application is through background jobs, architecture, and generally improving code efficiency.

P.S. Sure, you could set up some sort of polling for the app every hour and circumvent this policy that way, but hey let's be fair here - isn't that just cheating? You don't think Heroku deserves some pennies for running your (albeit small, but hopefully nicely working) app? :)

share|improve this answer
add comment

Neither workers nor dynos directly increase your application speed. If your application is slow, it will continue to be slow even if you add more dynos.

Dynos represents concurrent requests. With 1 dyno, Heroku handles 1 concurrent request at time. With 4 dynos, it will handle 4 requests but if a request takes 10 seconds to complete, 4 requests will take 10 seconds each.

Workers can indirectly speed up your application if you start moving heavy and slow processes (like email delivery or .PDF generation) to background tasks.

Generally speaking, the way to increase your application performance is to inspect your application behavior and improve the code. Normally, you might want to use a fast caching layer (like Redis or Memcached) to speed up slow queries or cache view fragments.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.