Companies/Twitter/

Daperture — Twitter Load Balancer

Lesson overview

Daperture — Twitter Load Balancer

How Twitter built Daperture (Deterministic Aperture) — an internal load-balancing algorithm combining deterministic server subsets with Power of Two Choices to distribute traffic at scale.

Daperture - Twitter Load Balancer

10k request/sec

50k request/sec

70k request/sec

Load Balancer

A load balancer is a system that receives traffic from clients and distributes that traffic across multiple backend servers.

Its goals are usually: Prevent one server from receiving all traffic. Improve availability when a server fails. Allow servers to be added or removed. Provide one stable address to clients.

Timeline Service

Tweet Service

C1 - S1 , S2 , S3 , S4 C2 - S1 , S2 , S3 , S4 C3 - S1 , S2 , S3 , S4

1. Full mesh

C1 - S1 , S2 C2 - S1 , S2 , S3 , S4 C3 - S1 , S3 , S4

2. Random Subset

Requirements 1. Fewer Connections 2. Balanced Traffic 3. Handle Server Failure 4. Handle machines being added or removed 5. No Central Load Balancer

Twitter created Deterministic Aperture, also called Daperture.

what is Daperture?

Daperture is an internal load-balancing algorithm used by Twitter.

It helps one Twitter service communicate with another Twitter service.

Internal Load Balancing

Main Idea 1. Give every client a small but carefully selected group of servers. 2. The group is not selected randomly. 3. It is selected using a deterministic ring.

Daperture = Deterministic server subset + Power of Two Choices

S1 S2 S3 S4 S5 S6 S7 S8

Building the deterministic aperture

S1 share = 3/7

Loading Daperture — Twitter Load Balancer