Dynos
Table of Contents
See How it Works, an illustrated tour of Heroku’s architecture and how dynos fit into the picture.
A dyno is a single process of any type running on the Heroku platform. This can include web processes, worker processes (such as timed jobs and queuing systems), and any process types declared in the app’s Procfile. One-off admin processes are also run as dynos.
Dyno Features
-
Elasticity: The number of dynos allocated for your app can be increased or decreased at any time - without any server provisioning.
-
Intelligent routing: The routing mesh tracks the location of all web dynos and routes HTTP traffic to them accordingly.
-
Process management: Each dyno process is monitored for responsiveness. Misbehaving dynos are taken down and new dynos are launched in their place.
-
Distribution and redundancy: Dynos are distributed across a distributed execution environment known as the dyno manifold. An app configured with two web dynos is running two processes, as you’d expect, but each process is running in a separate physical location. If a machine goes down, your site stays up - even with only two dynos.
-
Isolation: Every dyno is completely isolated in its own subvirtualized container, with many benefits for security, resource guarantees, and overall robustness.
Dyno Concurrency and Scaling
The number of dynos allocated to an app directly affects the app’s maximum concurrency and request throughput. Adding more web dynos allows you to handle more concurrent HTTP requests, and more workers will let you process more jobs in parallel.
Read more about scaling your dynos on Heroku.
Dyno Memory Behavior
Each dyno gets 512MB of memory to operate within. Most applications will fit comfortably within this allowance, and as a developer you need not worry about memory at all.
In some cases, your dyno may reach or exceed that 512MB amount. Typically this is because of a memory leak in your application, in which case you may wish to use a memory profiling tool such as Oink for Ruby or Heapy for Python to track down the leak and fix it.
Dynos that exceed 512MB of memory usage will display an R14 error in the logs, like this:
2011-05-03T17:40:10+00:00 heroku[worker.1]: Process running mem=528MB(103.3%)
2011-05-03T17:40:11+00:00 heroku[worker.1]: Error R14 (Memory quota exceeded)
Memory used above 512MB will go into swap, which can substantially degrade dyno performance.
If the memory size keeps growing until it reaches three times (512MB x 3 = 1.5GB) its quota, the dyno manifold will restart your dyno with an R15 error:
2011-05-03T17:40:10+00:00 heroku[worker.1]: Process running mem=2565MB(501.0%)
2011-05-03T17:40:11+00:00 heroku[worker.1]: Error R15 (Memory quota vastly exceeded)
2011-05-03T17:40:11+00:00 heroku[worker.1]: Stopping process with SIGKILL