---
title: "How Precision Time Protocol handles leap seconds"
description: "Meta handles leap seconds for its nanosecond-precision PTP service by self-smearing inside the fbclock library, which shifts its returned Window of Uncertainty {earliest_ns, latest_ns} by 1 ns every 62.5 µs."
url: "https://swe.quest/articles/how-precision-time-protocol-handles-leap-seconds-7f6fcf3729d9faf4"
canonical: "https://engineering.fb.com/2025/02/03/production-engineering/how-precision-time-protocol-ptp-handles-leap-seconds/"
source: "Meta Engineering"
published: "2025-02-03"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 3
tags: ["time-clocks","datacenters","distributed-systems"]
---

# How Precision Time Protocol handles leap seconds

A post on [Meta Engineering](https://swe.quest/sources/meta.md), published 2025-02-03, 3 min read, Deep dive. Original: [https://engineering.fb.com/2025/02/03/production-engineering/how-precision-time-protocol-ptp-handles-leap-seconds/](https://engineering.fb.com/2025/02/03/production-engineering/how-precision-time-protocol-ptp-handles-leap-seconds/)

## Summary

Meta handles leap seconds for its nanosecond-precision PTP service by self-smearing inside the fbclock library, which shifts its returned Window of Uncertainty {earliest\_ns, latest\_ns} by 1 ns every 62.5 µs. The approach is stateless and reproducible, since the start time comes from tzdata, so a rebooted server can recompute its position. The service keeps TAI internally and returns UTC through the API. The costs are that linear PTP smearing and quadratic NTP smearing can disagree by over 100 µs, hosts still drift apart during the smear, and precisely scheduled jobs end up nearly 1 ms off after 60 seconds. Meta therefore recommends that clients use TAI where possible and supports freezing new leap seconds after 2035.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Time & clocks](https://swe.quest/tags/time-clocks.md) (Distributed systems)
- [Datacenters](https://swe.quest/tags/datacenters.md) (Infrastructure)
- [Distributed systems](https://swe.quest/tags/distributed-systems.md) (Distributed systems)

## Prerequisites

- NTP basics ([easy posts on Time & clocks](https://swe.quest/tags/time-clocks.md?difficulty=easy))
- UTC vs TAI
- leap seconds

## Keywords

Precision Time Protocol, NTP, fbclock, leap second smearing, TAI, UTC

## Related posts

- [It’s time to leave the leap second in the past](https://swe.quest/articles/it-s-time-to-leave-the-leap-second-in-the-past-9e11ae3896edcf86.md): Meta Engineering · 2022-07-25 · Medium · 6 min read · Time & clocks, Distributed systems, Resilience
  Leap seconds do more harm than good for modern computing, and Meta backs an industry push to freeze them at the current 27.
- [PTP: Timing accuracy and precision for the future of computing](https://swe.quest/articles/ptp-timing-accuracy-and-precision-for-the-future-of-computing-7cb5bf24683b59a5.md): Meta Engineering · 2022-11-21 · Easy · 8 min read · Time & clocks, Datacenters, Networking, Open source
  Meta is rolling out Precision Time Protocol (PTP) across its data centers to replace NTP, moving clock synchronization precision from milliseconds to nanoseconds.
- [How Precision Time Protocol is being deployed at Meta](https://swe.quest/articles/how-precision-time-protocol-is-being-deployed-at-meta-6d56b79aabe69525.md): Meta Engineering · 2022-11-21 · Hard · 27 min read · Time & clocks, Networking, Datacenters, Hardware, Consistency models
  Meta replaced NTP with Precision Time Protocol across its data centers to get nanosecond-level clock sync.
- [Simple Precision Time Protocol at Meta](https://swe.quest/articles/simple-precision-time-protocol-at-meta-1f4dfeb134554941.md): Meta Engineering · 2024-02-07 · Hard · 9 min read · Time & clocks, Networking, Datacenters, Performance engineering
  Simple Precision Time Protocol (SPTP) replaces the subscription-based unicast PTPv2 exchange with a stateless, client-driven three-packet exchange: a delay request (flagged with PTP profile Specific 1), a sync carrying T4, and a followup/announce carrying T1 and CF1.
- [Open-sourcing a more precise time appliance](https://swe.quest/articles/open-sourcing-a-more-precise-time-appliance-d4216f5f1f5059e9.md): Meta Engineering · 2021-08-11 · Hard · 12 min read · Time & clocks, Hardware, Networking, Open source, Linux
  Meta built and open-sourced the Time Card, a PCIe card combining a multiband GNSS receiver, a miniaturized atomic clock and an FPGA time engine that turns a commodity x86 server with a hardware-timestamping NIC into an NTP/PTP Stratum 1 time appliance.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
