Heroku Dynos Explained

2017-05-24T14:19:10
ID RAPID7COMMUNITY:90B6F1E97B7AE4687ADABB043A564A34
Type rapid7community
Reporter Rapid Seven
Modified 2017-05-24T14:19:10

Description

<!-- [DocumentBodyStart:68bf6c5e-db63-4112-a65c-aa2a2c251aaf] --><div class="jive-rendered-content"><p><span style="font-family: arial, helvetica, sans-serif; font-size: 14pt; color: #e95f26;"><strong><em>What are Heroku Dynos?</em></strong></span></p><p style="min-height: 8pt; padding: 0px;"> </p><p style="text-align: left;"><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="color: #333333;">If you’ve ever hosted an application on </span><a class="jive-link-external-small" href="https://community.rapid7.com/external-link.jspa?url=http%3A%2F%2Fwww.heroku.com%2F" rel="nofollow" target="_blank"><span style="color: #0066cc;">Heroku</span></a><span style="color: #333333;">, the popular platform as a service, you’re likely at least aware of the existence of “Dynos”. But what exactly are Heroku Dynos and why are they important?</span></span></p><p style="min-height: 8pt; padding: 0px; text-align: left;"> </p><p style="margin-bottom: .0001pt; background: white;"><span style="color: #333333; background: white; font-size: 12pt; font-family: arial, helvetica, sans-serif;"><a href="https://blog.logentries.com/mstatic/content/uploads/2016/04/heroku-dynos-explained.jpg"><img alt="heroku-dynos-explained" class="j-img-floatend jive-image" height="275" src="https://blog.logentries.com/mstatic/content/uploads/2016/04/heroku-dynos-explained.jpg" style="float: right; height: 275px; width: 343.946px;" width="344"/></a></span></p><p style="margin-bottom: .0001pt; background: white;"><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="color: #333333;">As explained in </span><a class="jive-link-external-small" href="https://community.rapid7.com/external-link.jspa?url=https%3A%2F%2Fdevcenter.heroku.com%2F" rel="nofollow" target="_blank"><span style="color: #0066cc;">Heroku’s docs</span></a><span style="color: #333333;">, 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. You then have the option of adding additional Dynos and specifying Dyno processes in your </span><a class="jive-link-external-small" href="https://community.rapid7.com/external-link.jspa?url=https%3A%2F%2Fdevcenter.heroku.com%2Farticles%2Fprocfile" rel="nofollow" target="_blank"><span style="color: #0066cc;">procfile</span></a><span style="color: #333333;">. Dynos actually come in three different flavors:</span></span></p><p style="min-height: 8pt; padding: 0px; margin-bottom: .0001pt; background: white;"> </p><ul style="list-style-type: disc;"><li><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="color: #333333;"><strong>Web Dynos</strong></span><span style="color: #333333;">: for handling web processes</span></span></li><li><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="color: #333333;"><strong>Worker Dynos</strong></span><span style="color: #333333;">: for handling any type of process you declare (like background jobs)</span></span></li><li><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="color: #333333;"><strong>One-off Dynos</strong></span><span style="color: #333333;">: for handling one-off tasks, such as database migrations</span></span></li></ul><p style="min-height: 8pt; padding: 0px;"> </p><p style="margin-bottom: 19.2pt; background: white;"><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="color: #333333;">One of the great things about Heroku </span><ins cite="mailto:Elizabeth%20Gordy" datetime="2017-04-14T10:37"></ins><span style="color: #333333;">Dynos is how easy they are to scale up and out. Through Heroku’s admin portal or via the command line, you can easily add more Dynos or larger Dynos. Adding additional Dynos can help speed up your application’s response time by handling more concurrent requests, whereas adding larger Dynos can provide additional RAM for your application.</span></span></p><p style="margin-bottom: 19.2pt; background: white;"><span style="color: #e95f26; font-size: 18.6667px; font-family: arial, helvetica, sans-serif;"><strong><em>Using Heroku Dynos to get the insights you need </em></strong></span></p><p style="margin-bottom: 19.2pt; background: white;"><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="color: #333333;">Great. I get it. Dynos make it easy to run my application with less hassle. For this reason, I should have to think very little about Heroku <ins cite="mailto:Elizabeth%20Gordy" datetime="2017-04-14T10:38"></ins></span><span style="color: #333333;">Dynos, right? Wrong!</span></span></p><p style="margin-bottom: 19.2pt; background: white;"><span style="color: #333333; font-family: arial, helvetica, sans-serif; font-size: 12pt;">As Dynos are individual containers and identified uniquely in your Heroku logs, they can provide some great insight into where issues may be stemming from when things go wrong.</span></p><p style="margin-bottom: 19.2pt; background: white;"><span style="color: #333333; font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="color: #333333;">When </span><span style="color: #0066cc;"><span style="color: #303030;">sending Heroku logs to</span> <a class="jive-link-external-small" href="https://community.rapid7.com/external-link.jspa?url=https%3A%2F%2Fwww.rapid7.com%2Fproducts%2Finsightops%2F" target="_blank">InsightOps</a></span><span style="color: #333333;">, a Dyno’s unique ID will automatically be logged in key-value pair format along with information about the process it handled. In the example below, we see web Dynos being identified along with the HTTP requests being handled:</span></span></p><p style="margin-bottom: 19.2pt; background: white;"><a href="https://blog.logentries.com/mstatic/content/uploads/2016/04/heroku_log_view-2.png"><img alt="heroku_log_view" class="jive-image" src="https://blog.logentries.com/mstatic/content/uploads/2016/04/heroku_log_view-2.png"/></a></p><p style="margin-bottom: 19.2pt; background: white;"><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;">A<span style="color: #333333; background: white;">n easier way to view this data in InsightOps is to use the Table View:</span></span></p><p style="margin-bottom: 19.2pt; background: white;"><span style="color: #333333; background: white;"><a href="https://blog.logentries.com/mstatic/content/uploads/2016/04/heroku_tableview.png"><img alt="heroku_tableview" class="jive-image" src="https://blog.logentries.com/mstatic/content/uploads/2016/04/heroku_tableview.png"/></a></span></p><p style="margin-bottom: 19.2pt; background: white;"><span style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="color: #333333;">As you can see, the Heroku Dyno is easily identified along other pertinent data. Since I’ve enabled </span><a class="jive-link-external-small" href="https://community.rapid7.com/external-link.jspa?url=https%3A%2F%2Fblog.logentries.com%2F2016%2F03%2Fhow-to-analyze-herokus-new-runtime-metrics%2F" rel="nofollow" target="_blank"><span style="color: #0066cc;">Heroku’s beta log-runtime-metrics</span></a> <span style="color: #333333;">from </span><a class="jive-link-external-small" href="https://community.rapid7.com/external-link.jspa?url=https%3A%2F%2Fdevcenter.heroku.com%2Fcategories%2Flabs" rel="nofollow" target="_blank"><span style="color: #0066cc;">Heroku Labs</span></a><span style="color: #333333;">, I can also see data related to CPU and memory per Dyno, which is particularly useful for identifying issues like too much swap memory being used (perhaps indicating a need to scale up my Dynos).</span></span></p><p style="min-height: 8pt; padding: 0px; margin-bottom: .0001pt; background: white;"> </p><p style="margin-bottom: 19.2pt; background: white;"><span style="font-family: arial, helvetica, sans-serif; color: #333333; font-size: 12pt;">Since Dynos are uniquely identified in key value pairs, you can also use them to visualize data. In the example below, I’m visualizing how much swap memory each Dyno is using over a given period of time:</span></p><p style="margin-bottom: 19.2pt; background: white;"><span style="color: #333333; background: white;"><a href="https://blog.logentries.com/mstatic/content/uploads/2016/04/heroku_swap_memory.jpg"><img alt="heroku_swap_memory" class="jive-image" src="https://blog.logentries.com/mstatic/content/uploads/2016/04/heroku_swap_memory.jpg"/></a></span></p><p style="margin-bottom: 19.2pt; background: white;"><span style="color: #333333; background: white; font-size: 12pt; font-family: arial, helvetica, sans-serif;">You can also create visualizations to help you monitor how much each Dyno is being used compared to others:</span></p><p style="margin-bottom: 19.2pt; background: white;"><span style="color: #333333; background: white;"><a href="https://blog.logentries.com/mstatic/content/uploads/2016/04/Screen-Shot-2016-04-27-at-1.03.45-AM.png"><img alt="Screen Shot 2016-04-27 at 1.03.45 AM" class="jive-image" src="https://blog.logentries.com/mstatic/content/uploads/2016/04/Screen-Shot-2016-04-27-at-1.03.45-AM.png"/></a></span></p><p style="margin-bottom: 19.2pt; background: white;"><span style="color: #333333; background: white; font-size: 12pt; font-family: arial, helvetica, sans-serif;">Finally, checking the Heroku Dyno related to errors in your logs could hint at Dyno-related issues. In the example below, we see that Dyno web.2 is related to both errors, which happen to be backend connection timeouts. While Heroku Dynos are allowed to fail and automatically restart on a different server, this finding could warrant you manually restarting your Dynos to alleviate the issue.</span></p><p style="margin-bottom: 19.2pt; background: white;"><span style="color: #333333; background: white;"><a href="https://blog.logentries.com/mstatic/content/uploads/2016/04/Screen-Shot-2016-04-27-at-1.08.23-AM.png"><img alt="Screen Shot 2016-04-27 at 1.08.23 AM" class="jive-image" src="https://blog.logentries.com/mstatic/content/uploads/2016/04/Screen-Shot-2016-04-27-at-1.08.23-AM.png"/></a></span></p><p style="margin-bottom: 19.2pt; background: white;"><span style="color: #e95f26; background: white; font-size: 18.6667px; font-family: arial, helvetica, sans-serif;"><strong><em>Start logging with Heroku Dynos today</em></strong></span></p><p style="margin-bottom: 19.2pt; background: white;"><span style="color: #333333; background: white; font-size: 12pt; font-family: arial, helvetica, sans-serif;"><span style="color: #333333; background: white;">Ready to start logging from your Heroku app today? </span><span style="background: white;">Check out our <a class="jive-link-external-small" href="https://community.rapid7.com/external-link.jspa?url=https%3A%2F%2Fwww.rapid7.com%2Fproducts%2Finsightops%2Fbeta-request%2F" target="_blank">free log management tool</a>.</span></span></p></div><!-- [DocumentBodyEnd:68bf6c5e-db63-4112-a65c-aa2a2c251aaf] -->