Instacart Kaushik Gopal

Instacart's Offline First: Introducing TrueTime for Swift and Android

Original post Offline First: Introducing TrueTime for Swift and Android

Article Summary

Instacart shoppers were losing minutes in grocery store dead zones. The culprit? You can't trust device clocks when every second counts.

Instacart open sourced TrueTime, an NTP library for Swift and Android that solves a deceptively tricky problem: getting accurate time on mobile devices. This is part one of their offline-first architecture series.

Key Takeaways

Critical Insight

When you're promising one-hour delivery, you need millisecond precision that survives spotty networks and user clock tampering.

Continue reading

What This Article Covers

Problem

Instacart's shopper app had trouble reliably timestamping critical order events. iOS and Android don't provide a way to get time that isn't affected by user timezone changes or clock drift, which can span several minutes.

Solution

Kaushik Gopal's team built TrueTime to solve this. It queries NTP servers once when the app starts, calculates the delta between device uptime and server response, then applies that offset to all subsequent time requests.

Impact

The open-source library lets Instacart guarantee millisecond-precision timestamps for one-hour delivery orders on both Android and iOS. The RxJava extension supports parallel UDP requests with automatic retry logic.

The real story is why Instacart needed this for their offline-first architecture (hint: batch processing comes next).

This page summarizes “Offline First: Introducing TrueTime for Swift and Android” by Instacart, published Sep 12, 2016. All credit for the original work goes to the authors.

Read the original on tech.instacart.com (opens in new tab)

AI tools for iOS

Browse all AI tools →