Consistent caching mechanism in Titus Gateway

Netflix Technology Blog
15 min readadvanced
--
View Original

Overview

The article discusses the implementation of a consistent caching mechanism in the Titus Gateway, which is part of Netflix's cloud container runtime. It highlights how this mechanism allows for horizontal scaling while maintaining strict data consistency, addressing the challenges posed by increased API call volumes.

What You'll Learn

1

How to implement a caching mechanism that maintains data consistency in distributed systems

2

Why horizontal scaling can improve API performance under high load conditions

3

How to synchronize caches with a leader elected process to ensure up-to-date data

Prerequisites & Requirements

  • Understanding of caching mechanisms and distributed systems
  • Experience with API design and implementation(optional)

Key Questions Answered

How does the caching mechanism in Titus Gateway ensure data consistency?
The caching mechanism in Titus Gateway ensures data consistency by synchronizing with the Titus Job Coordinator, which maintains the latest state of the system. This synchronization occurs through a keep-alive protocol that guarantees clients receive the most recent data version, even during leader failovers.
What are the performance benefits of using a caching mechanism in Titus?
The performance benefits of using a caching mechanism in Titus include improved tail latencies and the ability to handle higher request volumes without overwhelming the system. The article notes that while median latencies may increase slightly, the 99th percentile latencies drop significantly, demonstrating better scalability.
What challenges does Titus face with increased API call volumes?
As the number of API calls increases, the original architecture of Titus, which relied on a single leader node, became overloaded, leading to increased response latencies and high utilization. The new caching mechanism addresses these challenges by distributing the load across multiple gateway nodes.
How does Titus handle leader failovers in the caching mechanism?
During leader failovers, Titus rejects all reads and writes of the active data until a connection to the new leader is re-established. This ensures that clients do not receive stale data, maintaining data consistency throughout the transition.

Key Statistics & Figures

99th percentile latency without caching
292 milliseconds
This latency drops to 30 milliseconds with the caching mechanism enabled.
Maximum load before system collapse without caching
4.5K queries/second
The system with caching enabled scales linearly, handling up to 8K queries/second without increased latencies.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Backend
Titus
Cloud container runtime for managing and running containers at scale.
Programming Language
Java
Used for implementing high-resolution monotonic time sources within the caching mechanism.

Key Actionable Insights

1
Implement a caching mechanism that synchronizes with a leader elected process to maintain data consistency across distributed systems.
This approach is crucial for applications that require real-time data accuracy, especially in high-load scenarios where traditional methods may fail.
2
Utilize a keep-alive protocol to ensure that caches are updated in a timely manner, preventing stale data issues.
This is particularly important for systems that rely on immediate data availability, such as job orchestration platforms.
3
Consider horizontal scaling of API gateways to distribute load and improve performance under high traffic conditions.
This strategy allows for better resource utilization and can significantly reduce response times during peak usage.

Common Pitfalls

1
Failing to synchronize caches properly can lead to clients receiving stale data, which can cause inconsistencies in application behavior.
This issue often arises in distributed systems where multiple nodes operate independently. Implementing a robust synchronization protocol is essential to avoid this problem.

Related Concepts

Caching Mechanisms
Distributed Systems
API Design
Leader Election Protocols