4 ms·
I'm sorry, but this is mostly wrong. Yes, you need to design your code to withstand disaster shutdown SIGKILL type situations. That doesn't mean you get to ign
by joatmon-snoo 7y ago
I'm sorry, but this is mostly wrong.
Yes, you need to design your code to withstand disaster shutdown SIGKILL type situations. That doesn't mean you get to ignore SIGTERM.
The vast majority of shutdowns are due to routine maintenance events. If you get SIGTERM-ed and all you did was crash, here's a short list off the top of my head of bad things that can and do result:
* Tail latency goes up, because clients talking to tasks that don't shut down gracefully have to wait for at least one RPC timeout - possibly more if channel timeout is longer - before they retry elsewhere. (This will manifest in multiple ways, because things like load balancers will also be slow to respond.)
* System contention goes up - if your server was holding any kind of distributed lock (e.g. DB write) when it went down, everyone else needs to wait for that lock to time out before someone else can take it. (Hopefully your locks require keep-alives to hold them!)
* Corruption of data in transit - a crashing binary is basically a big ol blob of UB. With enough replication and checksumming you can mitigate this, but it doesn't mean you get to do dangerous things now! Guardrails only work if you don't take a sledgehammer to them.
* I really, really hope you don't have any request affinity in your system, because if you do, now your caches are empty, your dependencies are going to see you doing expensive ops much more frequently, and so on. (And if you're a streaming system, well now you're just all kinds of screwed.)
- m0zg 7y agoI hardly ever felt so strongly about anything in software engineering, although I will concede this is an acquired taste, and it took me some time to see the obvious truth in this. I will reiterate. If your programs are designed to be kill-safe, it's a waste of time to shut them down any other way. It is also harmful to your systems design, because you can't guarantee that your hardware won't give out, especially if you run on e.g. 50-100K cores (as many Google services do). You can basically be certain at that point that individual tasks (and hardware they run on) will die from time to time. Note that this only applies to shut down, not to e.g. draining traffic. That part can and should still be orderly in most systems so as not to disrupt the user experience too much, and Google does have that in their RPC stack (lame duck mode etc). For everything else you end up doing a lot of logging, checkpointing, and 2PC. For distributed systems you end up using consensus mechanisms and eliminating SPOFs. If you rely on orderly shutdown for correctness in your distributed system, I'd like to know the name of your product so I can avoid it.
- ownagefool 7y agoI think you're talking past each other a bit here. Nothing the parent is discussing is regarding correctness, so I think your last sentence is a bit uncalled for.
- m0zg 7y agoI'm actually serious about that last bit. If your distributed system relies on guarantees it _does not have_ in order to operate correctly, one would be well advised to stay away from it.
- ownagefool 7y agoYou can be super serious about it all you want, but it's accusatory and doesn't reflect the post you responsed to, which referred to performance and user experience implications with shooting nodes in the head. Personally I think there was the formation of a really good debate. As you said, if you drain the nodes traffic before killing it, you're probably right, any costs associated with maintaining consistency is probably saved by the human aspect of just not waiting for a clean shutdown of processes at scale. But when you throw in the sass, people stop listening and we all get dumber for it.
- m0zg 7y agoBut there's no "debate" here to be had. All the high scale companies (Google, FB, Amazon, Microsoft, Netflix, others) do not rely on their distributed system nodes being able to wind down in an orderly fashion. Shit, Netflix and Google (and likely others as well) stage fault tolerance exercises, taking random nodes (or entire datacenters) out of rotation and checking if things still work. There's no way to get to five nines if you expect your program to always behave. Here's one from Netflix that will give you an ulcer: https://github.com/Netflix/chaosmonkey https://github.com/Netflix/chaosmonkey Here's what Google does: https://www.usenix.org/conference/lisa15/conference-program/presentation/krishnan https://www.usenix.org/conference/lisa15/conference-program/... >> we all get dumber for it Not _all_. Only those who feel inclined to reject the obvious.
- dastbe 7y agoTo me, this is focusing on minimizing the occurrence of failure scenarios rather than solutions for them. You should not only be asking yourself what you're ok with happening in failure scenarios, but also what happens when rare scenarios suddenly become not so rare. And you should be actively testing these decisions by failing often, to improve your confidence that when unplanned failure occurs your system will be resilient. That's not to say that you can't minimize rather than solve, as its (IMO) easier and faster to introduce minimizing mitigations rather than wholesale solutions to failure and, well, time is dimes. But the reality is that these are just short-term mitigations that you'll outgrow as you scale.
- closeparen 7y agoYou need to be resilient to all of these things to handle normal failures. So "hard shutdown" is just "free extra chaos test."