3 ms·
Yeah, that's why I'm not dogmatic about it. With network timeouts, external systems that you can't control, and low level hardware access, sometimes it's the be
by thraxil 11y ago
Yeah, that's why I'm not dogmatic about it. With network timeouts, external systems that you can't control, and low level hardware access, sometimes it's the best you can do. The better solution would be for the hardware/system you are interacting with to publish an event or otherwise signal when it is or isn't able to handle more load. If it wasn't designed with back pressure in mind though, you do the best you can, and in your case, exponential backoff is probably it.
Adding jitter to avoid dogpiling is another case where sleeping is perfectly reasonable.
What I get wary about is the common pattern of: Make a call to some external service. Sleep for some amount of time (to "let it finish"). Then continue under the assumption that it has completed.
- danieltillett 11y agoI think we are in massive agreement here. Sleep can be used as crutch inappropriately, but when you have a broken leg a crutch is exactly what you need.
- ericfrederich 11y agoAgree that we're in agreement ;-)