Remix.run Logo
▲ dylan604 6 hours ago

Sounds like they've been set up as cron tasks. I've always been unhappy with the 1 minute granularity of cron tasks. Only thing I could come up with was putting a sleep(random()) type of line to avoid a thundering herd type of issue.

▲compumike 5 hours ago | parent | next [-]

Yes it’s a real effect. I’ve just hardcoded offsets on various jobs:

  * * * * * sleep 17 && …
etc.

That way I still maintain a per-job 60-second cadence consistently (which random would not), but don’t do it right on the top of the minute.

▲dylan604 5 hours ago | parent | next [-]

That's interesting as it is also visible with a crontab -l so that new scripts can avoid using the same second. However, if you have a farm of machines with the same hardcoded value, they will all still stampede at the same time just not at the top of the minute. By allowing a random value, their start times are slightly offset with in the minute. Is the precise 60s consistent interval really that critical or just that each machine checks once per minute-ish?

▲Magniquick 5 hours ago | parent | prev [-]

Systemd timers do this natively btw, no need to hardcode And imho are also friendlier.

▲Cyph0n 5 hours ago | parent | next [-]

But systemd bad :[

▲falserum an hour ago | parent [-]

People slowly are getting used to it. (Less so with journalctl)

▲stonogo 5 hours ago | parent | prev [-]

BSD cron has supported jitter for decades. This is strictly a linux problem.

▲nlehuen 4 hours ago | parent | prev [-]

The Google internal equivalent to cron has a ? placeholder in the scheduling spec syntax letting the scheduler deterministically pick an arbitrary valid value within the field range. So ? 2 ... will pick any minute between 02:00 and 02:59 (and I suspect any second within that minute). The value is derived from a hash of the job definition, so overall this spreads the cron load within the hour.

Obviously cron jobs are not all equal in terms of load and duration, and hours are not all equal in terms of usage, but that still helps prevent trivial spikes similar to the one mentioned in the article (disclaimer: I'm not aware of a recent counterfactual experiment proving this, but that seems a fair assumption).

▲sdenton4 4 hours ago | parent [-]

I suppose one would end up with checks happening on a random second instead of a random minute - reducing the size of the spike by a factor of 60, but still spiky.