Reputation: 319
I've got a Rails app deployed on Heroku. It's getting a ton of traffic and it's lagging as a result. I'd like to: 1) make the app run faster and 2) make it so that the app can accommodate heavy traffic on any given day. I read about Heroku's "dynos" feature and have a few questions. Here's the Heroku explainer on what dynos are:
Heroku docs:
The containers used at Heroku are called “dynos.” Dynos are isolated, virtualized Linux containers that are designed to execute code based on a user-specified command. Your app can scale to any specified number of dynos based on its resource demands. Heroku’s container management capabilities provide you with an easy way to scale and manage the number, size, and type of dynos your app may need at any given time.
My questions:
Thank you in advance for your help with this! I'm a software developer and I can deploy an app to a virtual platform to get it in production -- but I don't know much about dev ops. Halp!
Upvotes: 0
Views: 994
Reputation: 37507
First up, increasing dyno count will not make your application run faster. It will however let you handle more requests at the same time, which may give the perception of speeding up your application. As requests come in your application has to execute your code and return a response. If your application is executing code already then other requests may need to wait to execute - thus exhibiting a 'slow response'. As it's a Rails app, you really want to ensure you are using Puma as your webserver and that you have to be configured it to use multiple processes (the number of which is specific to your application - there are guides available for this).
It's really important to make your application as fast as possible, caching etc all helps with that to keep things running sweet. Also, there's no magic number for the number of dynos to run - it's down to your traffic patterns. More requests per second == more dynos.
You do have the option of scaling vertically, this gives you more CPU and more RAM but with added cost.
Also, there's no real downside of scaling up except the added cost. Often though, I've seen that scaling up is often unnecessary. It solves an immediate problem but with the added cost. Often, optimising code, queries, caching etc is a much better path. Using NewRelic here really helps as that shows you were the time is spent inside your application. You'd be amazed at the performance a single Dyno can give you!
Upvotes: 2