News for hackers. Stuff that matters.
Re:Heroku's Ugly Secret: The story of how the cloud-king tur... by toast76 on Wednesday February 13, 2013 @06:31PM (#5216449)
Wow. This is explains a lot.

We've always been of the opinion that queues were happening on the router, not on the dyno.

We consistently see performance problems that, whilst we could tie down to a particular user request (file uploads for example, now moved to S3 direct), we could never figure out why this would result in queuing requests given Heroku's advertised "intelligent routing". We mistakenly thought the occasion slow request couldn't create a queue....although evidence pointed to the contrary.

Now that it's apparent that requests are queuing on the dyno (although we have no way to tell from what I can gather) it makes the occasional "slow requests" we have all the more fatal. e.g. data exports, reporting and any other non-paged data request.

Re:Heroku's Ugly Secret: The story of how the cloud-king tur... by 46Bit on Wednesday February 13, 2013 @06:57PM (#5216593)
Several Rails apps I develop have been suffering from similar issues. Perhaps 2-3% of requests take 0.4-2s in just processing. If the allocation is a little intelligent, it'll not perform too badly and is less work than much harder optimization. Yet if it's random, it'll queue up horribly.

I'm pissed. Spent way too much time unable to explain it to coworkers, thinking I just didn't understand Heroku's platform and that it was my fault.

Turns out, I didn't understand it, because Heroku never thought to clearly mention something that's pretty important.

Easiest fix: moving to EC2 next week. I've wanted to ever since our issues became evident but it's hard to make a good argument from handwaving about 'problems'.

Re:Heroku's Ugly Secret: The story of how the cloud-king tur... by jholman on Wednesday February 13, 2013 @07:07PM (#5216657)
> Easiest fix: moving to EC2 next week. I've wanted to ever since these issues became evident but it's hard to make a good argument from handwaving about 'problems'.

Of course, then you need to solve all these problems yourself. That sounds pretty easy, you'll have it done next week no problem!

That was sarcastic, but this isn't: good luck, let us know how it goes.

Re:Heroku's Ugly Secret: The story of how the cloud-king tur... by codewright on Wednesday February 13, 2013 @10:40PM (#5217548)
I've done dev-ops in the ads industry before, it's really not that hard if you're a competent programmer. You just have to take a more studious approach than most non-dev-ops programmers and read up on things before deploying them.

But if you want to let the various PAAS providers put the fear into you, that's your cowardice.

Let the others learn as they may.

Edit:

To clarify, Heroku is making the problem harder on themselves than it would be for an individual to serve their own needs because of the complexity managing so many customers and apps.

You don't have to be Heroku to do for yourself what they offer.

Re:Heroku's Ugly Secret: The story of how the cloud-king tur... by 46Bit on Wednesday February 13, 2013 @11:41PM (#5217772)
Thanks for this codewright. I've consistently found that learning things others are afraid of is a good business decision - and I reckon this is a big one.
Re:Heroku's Ugly Secret: The story of how the cloud-king tur... by 46Bit on Wednesday February 13, 2013 @07:13PM (#5216683)
> Of course, then you need to solve all these problems yourself. That sounds pretty easy, you'll have it done next week no problem!

I agree with this, actually. I know it's not simple to do your own servers when you're growing. Yet I'd rather improve my existing ops skills a bit than have to setup everything as async APIs (on EC2 anyway). That's the only way I can see that I can solve this.

Re:Heroku's Ugly Secret: The story of how the cloud-king tur... by timr on Wednesday February 13, 2013 @09:20PM (#5217246)
"Yet I'd rather improve my existing ops skills a bit than have to setup everything as async APIs (on EC2 anyway). That's the only way I can see that I can solve this."

You're going to discover that a lot of "ops skills" boils down to "do things asynchronously whenever possible". And while nearly any smart engineer can think of the "right" way of doing something, finding the time to do it all is a huge opportunity cost.

That's what the parent is trying to say. It's not that you can't do it; it's that it's a really bad idea to do it, at first.

Re:Heroku's Ugly Secret: The story of how the cloud-king tur... by coldtea on Wednesday February 13, 2013 @11:19PM (#5217693)
>That's what the parent is trying to say. It's not that you can't do it; it's that it's a really bad idea to do it, at first.

This "bad idea" is how 90% of the web works...

Re:Heroku's Ugly Secret: The story of how the cloud-king tur... by loopdoend on Wednesday February 13, 2013 @10:36PM (#5217535)
It's a lot easier than you think when you aren't limited by artificial restrictions on the number of concurrent requests you can serve. Taking out what could be considered here to be a hostile intermediary will free up tech resources to fix problems that actually exist.

I can only imagine how these guys must have been beating their heads against the wall. Heroku charges a premium price and should be providing a premium service.

Re:Heroku's Ugly Secret: The story of how the cloud-king tur... by coldtea on Wednesday February 13, 2013 @11:18PM (#5217688)
>Of course, then you need to solve all these problems yourself. That sounds pretty easy, you'll have it done next week no problem!

Depending on the complexity of their setup, they COULD have it done next week no problem.

After all tens of thousands of other sites have. It's not like everybody except Google and Facebook is using Heroku.

Re:Heroku's Ugly Secret: The story of how the cloud-king tur... by vidarh on Thursday February 14, 2013 @11:30AM (#5220174)
Solving this problem is easy: Run haproxy, and he'll have detailed control over the balancing algorithm, including balancing by least connections and a number of other measures (if he, for example, wants to segregate the long running requests on a specific set of backends, it's trivial).
Re:Heroku's Ugly Secret: The story of how the cloud-king tur... by tbenst on Wednesday February 13, 2013 @07:45PM (#5216821)
Best thing we can do is follow through on the article's call-to-action for emailing [email protected]:

"After reading the following RapGenius article (http://rapgenius.com/James-somers-herokus-ugly-secret-lyrics), we are reevaluating the decision to use Heroku. I understand that using a webserver like unicorn_rails will alleviate the symptoms of the dyno queuing problem, but as a cash-strapped startup, cost-efficiency is of high importance.

I look forward to hearing you address the concerns raised by the article, and hope that the issue can be resolved in a cost-effective manner for your customers."

Re:Heroku's Ugly Secret: The story of how the cloud-king tur... by jaggederest on Wednesday February 13, 2013 @07:17PM (#5216703)
It's interesting, because initially the way that queue time detection worked within New Relic was via timestamps.

Currently, though, I believe it's just fed as a number of milliseconds: https://github.com/newrelic/rpm/blame/master/lib/new_relic/a...

This solves the issue of the application seeing out-of-whack queue times if there's clock skew between the front-end routing framework and the actual dyno box, but misses all the queued time spent in the dyno-queue per rap genius's post.

Re:Heroku's Ugly Secret: The story of how the cloud-king tur... by sgrock on Wednesday February 13, 2013 @09:45PM (#5217354)
I work on New Relic's ruby agent, and you're right (hey Justin). In fact we support both methods (i.e. passing a timestamp or a duration). We rely on the front end server (e.g. nginx, apache) to set a timestamp in an HTTP header and forward that to the ruby application. In the case of heroku there is a special header that they pass which describes the queuing duration. Because we're in the ruby application we don't have control over whether this timestamp is accurate but I'm very interested in ideas on how we could do a better job in this situation.

We do provide javascript based browser instrumentation ("Real User Monitoring") which measures request time from the browser's perspective. This might give you a more accurate idea of what real users are experiencing in this case.

Re:Heroku's Ugly Secret: The story of how the cloud-king tur... by jaggederest on Wednesday February 13, 2013 @10:36PM (#5217537)
My thoughts before I left the project were to add increased granularity of queue times via having headers added at each passing server and show a rainbow chart for the 'depth' of queue at each layer, not sure if that ever got added.

There's facility for that in the Agent, to allow multiple copies of the header and use whichever came first (for the beginning) and whichever came last (for the end ), it'd be relatively easy to hook metrics into each of those.

Re:Heroku's Ugly Secret: The story of how the cloud-king tur... by runarb on Wednesday February 13, 2013 @06:50PM (#5216560)
Is it so that a dyno can only handle a single user request at a time?

Why dos it not use some kind of scheduling system to handle other task while one task is waiting on i/o?

Re:Heroku's Ugly Secret: The story of how the cloud-king tur... by Cushman on Wednesday February 13, 2013 @06:55PM (#5216589)
It's not exactly so, if you use a server that spawns child processes: http://michaelvanrooijen.com/articles/2011/06/01-more-concur... you can potentially handle 3-4 requests per dyno at a time. That doesn't fix the root problem, though.
Re:Heroku's Ugly Secret: The story of how the cloud-king tur... by toast76 on Wednesday February 13, 2013 @08:14PM (#5216955)
Investigating this approach now. It won't fix the problem, but will certainly reduce the occurrence of blocked dynos. Thx!

EDIT: will need to look into our memory perf though, looks like we'll need to do some work to get more than a couple of workers.

Re:Heroku's Ugly Secret: The story of how the cloud-king tur... by joeya on Wednesday February 13, 2013 @11:41PM (#5217774)
I can confirm this. We experimented with Unicorn as a way to get some of the benefits of availability-based routing despite Heroku's random routing. Our medium-sized app (occupying ~230 MB on boot) would quickly exceed Heroku's 512 MB memory limit when forking just 2 unicorn workers, so we had to revert to thin and a greater number of dynos.
Re:Heroku's Ugly Secret: The story of how the cloud-king tur... by dspillett on Thursday February 14, 2013 @04:32AM (#5218659)
That makes more efficient use of the nodes, because otherwise idle cpu time and memory allocation within a node has a chance of getting used, but it doesn't stop the queueing problem (it mearly gives you more virtual nodes to hand tasks to unintelligently).

Also as the nodes are virtual machines anyway and may be contending with each other for IO, and for most apps these days you spend more time waiting for IO than you do spinning the CPU (unless you have a lot of static content so don't need to hit the db for many requests - but such requests are better handled by a caching layer above that which handles the fancier stuff), so the benefit of running multiple processes per node is going to be a lot less noticable than if you are talking about the nodes being physical machines with dedicated storage channels.