51 points · by fhoffa · 9y ago · 15 comments
Secondly, the error path on your backend must be strictly cheaper than the success path, or the whole scheme doesn't work. Particularly bad actions on error are for example logging an error at such a high severity that the log files need to be flushed and synced, which is likely to be tremendously expensive. Another example is taking a mutex and incrementing some error counter that normally wouldn't be incremented on the serving path. If this tends to synchronize all your serving threads, your server will collapse.
Third, load shedding can only be implemented correctly if you control the client and the server, end-to-end. Perhaps you want to avoid hot spots by serving a soft error from an overloaded shard. If your client is guaranteed to try another shard (or just give up) this is a good approach. If the client might retry on the same shard, then it's not helpful. You just "shed load" in such a way that you had to serve the same request twice.
* soft-shedding, where instead of dropping a request (which might just incur a retry storm), sometimes it is appropriate to send back a cheap response so that the clients sees a successful response instead of an error
* route critical requests and non-critical requests to separate clusters that can be scaled and configured independently. The blog post mention doing that using DNS, but that also works for mid-tier services.
* build back-pressure into the client. Instead of a timeout or error, a well-conforming client can enter "polite" mode when it receives a signal that the backend is overwhelmed.
Also anomalous load shedding is a great indication of a traffic anomaly. Big scrapers sometimes appeared that way first even when their attack was coming from a wide number of IPs.
Would these kind of techniques ever be a worthwhile exercise to a (early) startup or a small company that is hosting in the cloud or is it a last resort after you have already gotten quite large?
I'm definitely going to store the techniques away in my mental toolbox for later though and hope I get an opportunity to say "Procrustean load shedding" in a standup sometime.
The paper basically identifies the problem as a "livelock". You have a system that receives so many requests that instead of making any real progress, it tries to move those requests through different queues (Section 6).
If you're building a distributed system (say SOA), I find that load shedding also has the nice property that it gives the system's clients immediate feedback -- rather than having the client wait for a long time and make guesses.