Top Banner
EXPLORATIONS IN COOPERATIVE DISTRIBUTED SYSTEMS WITH UBER’S RINGPOP
51

Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

Apr 16, 2017

Download

Technology

Codemotion
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

EXPLORATIONS IN COOPERATIVE DISTRIBUTED SYSTEMSWITH UBER’S RINGPOP

Page 2: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

WHAT IS RINGPOP?HIGH-LEVEL FACTS

It is a library written in Node.js and Go.

It is...

“...scalable, fault-tolerant application layer sharding.”

"...a library that brings cooperation and coordination to distributed applications.”

“...a hash ring.”

It is open source.

Page 3: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

BUT WHAT IS UBER?REALTIME DISPATCH ENGINEERING

Mobile API, match-maker, trip orchestrator

Platform for marketplaces

Highly interactive, real-time

Data locality

Long-running transactions

Page 4: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

NG

INX

HA

PR

OX

Y

NO

DE

.JS

TWE

MP

RO

XY

RE

DIS

NG

INX

HA

PR

OX

Y

NO

DE

.JS

TWE

MP

RO

XY

RE

DIS

NO

DE

.JS

NO

DE

.JS

RE

DIS

NO

DE

.JS

NO

DE

.JS

NO

DE

.JS

NO

DE

.JS

RE

DIS

NO

DE

.JS

NO

DE

.JS

ROUTING LAYER DISPATCH LAYER

LON

DO

NN

EW

YO

RK

ORIGINAL DISPATCH ARCHITECTUREUBER REAL-TIME DISPATCHING

0 1 2 3

Page 5: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

NG

INX

HA

PR

OX

Y

NO

DE

.JS

TWE

MP

RO

XY

RE

DIS

NG

INX

HA

PR

OX

Y

NO

DE

.JS

TWE

MP

RO

XY

RE

DIS

NO

DE

.JS

NO

DE

.JS

RE

DIS

NO

DE

.JS

NO

DE

.JS

NO

DE

.JS

NO

DE

.JS

RE

DIS

NO

DE

.JS

NO

DE

.JS

ROUTING LAYER

ORIGINAL DISPATCH ARCHITECTUREUBER REAL-TIME DISPATCHING

0 1 2 3

DISPATCH LAYER

LON

DO

NN

EW

YO

RK

Page 6: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

NG

INX

HA

PR

OX

Y

NO

DE

.JS

TWE

MP

RO

XY

RE

DIS

NG

INX

HA

PR

OX

Y

NO

DE

.JS

TWE

MP

RO

XY

RE

DIS

NO

DE

.JS

NO

DE

.JS

RE

DIS

NO

DE

.JS

NO

DE

.JS

NO

DE

.JS

NO

DE

.JS

RE

DIS

NO

DE

.JS

NO

DE

.JS

ROUTING LAYER

ORIGINAL DISPATCH ARCHITECTUREUBER REAL-TIME DISPATCHING

0 1 2 3

DISPATCH LAYER

LON

DO

NN

EW

YO

RK

Page 7: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

NG

INX

HA

PR

OX

Y

NO

DE

.JS

TWE

MP

RO

XY

RE

DIS

NG

INX

HA

PR

OX

Y

NO

DE

.JS

TWE

MP

RO

XY

RE

DIS

NO

DE

.JS

NO

DE

.JS

RE

DIS

NO

DE

.JS

NO

DE

.JS

NO

DE

.JS

NO

DE

.JS

RE

DIS

NO

DE

.JS

NO

DE

.JS

ROUTING LAYER DISPATCH LAYER

LON

DO

NN

EW

YO

RK

ORIGINAL DISPATCH ARCHITECTUREUBER REAL-TIME DISPATCHING

0 1 2 3

Page 8: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

NG

INX

HA

PR

OX

Y

NO

DE

.JS

TWE

MP

RO

XY

RE

DIS

NG

INX

HA

PR

OX

Y

NO

DE

.JS

TWE

MP

RO

XY

RE

DIS

NO

DE

.JS

NO

DE

.JS

RE

DIS

NO

DE

.JS

NO

DE

.JS

NO

DE

.JS

NO

DE

.JS

RE

DIS

NO

DE

.JS

NO

DE

.JS

ROUTING LAYER DISPATCH LAYER

LON

DO

NN

EW

YO

RK

ORIGINAL DISPATCH ARCHITECTUREUBER REAL-TIME DISPATCHING

0 1 2 3

Page 9: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

EVOLUTION OF THINKING AT UBERUBER REAL-TIME DISPATCHING

Scaling our organization, product and

systems

100x scale

Availabilityover

consistency Self-healing

No “master” No monolith

Flexibility and safety

Page 10: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

ENTER RINGPOPMEMBERSHIP PROTOCOL, CONSISTENT HASHING, REQUEST ROUTING

Page 11: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

INST. A INST. B INST. C

DATABASE DATABASE

DISCRETE APPLICATION INSTANCESENTER RINGPOP: MEMBERSHIP PROTOCOL

FE1 FE2 FE3 FE4 FE5FRONT-END

APPLICATION

STORAGE

Page 12: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

COOPERATIVE APPLICATION INSTANCESENTER RINGPOP: MEMBERSHIP PROTOCOL

INST. A

INST. B

INST. C

DATABASE DATABASE

FE1 FE2 FE3 FE4 FE5FRONT-END

APPLICATION

STORAGE

Page 13: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

MEMBERSHIP PROTOCOLRINGPOP

Page 14: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

SWIM GOSSIP PROTOCOLENTER RINGPOP: MEMBERSHIP PROTOCOL

PINGINST. A INST. B

INST. AINST. BINST. C

INST. AINST. BINST. C

INST. CINST. AINST. BINST. C

PING PING

Membership list

Page 15: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

ENTER RINGPOP: MEMBERSHIP PROTOCOL

PINGINST. A INST. B

INST. AINST. BINST. C

INST. AINST. BINST. C

INST. CINST. AINST. BINST. C

FAILURE DETECTION

Page 16: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

ENTER RINGPOP: MEMBERSHIP PROTOCOL

INST. A INST. BINST. AINST. BINST. C

INST. AINST. BINST. C

INST. CINST. AINST. BINST. C

PING-REQ PING

AN INDIRECT PING

Page 17: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

ENTER RINGPOP: MEMBERSHIP PROTOCOL

INST. A INST. BINST. AINST. BINST. C

INST. AINST. BINST. C

INST. CINST. AINST. BINST. C

PING-REQ

DECLARE INST. B SUSPECT

Page 18: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

ENTER RINGPOP: MEMBERSHIP PROTOCOL

INST. A INST. BINST. AINST. BINST. C

INST. AINST. BINST. C

INST. CINST. AINST. BINST. C

PING

INST. B

PIGGYBACK MEMBERSHIP UPDATES

Page 19: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

ENTER RINGPOP: MEMBERSHIP PROTOCOL

INST. A INST. BINST. AINST. BINST. C

INST. AINST. BINST. C

INST. CINST. AINST. BINST. C

PING

INST. B

INFECTION-STYLE DISSEMINATION

Page 20: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

ENTER RINGPOP: MEMBERSHIP PROTOCOL

INST. A INST. BINST. AINST. BINST. C

INST. AINST. BINST. C

INST. CINST. AINST. BINST. C

PING

DETECTING A FAILURE

Page 21: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

CREATING A CLUSTERENTER RINGPOP: MEMBERSHIP PROTOCOL

INST. AINST. A

INST. C

INST. B

SENDS JOIN

SENDS JOIN

Page 22: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

INST. B STARTS UPENTER RINGPOP: MEMBERSHIP PROTOCOL

INST. AINST. A

INST. C

SENDS JOIN

SENDS JOININST. B INST. B

Page 23: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

PIGGYBACK MEMBERSHIP ON JOINENTER RINGPOP: MEMBERSHIP PROTOCOL

INST. AINST. A

INST. C

INST. B INST. B

SENDS JOIN

RESPONDS TO JOIN

INST. B

Page 24: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

“A” APPLIES UPDATE FROM “B”ENTER RINGPOP: MEMBERSHIP PROTOCOL

INST. AINST. A

INST. C

INST. B INST. BINST. B

SENDS JOIN

RESPONDS TO JOIN

INST. B

Page 25: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

“A” PIGGYBACKS UPDATEENTER RINGPOP: MEMBERSHIP PROTOCOL

INST. AINST. A

INST. C

INST. B INST. BINST. B

SENDS JOIN

SENDS PING

INST. A

Page 26: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

“B” APPLIES “A” UPDATEENTER RINGPOP: MEMBERSHIP PROTOCOL

INST. AINST. A

INST. C

INST. B INST. BINST. B

SENDS JOIN

SENDS PING

INST. A

INST. A

Page 27: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

CONSISTENT HASHINGRINGPOP

Page 28: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

ENTER RINGPOP: CONSISTENT HASHING

START WITH A KEYSPACE AND A RING

232-1

Page 29: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

ENTER RINGPOP: CONSISTENT HASHING

hash(“INST. A”);

hash(“INST. B”);

hash(“INST. C”);

HASH APPLICATION INSTANCES

Page 30: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

ENTER RINGPOP: CONSISTENT HASHING

INST. B

INST. C

DIVIDE UP THE KEYSPACE

INST. A

Page 31: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

ENTER RINGPOP: CONSISTENT HASHING

ASSIGN OWNERSHIP “USER1”

hash(“USER1”);

INST. A

INST. B

INST. C

Page 32: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

ENTER RINGPOP: CONSISTENT HASHING

ASSIGN OWNERSHIP “USER5”

hash(“USER5”);

INST. B

INST. C

INST. A

Page 33: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

ENTER RINGPOP: CONSISTENT HASHING

INST. A

INST. B

INST. C

ASSIGN OWNERSHIP “USER8”, “USER4”

hash(“USER4”);

hash(“USER8”);

Page 34: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

ENTER RINGPOP: CONSISTENT HASHING

LOSING CAPACITY

hash(“USER1”);

hash(“USER5”);

hash(“USER4”);

hash(“USER8”);

INST. A

INST. B

INST. C

Page 35: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

ADDING CAPACITYENTER RINGPOP: CONSISTENT HASHING

INST. D

INST. A

INST. B

INST. C

hash(“USER1”);

hash(“USER5”);

hash(“USER4”);

hash(“USER8”);

Page 36: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

APPLICATION LAYER MIDDLEWAREENTER RINGPOP: REQUEST ROUTING

HTTP / THRIFT / ETC

ROUTING

HASH RING

BUSINESS LOGIC

MEMBERSHIP

INST. A

{RINGPOP } PROCESSAPPLICATION

FRONT-END

STORAGE

Page 37: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

PROGRAMMING RINGPOPINSTANTIATE, BOOTSTRAP, LOOKUP

Page 38: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

A TYPICAL WEB APPPROGRAMMING RINGPOP

Page 39: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

INSTANTIATING RINGPOPPROGRAMMING RINGPOP

Page 40: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

BOOTSTRAPPING RINGPOPPROGRAMMING RINGPOP

Page 41: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

RING LOOKUPSPROGRAMMING RINGPOP

Page 42: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

APPLICATIONSRINGPOP

Page 43: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

GEOSPATIAL INDEXAPPLICATIONS OF RINGPOP

REPLICA 2

REPLICA 1

OWNER

INST. D

DISPATCH UPDATE DRIVER LOCATION

UPDATE

UPDATE

Page 44: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

WORK DELEGATIONAPPLICATIONS OF RINGPOP

BACKUP 2

BACKUP 1

LEADER

BACKUP 3

POLL DB FOR WORK

Page 45: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

APPLICATIONS OF RINGPOPRINGPOP IN PRODUCTION

Geospatial sharding

Work delegation

Server-side push / long-polling

Caching

Aggregation

Mailboxes

Database

Service Discovery and Routing

Page 46: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

LESSONS LEARNEDRINGPOP

Page 47: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

Verifying correctness.

Scaling and Failing.

DEVELOPMENT AND STAGINGLESSONS LEARNED

Page 48: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

Convergence

Cross-pollination

Flappy nodes

Hard to forget

Slow start times

Anti-entropy

Tooling

Backwards compatibility

PRODUCTIONLESSONS LEARNED

Page 49: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

CONCLUSIONRINGPOP

Page 50: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

DynamoDBby Amazon

Riakby Basho

Serfby Hashicorp

Cassandraby Apache

Orleansby Microsoft

Akkaby Typesafe

Page 51: Jeff Wolski - Explorations in Cooperative, Distributed Systems with Uber's Ringpop

GRAZIE!

Presented by Jeff Wolski <[email protected]>

Uber is hiring.Come work with me in our Amsterdam office!