Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku: web dyno vs. worker dyno? How many/what ratio do I need?

I was curious as to what the difference between web and worker dynos is on Heroku. They give a one sentence explanation on their pricing page, but this just left me confused. How do I know how many to pick of each? Is there a ratio I should aim for? I'm pretty new to this stuff, so can someone give an in depth explanation, or maybe some sort of way I can calculate how many and which kind of dynos I would need?

Also, I'm confused about what they mean by the amount of hours for each dyno.

http://www.heroku.com/pricing

I also happened upon this article. As one of their suggested solutions, they said to increase the amount of dynos. Which type of dyno are they referring to here?

http://devcenter.heroku.com/articles/backlog-too-deep

like image 941
varatis Avatar asked Dec 08 '11 04:12

varatis


People also ask

How many dynos do I need heroku?

By default, applications are limited to 100 total dynos across all process types. Additionally, a single process type that uses performance dynos can't be scaled to more than 10 dynos. Submit a request to raise this limit for your application.

What is the difference between web and Worker heroku?

Web: Web dynos are dynos of the “web” process type that is defined in your Procfile. Only web dynos receive HTTP traffic from the routers. Worker: Worker dynos can be of any process type declared in your Procfile, other than “web”. Worker dynos are typically used for background jobs, queueing systems, and timed jobs.

What is a web Dyno heroku?

But what exactly are Heroku Dynos and why are they important? As explained in Heroku's docs, Dynos are simply lightweight Linux containers dedicated to running your application processes. At the most basic level, a newly deployed app to Heroku will be supported by one Dyno for running web processes.

What is a worker Dyno heroku?

Heroku allows you to specify an application-specific process model, which can include background workers retrieving and processing jobs from the work queue.


2 Answers

Your best indication if you need more dynos (aka processes on Cedar) is your heroku logs. Make sure you upgrade to expanded logging (it's free) so that you can tail your log.

You are looking for the heroku.router entries and the value you are most interested is the queue value - if this is constantly more than 0 then it's a good sign you need to add more dynos. Essentially this means than there are more requests coming in than your process can handle so they are being queued. If they are queued too long without returning any data they will be timed out.

There's no ideal ratio I'm afraid, you could have an app doing 100 requests a second needing many web processes but just doesn't make use of workers. You only need worker processes if you are doing processing in the background like sending emails etc etc.

ps Backlog too deep would be a Dyno web process that would cause it.

UPDATE: On March 26 2013 Heroku removed queue and wait fields from the log out put.

queue and wait fields have been removed from router log messages. Also, the Heroku router no longer sets X-Heroku-Dynos-In-Use, X-Heroku-Queue-Depth and X-Heroku-Queue-Wait-Time HTTP headers for incoming requests.

like image 153
John Beynon Avatar answered Nov 26 '22 18:11

John Beynon


Dynos are basically processes that run on your instance. With the new Cedar stack, they can be set up to execute any arbitrary shell command. For web applications, you generally have one process called "web" which is responsible for responding to HTTP requests from users. All other processes are what were previously called "workers." These run continuously in the background for things like cron, processing queues, and any heavy computation that you don't want to tie up your web processes. You can also scale each type of process, so that multiple processes of each type will be booted up for additional concurrency. The amount of each that you use really depends on the needs of your application and the load it receives. You can use tools like the New Relic plugin to monitor these things. Take a look at the articles on the Process Model and the Procfile in Heroku's dev center for more details.

like image 28
Jimmy Avatar answered Nov 26 '22 16:11

Jimmy