TIL: Leap Seconds: The One-Second Fix That Broke the Internet
5 min read
Time feels mechanical. Seconds tick. Minutes roll. Days advance. But that neat structure is an approximation—a compromise between two systems that measure time differently and refuse to agree.
Atomic time vs. Earth time
Modern timekeeping relies on atomic clocks. These measure time using the oscillation of cesium atoms—9,192,631,770 cycles per second, to be exact. The precision is staggering: stable to within a billionth of a second per day.
Earth’s rotation is not nearly so reliable. Our planet speeds up and slows down due to tidal friction from the Moon, the redistribution of mass from melting ice, seismic activity, and even atmospheric pressure changes. The difference between atomic time and Earth’s rotation is tiny at first. Milliseconds. But it accumulates.
Why leap seconds exist
When the gap between atomic time (UTC) and astronomical time (UT1) approaches 0.9 seconds, timekeepers intervene. They add a leap second. At the end of a chosen day—usually June 30 or December 31—time does something impossible:
23:59:59
23:59:60
00:00:00
That’s a real timestamp. Sixty seconds in a minute. Since 1972, this has happened 27 times.
Leap seconds vs. leap years
These two fixes solve different problems, and software handles them very differently.
Leap years correct for Earth’s orbit around the Sun. A year is actually about 365.2422 days, so we add a day every four years. This is predictable, well-understood, and rarely breaks anything.
Leap seconds correct for Earth’s rotation speed. They’re announced only six months in advance by the International Earth Rotation and Reference Systems Service. They cannot be predicted years ahead. Software often assumes they don’t exist.
Leap years adjust calendars. Leap seconds adjust clocks. That distinction matters enormously when your code expects time to flow forward in a smooth, unbroken line.
Why leap seconds break systems
Most software makes a simple assumption: time never repeats, never skips, never has 61 seconds in a minute. Leap seconds violate all of these.
The problems cascade. Timestamps become ambiguous—did 23:59:60 happen before or after 00:00:00? Databases that rely on monotonic time ordering suddenly have entries that appear to go backward. Systems waiting for a specific time might wait forever for 23:59:60 to arrive, since most clocks skip straight from :59 to :00. Distributed systems comparing timestamps across machines might conclude that events happened in impossible orders.
The fundamental issue isn’t the second itself. It’s the assumption, baked into countless systems, that time never repeats.
When leap seconds crashed the web
Leap seconds have caused real outages, and the casualties read like a who’s-who of the internet.
2012: A leap second on June 30 triggered a bug in the Linux kernel’s timekeeping code. Reddit went down. Mozilla went down. Foursquare, Yelp, LinkedIn, and Gawker all experienced outages. Qantas grounded flights for hours when its check-in system failed. The culprit was a race condition that caused CPUs to spike to 100% utilization, and it lurked undetected until the leap second exposed it.
2015: Financial markets preemptively shut down trading to avoid leap second chaos. Some systems failed anyway.
2017: Cloudflare’s DNS service experienced widespread failures. The company later published a detailed postmortem explaining how a leap second caused their time calculations to briefly produce negative numbers.
2012 (Oracle): The Solaris operating system developed by Sun Microsystems caused Oracle database servers to spontaneously reboot at midnight on New Year’s Day—traced back to a leap second bug from three years earlier.
How companies cope
Different organizations have adopted different strategies, none of them elegant.
Ignore Earth entirely. GPS time, used by navigation satellites, runs on pure atomic time and has drifted 18 seconds away from UTC since 1980. Some internal systems follow this approach, accepting that their clocks will slowly diverge from civil time.
Smear the second. Instead of inserting one second instantaneously, Google and AWS spread the extra time across hours. Clocks run imperceptibly slower for part of the day. No discontinuity, no repeated timestamp. But now different systems disagree about what time it is during the smear window.
Freeze time. Some systems stop their clocks for one second. This avoids the impossible timestamp but creates its own problems for anything that depends on time advancing.
Hope nothing breaks. Many systems simply rely on the operating system to handle it, with varying results.
The coming abolition
In November 2022, the General Conference on Weights and Measures voted to abolish leap seconds starting in 2035. The vote wasn’t close—the United States, France, Australia, and most other nations supported it. Russia, whose GLONASS satellite system was designed around leap seconds, voted against.
The plan isn’t to let atomic time drift forever from Earth’s rotation. Instead, the allowed gap will increase from 0.9 seconds to something larger—possibly a full minute, which would take 50 to 100 years to accumulate. A century from now, timekeepers will apply a larger correction, perhaps by making one minute last two minutes in a gradual “smear.”
This favors computers over astronomers. For most applications, a minute of drift is invisible. For telescopes that need to point at specific celestial coordinates, the correction will require adjustment. The tradeoff was deemed worthwhile.
The threat of negative leap seconds
Here’s a wrinkle that keeps engineers awake at night: Earth has recently been spinning faster than expected. June 29, 2022 was the shortest day ever recorded—1.59 milliseconds shorter than a standard day. If this trend continues, the next leap second might be negative—removing a second rather than adding one.
No one knows what would happen. Positive leap seconds have caused outages, but at least they’ve been tested in production (the hard way). A negative leap second—time skipping from 23:59:58 directly to 00:00:00—has never occurred. The assumption that time always moves forward is even more deeply embedded than the assumption that minutes have 60 seconds.
The 2035 abolition may spare us from finding out.
The uncomfortable truth
Time is not as clean as our software wants it to be.
Leap years remind us that calendars are approximations. Leap seconds remind us that clocks are, too. A single extra second—one out of 31,536,000 in a year—exposed how fragile our assumptions about time really are.
The universe doesn’t care about your timestamp format. Your code has to.