50 points · by neya · 13y ago · 51 comments
I've played around with various routing methods before, and intelligent routing does seem to be incredibly difficult at scale. I don't think anybody gets it right? Any examples of intelligent routing at scale that works properly?
If not, might be a good place to start an OSS project into and benefit everyone. Intelligent routing should be far from impossible, all you need is very basic communication between servers and routers, possibly using some form of minimal broadcasting or multicast?
A simple solution could be having each server send 'dont send me more requests' and 'im ready for more requests'
One good notion is to embed server statistics into the response, like in an HTTP header. That way the LB can be aware of queue size, queue wait, utilization, etc. But that only works if the knowledge of server health is global to all load balancers, or if some LBs only talk to some servers.
If your requests are more or less the same "size", eg they take roughly the same amount of CPU / wall / etc, all of this gets vastly easier.
A system like this could have all sorts of knobs to turn. Requests could be partitioned into two groups: "probably fast" and "probably slow". Or three, four, n groups etc. Then the way in which the LBs distribute the requests could be tweaked. For example a ratio of 1/5 slow/fast requests per server.
This does require some feedback from the servers to the LBs. However it doesn't have to be fast. The servers could push some (request, time) pairs to some aggregating system at their leisure. Then the response time prediction algorithms used by the LBs are updated at some point. Probably doesn't have to be immediate.
1) In very large systems there are many many load balancers
2) Server "spikes" (eg swapping) can happen very suddenly, so distributing health info is a hard problem
3) Determining a priori which requests are heavy and light is also hard. Think about "SEO urls": they blow up the cardinality.
4) Even assuming perfect global knowledge, you are proposing to solve a variant of the knapsack problem.
Heroku likely has their own custom routing software that communicates with their databases to route incoming requests to the correct dynamos, etc.
EDIT: Key problem with the 'at scale' part is that Heroku does not have a single router, they have many many routers. I don't work there, so I have no idea if/why a single HAProxy couldn't handle it all, but obviously it can't or they'd just do that and save money!
Using a HAProxy with 'maxconn' flag works only for that single router instance. If a request arrives at a different router, it has no knowledge that server is wants to route the request to is already processing a request. That knowledge is internal state in a different router.
The key here would be to communicate this state between all routers. As I thought in the OP, the correct way to handle this at scale is some form of multicast - across a 1gbps network, broadcasted status updates should account for a tiny percent of traffic/processing, yet allow intelligent routing that would decrease latency immensely.
So I guess the original question still stands: is there any router project that communicates state between multiple load balancers/routers to allow intelligent routing at scale ?
EDIT2: Here we go - looks like research is being done in this area. Maybe Heroku should read this paper:
http://digitalcommons.unl.edu/cgi/viewcontent.cgi?article=10...
Yes. Consider that Heroku publishes DNS records for all their customers to the same set of nodes; those nodes must be responsible for routing all Heroku traffic. Sharding customers onto individual Haproxy LBs would require either updating an upstream load balancer (which just pushes the problem around) or updating DNS (which comes with long convergence times).
If you would extend the whole thing to have a negotiation protocol that lets the load balancer know how loaded the individual backend processes are then you could start talking about intelligent routing. That however currently does not exist in the Ruby world.
I'm inclined to give them the benefit of the doubt. They made a reasonable engineering and product tradeoff to increase their system's scalability, decrease it's latency, and allow new kinds of applications that are able to serve more than one request at once (eg. node.js servers holding onto tons of idle websockets).
Given an increasingly large infrastructure (which makes stronger queueing much harder if you don't want to add a lot of latency) and strong requests from customers to allow other languages that don't fit into the "one fast request per process" paradigm, I can absolutely see making that tradeoff. It makes the infrastructure simpler (and thus more robust), cuts some latency, and makes the many loud customers who wanted to run things like node.js happy.
Doing so, I would have been aware that in some cases, this would lead to suboptimal routing that increased latency, but I never really would have thought it would have as devastating effects on an application's overall performance as Rap Genius saw.
So yes, they do care a lot more about this issue now that there has been a big stir about it, but I think it's reasonable to assume that this may be more because they've realized it can have a huge impact on overall latency rather than a moderate one, and that it's come to their attention that some of their messaging and docs hadn't been updated reflecting the routing change.
But given how great of a company Heroku usually is, the fact that it is not in their interest to decrease their quality of service, and that there are very legitimate reasons to move away from intelligent routing (namely, the facts that it doesn't really make sense for applications that can do multiple requests concurrently and that it is extremely difficult to scale), I'm inclined to believe that this is more a mistake than a malicious lack of concern for their customer's well-being that they are only addressing due to vocal outside pressure.
(Something like my app name is heroku.ruby.free.cheapcustomers.myapp )
There will be lots of header handling but it seems simpler
The only difference is the URL here has a trailing question mark.
Why does this keep happening?
Or one that allows only k concurrent requests with a routing mesh that schedules m>k per server (dyno) or at least does that often enough.
Even with unlimited concurrent requests per server, similar problems may arise if the performance drops sharply with the number of concurrent requests being served (e.g. due to swapping.)
Fulfilling these commitments is Heroku’s number one
priority
I think this is the part that really breaks the camel's back for me.I don't doubt that dealing with the biggest PR disaster in the company's history is their number-one priority, don't get me wrong.
EDIT: It's probably better to make your opinion known on the blog post than here, though.
"Hey all our customers, We're terribly sorry for all the black magic stuff
we did (the shitty Newrelic reporting, etc.) and we've refunded your account
with $100*x for all the losses that we knowingly caused you and your business."
Unfortunately, that doesn't seem to be the case with this blog post.I'm not going to make it sound like this is something that can be fixed and mended by hiring some copywriters and PR consultants, but they're doing a very poor job of making me personally give them the benefit of the doubt.
It's like the asshole who says "I'm sorry you feel offended", or "I'm sorry I got caught". There isn't even a semblance of an apology and understanding of the consequences of this for their customers.