Chat with us, powered by LiveChat
INDIA +91 964 309 2571 | USA +1669 327 4700

YES, it’s true!!! When we all are busy in a party of the new year, Science gifted us “a second” to live more in 2016. 2017 was started a little bit late than usual. And this is not the first time, this is 27th time when we shifted “our clock” a second late since 1970. So, let’s catch what actually happened on 31-Dec-216 23:59:60.

Leap Second

Earth moves around the sun in an elliptical way and its speed during this path is not constant. When the earth is nearer to the sun, its speed increases and when it moves far its speed decreases. From this, two definitions are given, Sidereal Day and Solar day
Sidereal day: A time is taken by a planet to complete a trip around its axis in a context of the ‘fixed’ star.
Solar day: A time is taken by the earth to complete a trip around its axis in the context of the sun. (Average 24 hours which called Mean Solar day)
More info:
Based on solar day sundial clocks are invented. But eventually, we gave up and invented digital and mechanical clocks which have fixed 86400 seconds and here we made a mistake.
A speed of the earth (on its axis as well as around the sun) varies time by time (Since 1820, the mean solar day has increased by about 2.5 milliseconds-NASA) and for that, an organization named IERS helped us.

IERS provides data, publications and general information on the Earth`s orientation, which helped us to identify when to increase or decrease more seconds, called “leap-second” in the calendar, to sync “our clock” with “solar clock”.

So, actually 31-Dec-2016 23:59:60 is a patch to correct our clock error. We added a leap second generally at the end of last minute of 30-Jun or 31-Dec as per UTC time And other timezones add according to their time. So, in India(GMT+05:30), we added a second at 01-01-2017 05:30:60.

Why should I know all this?

Because time is money!!!
In 1998, the leap second was added and after that next was added in 2005. So in between whichever servers were developed, very few servers took care for the leap second. The same thing happens in 2012 too. And for that Google, Amazon, Reddit, CDMA users and many other giants have to pay for the same due to time many of slow down or crash of their servers.

What actually happens?

There is a system called Hrtimer (High-resolution timer) in every Linux kernel.
Hrtimer is a subsystem that is used when an application is “sleeping,” waiting for the OS to complete some other task. In some cases, it sets a kind of alarm clock for these sleeping applications that will go off when the OS is taking too much time with its other work. When the leap second hit and these hrtimers were suddenly a second ahead of the core OS, they started ringing those alarm clocks, waking up countless sleeping applications at once and overloading the machines’ CPUs. And the result is slow down or crash.

How to handle it?

David Mills designed a protocol called, NTP(Network Time Protocol), which is used in application layer for clock synchronization. There are 3-4 techniques to handle leap second.
1) Notify kernel to step back the clock
2016-12-31 23:59:59:052549000 UTC <– 1st occurrence of the 60th second
2016-12-31 23:59:59:259988000 UTC
2016-12-31 23:59:59:465214000 UTC
2016-12-31 23:59:59:669629000 UTC
2016-12-31 23:59:59:873936000 UTC
2016-12-31 23:59:59:079184000 UTC <– 2nd occurrence of the 60th second
2016-12-31 23:59:59:284011000 UTC
2016-12-31 23:59:59:488648000 UTC
2016-12-31 23:59:59:692691000 UTC
2016-12-31 23:59:59:896577000 UTC
2017-01-01 00:00:00:052378000 UTC

2) Add daemon to step back kernel
It works same as above transition, but instead of kernel notification, the daemon will perform the task.

3) Ignore it
The clock will continue with the incorrect time until it is addressed through normal operation. If multiple systems are configured with this method it is possible that their times will drift apart from each other, as the correction process is random to a certain extent. This method is not recommended for systems that require in-sync communication.

The better option is
Instead of directly increase or decrease the second, add it over a period of time. To accommodate the extra second is to run all its internal server clocks infinitesimally slower over a 20-hour window. Instead of bolting on an extra second to clocks at the end of the day, a tactic has been to “smear” away the extra second by slowing down system clocks. Google slows its clock by 0.0014 percent or 14 parts per million during this time period.

Articles from some server hosting services

And as always thanks for reading!!!