I did a load test of my Rails application yesterday, running 8 dynos with 3 concurrent Unicorn processes on each. This is the New Relic output:
As you can see, my Rails stack itself has a pretty good response time (DB, Web, etc), but the queue time is super terrible.
What can I do about this? Is this inherent in Heroku performance, or does it just mean I need to add more dynos?
Any advice appreciated.
You can view the amount of free dyno hours remaining by using the CLI. You can do this by running heroku ps on one of your free apps. Alternatively, you can also view this on Dashboard's billing page, which is refreshed daily to display the updated amount.
The Heroku Runtime is the part of the Heroku platform responsible for running and managing your application. The Heroku Runtime is responsible for provisioning and orchestrating containers (dynos), managing and monitoring their lifecycle, providing proper network configuration, HTTP routing, log aggregation, and more.
Starting today, Heroku accounts have an account-based pool of free dyno hours for use on free apps. This replaces the 18 hours a day limit on free apps, allowing a free app to run 24/7 if needed. New accounts receive 550 free dyno hours and you can verify your identity with a credit card for an additional 450 hours.
Basically, break the problem down into its parts and test each part. Simply throwing a bunch of requests at a cluster of unicorns isn't necessarily a good way to measure throughput. You have to consider many variables (side note: checkout "Programmers Need To Learn Statistics Or I Will Kill Them All" by Zed Shaw)
Also, you're leaving out critical information from your question for solving the mystery.
You're the only person who can answer these questions.
Queuing time, if I understand Heroku's setup correctly, is essentially the time new requests sit waiting for an available unicorn (or to be more accurate with unicorn, how long requests sit before they are grabbed by unicorn). If you're load testing and feeding the system more than it can handle then, while your app itself my serve requests that it's ready to handle very quickly, there will still be a backlog of requests waiting for an available unicorn to process it.
Depending on your original setup, try the following variables in your test:
Also, find out if the test results chart you're showing above is an average, or a 95th percentile with standard deviations, or some other measurement.
Only after you've broken the problem down into its component parts will you know with any predictability whether or not adding more unicorns will help. Looking at this basic chart and asking, "Should I just add more unicorns?" is like having a slow computer and asking, "Should I just add more RAM to my machine?". While it may help you're skipping the steps of actually understanding why something is slow, and adding more of something, while it may help, won't give you any deeper understanding of why it's slower. Because of this (and especially on heroku), you might wind up overpaying for more dynos when you don't need them, if only you could get to the root of what is causing the longer than expected queuing times you'll be in much better shape.
This approach, of course, isn't unique to heroku. Trying experiments, tweaking variables, and recording the outcome measurements will allow you to pick apart what's going on inside those performance numbers. Understanding the "why" will enable you to take specific, educated steps that should have mostly predictable effects on overall performance.
After all of that you may find that yes, the best way to improve the performance in your specific case is to add more unicorns, but at least you'll know why and when to do so, as well as a really solid guess as to how many to add.
I essentially wrote another question, and then sat back, and realized I just edited this exact question a week before, and knew the answer to both.
What jefflunt said is basically 100% true, but, because I'm here, I'm here to spell it out.
There's 2 solutions:
They basically boil down to the same exact concept, but:
Granted, this is just the roughest of frameworks on how to gauge the problem, especially because traffic is always weighted somehow, and taking an average (over the median), is usually a better gauge because you're taking more into consideration the 95% requests, but you'll be close to the right number to understanding what kind of capacity you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With