Now Reading
Easy Precision Time Protocol at Meta

Easy Precision Time Protocol at Meta

2024-02-07 23:36:54

  • Whereas deploying Precision Time Protocol (PTP) at Meta, we’ve developed a simplified model of the protocol (Easy Precision Time Protocol – SPTP), that may provide the identical degree of clock synchronization as unicast PTPv2 extra reliably and with fewer assets.
  • In our personal exams, SPTP boasts comparable efficiency to PTP, however with important enhancements in CPU, reminiscence, and community utilization.
  • We’ve made the supply code for the SPTP consumer and server obtainable on GitHub.

We’ve beforehand spoken in nice element about how Precision Time Protocol is being deployed at Meta, together with the protocol itself and Meta’s precision time structure.

As we deployed PTP into certainly one of our information facilities, we have been additionally evaluating and testing various PTP shoppers. In doing so, we quickly realized that we might remove loads of complexity within the PTP protocol itself that we skilled throughout information heart deployments whereas nonetheless sustaining full {hardware} compatibility with our present tools.

That is how the thought of Easy Precision Time Protocol (SPTP) was born. 

However earlier than we dive underneath the hood of SPTP we should always discover why the IEEE 1588 G8265.1 and G8275.2 unicast profiles (right here, we simply name them PTP) weren’t an ideal match for our information heart deployment.

PTP and its limitations

Extreme community communication

A typical IEEE 1588-2019 two-step PTPv2 unicast UDP movement consists of the next change:

Determine 1: Typical two-step PTPv2 change.

This sequence repeats both in full or partially relying on the negotiation end result. The change proven is certainly one of many doable mixtures. It might contain extra steps resembling grant cancellation, grand cancellation acknowledgements, and so forth.

The frequency of those messages could range relying on the implementation and configuration. After finishing negotiation, the frequency of some messages can change dynamically.

This design permits for lots of flexibility, particularly for much less highly effective tools the place assets are restricted. Together with multicast, it permits us to assist a comparatively giant variety of shoppers utilizing both very outdated or embedded gadgets. For instance, a PTP server can reject the request or affirm a much less frequent change if the assets are exhausted.

This design, nevertheless, results in extreme community communication, which is especially seen on a time appliance serving a lot of shoppers.

State machine

Because of the “subscription” mannequin, each the PTP consumer and the server need to hold the state in reminiscence. This strategy comes with the tradeoffs resembling:

  • Extreme utilization of assets resembling reminiscence and CPU.
  • Strict capability limits that imply multicast assist is required for giant numbers of shoppers.
  • Code complexity.
  • Fragile state transitions.

These points can manifest, for instance, in so-called deserted syncs – conditions the place the work of a PTP consumer is interrupted (both forcefully stopped or crashed). As a result of the PTP server didn’t obtain a cancellation signaling message it can hold sending sync and followup packets till the subscription expires (which can take hours). This results in extra complexity and fragility within the system. 

 There are extra protocol design uncomfortable side effects resembling:

  • An virtually infinite Denial of Service Assault (DoS) amplification issue.
  • Server-driven communication with little management by the consumer.
  • Full belief within the validity of server timestamps.
  • Asynchronous path delay calculations.

In information facilities, the place communication is usually pushed by a whole lot of 1000’s of shoppers and multicast will not be supported, these tradeoffs are very limiting. 


True to its identify, SPTP considerably reduces the variety of exchanges between a server and consumer, permitting for way more environment friendly community communication.


Determine 2: Typical SPTP change.

In a typical SPTP change:

  1. The consumer sends a delay request.
  2. The server responds with a sync.
  3. The server sends a followup/announce.

The variety of community exchanges is drastically lowered. As a substitute of 11 totally different community exchanges as proven on Determine 1 and the requirement for consumer and server state machines all through the subscription, there are solely three packets exchanged and no state must be preserved on both aspect. Within the simplified change, each packet has an essential position:

Delay request

A delay request initiates the SPTP change. It’s interpreted by a server not solely as a typical delay request containing the correction subject (CF1) of the clear clock, but additionally as a sign to reply with sync and followup packets. Identical to in a two-step PTPv2 change, it generates T3 upon departure from the consumer aspect and T4 upon arrival on the server aspect.

To differentiate between a PTPv2 delay request and a SPTP delay request, the PTP profile Particular 1 flag should be set by the consumer.


In response to a delay request, a sync packet can be despatched containing the T4 generated at an earlier stage. Identical to in an everyday two-step PTPv2 change, a sync packet will generate a T1 upon departure from the server aspect. Whereas in transit, the correction subject of the packet (CF2) is populated by the community tools.


Following the sync packet, an announce packet is instantly despatched containing T1 generated at a earlier stage. As well as, the correction filed from the Delay Request subject is populated by the CF1 worth collected at an earlier stage.  

The announce packet additionally comprises typical PTPv2 info resembling clock class, clock accuracy, and so forth. On the consumer aspect, the arrival of the packet generates the T2 timestamp.

After a profitable SPTP change, default two-step PTPv2 formulation for imply path delay and clock offset should be utilized:

mean_path_delay = ((T4 – T3) + (T2-T1) – CF1 -CF2)/2

clock_offset = T2 – T1 – mean_path_delay

After each change the consumer has entry to the announce message attributes resembling time supply, clock high quality, and many others., in addition to the trail delay and a calculated clock offset after each change with each server. And, as a result of the change is client-driven, the offsets may very well be calculated at the very same time. This avoids a state of affairs the place a consumer is following a defective server and has no probability of detecting it.

Determine 3: Consumer following defective Time Server 2 based mostly on announce.


We are able to additionally present stronger reliability ensures through the use of multi-clock reliance.

In our implementation for precision time synchronization, we offer time in addition to a window of uncertainty (WOU) to the buyer software through the fbclock API. As we described in a earlier weblog submit on how PTP is being deployed at Meta the WOU is predicated on the statement of time sync errors for the minimal period to have stationarity of the state of the system. 

As well as, we’ve established a technique based mostly on a set of clocks that every consumer can entry for timing info that we name a clock ensemble. The clock ensemble operates in two modes, regular state and transient; the place regular state is throughout regular operation and transient is within the case of holdover.

Nonetheless, with a pool of N clocks, C, forming the clock ensemble, the query turns into which clocks to pick for figuring out robustness and correct timing info. Clocks that aren’t correct are rejected (C_reject) and, thus, our ensemble measurement falls to N = C_total –  C_reject. We make use of two phases, one that’s based mostly on every particular person clock, and the second that acts on the gathering of legitimate clocks within the ensemble. 

The primary stage observes the earlier measurements of every particular person clock, the place the primary standards is to reject outliers within the earlier states of the clock. As soon as this criterion threshold is exceeded, your complete clock is rejected from the legitimate clock ensemble pool. That is based mostly off Chauvenet’s criterion, the place the criterion is a likelihood band that’s centered on the imply of the clock outputs (assuming a standard distribution throughout regular state). Primarily based on the stationarity exams, we use a pattern measurement of 400 earlier clock outputs and calculate a most allowable deviation. 

For instance:

, the place is the present clock output,  is the clock pattern imply, and is the clock set commonplace deviation.

We discover the likelihood that the present clock output is in disagreement with the earlier 400 samples:

Primarily based on a window measurement of 400 earlier samples, the utmost allowed deviation is:

Now, the clock outputs are examined towards this worth. In the event that they exceed the  they’re rejected, an alert is raised, and a threshold counter is incremented. As soon as the rejection threshold is reached for a person clock, this clock is fully rejected.

Now, we enter the second stage of verifying the clock ensemble composed of the legitimate clocks. The second stage kinds a weighted common of the non-rejected clocks within the legitimate clock ensemble, the place every clock within the ensemble is reported as its pattern measurement, imply, and variance. The common of the clocks’ means is the weighted common, the place the weights are inversely proportional to the imply absolute deviations reported by every clock after making use of Chauvenet’s criterion. 

Now we are able to report the imply and variance of the clock ensemble, guaranteeing the clocks contained therewith are legitimate and never offering misguided values. The arrogance interval is scaled with the variety of good clocks within the ensemble, the place the upper the variety of legitimate clocks out of the overall clocks gives better reliability.

For quite a few hosts, we present that the distribution of clocks falls inside the following heatmap:

Determine 4: Offset distribution overlay of a number of clocks.

We calculate the variance, , of every particular person clock’s observations, then we calculate a weighted imply, , taking into account the reciprocal of every clock’s variance as the burden.

See Also

Resulting from independence of clocks, the variance of the weighted sum, , is:

In abstract, we accumulate samples from quite a few clock sources that type our clock ensemble. The general precision and reliability of the supplied information by SPTP is a operate of the variety of dependable and in distribution clocks forming the clock ensemble.

A future submit will give attention to this particularly. 

SPTP’s efficiency

Let’s discover efficiency of the SPTP versus PTP.

Preliminary deployments to a single consumer confirmed no regression within the precision of the synchronization:

Determine 5: Clock offset after switching from ptp4l and SPTP.

Repeating the identical measurement after migration to SPTP produces a really related end result, solely marginally totally different as a result of a statistical error:

Determine 6: P99.99 offset collected from over 100000 SPTP shoppers.

With large-scale deployment of our implementations, we are able to affirm useful resource utilization enhancements.

We observed that because of the distinction in multi-server assist, the efficiency good points range considerably relying on the variety of tracked time servers.

For instance, with only a single time equipment serving your complete community there are important enhancements throughout the board. Most notably over 40 p.c CPU, 70 p.c reminiscence, and 50 p.c community utilization enhancements:

Determine 7: Packets per second with ptp4l (inexperienced) vs SPTP (blue).

The following steps for SPTP at Meta

Since SPTP can provide the very same degree of synchronization with quite a bit fewer assets consumed, we predict it’s an affordable various to the present unicast PTP profiles.

In a large-scale information heart deployment, it will probably assist to fight continuously altering community paths and create financial savings when it comes to community site visitors, reminiscence utilization, and variety of CPU cycles.

It is going to additionally remove loads of complexity inherited from multicast PTP profiles, which isn’t essentially helpful within the trusted networks of the trendy information facilities.

It needs to be famous that SPTP is probably not appropriate for programs that also require subscription and authentication. However this may very well be solved through the use of PTP TLVs (type-length-value). 

Moreover, by eradicating the necessity for subscriptions, it’s doable to look at a number of clocks – which permits us to supply larger reliability by evaluating the time sync from a number of sources on the finish node.

SPTP can provide considerably less complicated, quicker, and extra dependable synchronization. Much like G.8265.1 and G.8275.2 it gives wonderful synchronization high quality utilizing a distinct set of parameters. Simplification comes with sure tradeoffs, resembling lacking signaling messages, that customers want to concentrate on and resolve which profile is the perfect for them.

Having it standardized and assigned a unicast profile identifier will encourage wider assist, adoption, and popularization of PTP as a default exact time synchronization protocol.

The supply code for the SPTP consumer and the server could be accessed on our GitHub page.


We wish to thank Alexander Bulimov, Vadim Fedorenko, and Mike Lambeta for his or her assist implementing the code and the maths for this text.

Source Link

What's Your Reaction?
In Love
Not Sure
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top