My mom told me that Git doesn’t scale by Vicent Martí

118
Saturday, May 11, 13

description

With over 2 million and a half repositories, GitHub is the world’s largest source code host. Since day one, we’ve faced an unique engineering problem: making terabytes of Git data always available, either directly or through our website. This talk offers a hopefully insightful view into the internals of Git, the way its original design affects our scalable architecture, and the many things we’ve learnt while solving this fascinating problem.

Transcript of My mom told me that Git doesn’t scale by Vicent Martí

Page 1: My mom told me that Git doesn’t scale by Vicent Martí

Saturday, May 11, 13

Page 2: My mom told me that Git doesn’t scale by Vicent Martí

These are the things you don’t

care about

Saturday, May 11, 13

Page 3: My mom told me that Git doesn’t scale by Vicent Martí

Saturday, May 11, 13

Page 4: My mom told me that Git doesn’t scale by Vicent Martí

github

Saturday, May 11, 13

Page 5: My mom told me that Git doesn’t scale by Vicent Martí

github

Git hosting:No longer a pain in the ass

Saturday, May 11, 13

Page 6: My mom told me that Git doesn’t scale by Vicent Martí

github

Git hosting:No longer a pain in the ass

for you.Not for us.

Because, goddamnit,if I ever find the guy who invented

this thing I’m going to hang him froma fence by his underwear and.Saturday, May 11, 13

Page 7: My mom told me that Git doesn’t scale by Vicent Martí

Let’s host some Git repos!

file.c src

file.h README.md COPYING.md

.git

Bare Repository

HEAD index objects refs

git-daemon

Saturday, May 11, 13

Page 8: My mom told me that Git doesn’t scale by Vicent Martí

OK, now about the web...

grit

Ruby - Gitinterface

Saturday, May 11, 13

Page 9: My mom told me that Git doesn’t scale by Vicent Martí

OK, now about the web...

grit

Bare Repository

Bare Repository

Bare Repository

Ruby - Gitinterface

Saturday, May 11, 13

Page 10: My mom told me that Git doesn’t scale by Vicent Martí

1VMgrit

📽storage

rails app

Saturday, May 11, 13

Page 11: My mom told me that Git doesn’t scale by Vicent Martí

nVM 📽storage

Saturday, May 11, 13

Page 12: My mom told me that Git doesn’t scale by Vicent Martí

nVM 📽storage(GFS)

Saturday, May 11, 13

Page 13: My mom told me that Git doesn’t scale by Vicent Martí

Rails was making us slow.

Saturday, May 11, 13

Page 14: My mom told me that Git doesn’t scale by Vicent Martí

Saturday, May 11, 13

Page 15: My mom told me that Git doesn’t scale by Vicent Martí

Literally.Saturday, May 11, 13

Page 16: My mom told me that Git doesn’t scale by Vicent Martí

Time to move to

Real Hardware

Saturday, May 11, 13

Page 17: My mom told me that Git doesn’t scale by Vicent Martí

fileservers

frontends

📸db

Saturday, May 11, 13

Page 18: My mom told me that Git doesn’t scale by Vicent Martí

fileservers

frontends

📸db

?????????

Saturday, May 11, 13

Page 19: My mom told me that Git doesn’t scale by Vicent Martí

smoke

Saturday, May 11, 13

Page 20: My mom told me that Git doesn’t scale by Vicent Martí

Saturday, May 11, 13

Page 21: My mom told me that Git doesn’t scale by Vicent Martí

bert(binary Erlang term)

Saturday, May 11, 13

Page 22: My mom told me that Git doesn’t scale by Vicent Martí

bert(binary Erlang term)ernie

(not an acronym)

Saturday, May 11, 13

Page 23: My mom told me that Git doesn’t scale by Vicent Martí

📸chimney(Redis)

frontend

fileserver

smoke

grit

erniegrit

Saturday, May 11, 13

Page 24: My mom told me that Git doesn’t scale by Vicent Martí

Vertical Scaling#realtalk

Saturday, May 11, 13

Page 25: My mom told me that Git doesn’t scale by Vicent Martí

bottleneck:

grit

Saturday, May 11, 13

Page 26: My mom told me that Git doesn’t scale by Vicent Martí

bottleneck:

grit

solution:

git

shell out to

Saturday, May 11, 13

Page 27: My mom told me that Git doesn’t scale by Vicent Martí

bottleneck:

git

shell out to

Saturday, May 11, 13

Page 28: My mom told me that Git doesn’t scale by Vicent Martí

bottleneck:

git

solution:

git

shell out to

shell out to

Saturday, May 11, 13

Page 29: My mom told me that Git doesn’t scale by Vicent Martí

bottleneck:

git

solution:

git

shell out to

shell out to

properly

Saturday, May 11, 13

Page 30: My mom told me that Git doesn’t scale by Vicent Martí

Saturday, May 11, 13

Page 31: My mom told me that Git doesn’t scale by Vicent Martí

GUISE

Saturday, May 11, 13

Page 32: My mom told me that Git doesn’t scale by Vicent Martí

GUISEGUISE

Saturday, May 11, 13

Page 33: My mom told me that Git doesn’t scale by Vicent Martí

GUISEGUISEGUISE

Saturday, May 11, 13

Page 34: My mom told me that Git doesn’t scale by Vicent Martí

GUISEGUISEGUISE

...what?

Saturday, May 11, 13

Page 35: My mom told me that Git doesn’t scale by Vicent Martí

Saturday, May 11, 13

Page 36: My mom told me that Git doesn’t scale by Vicent Martí

Why don’t we take

Saturday, May 11, 13

Page 37: My mom told me that Git doesn’t scale by Vicent Martí

Why don’t we take

the Git binary...

Saturday, May 11, 13

Page 38: My mom told me that Git doesn’t scale by Vicent Martí

Why don’t we take

the Git binary...yeah?

Saturday, May 11, 13

Page 39: My mom told me that Git doesn’t scale by Vicent Martí

Why don’t we take

the Git binary...yeah? and compile it as

Saturday, May 11, 13

Page 40: My mom told me that Git doesn’t scale by Vicent Martí

Why don’t we take

the Git binary...yeah? and compile it as

a library

Saturday, May 11, 13

Page 41: My mom told me that Git doesn’t scale by Vicent Martí

Why don’t we take

the Git binary...yeah? and compile it as

a libraryoh... go on...

Saturday, May 11, 13

Page 42: My mom told me that Git doesn’t scale by Vicent Martí

Why don’t we take

the Git binary...yeah? and compile it as

a libraryoh... go on...

and link that into

Saturday, May 11, 13

Page 43: My mom told me that Git doesn’t scale by Vicent Martí

Why don’t we take

the Git binary...yeah? and compile it as

a libraryoh... go on...

and link that intoour server

Saturday, May 11, 13

Page 44: My mom told me that Git doesn’t scale by Vicent Martí

ScientificGraph™

Saturday, May 11, 13

Page 45: My mom told me that Git doesn’t scale by Vicent Martí

Mem

ory

Usa

ge

Time

ScientificGraph™

Saturday, May 11, 13

Page 46: My mom told me that Git doesn’t scale by Vicent Martí

Mem

ory

Usa

ge

Time

ScientificGraph™

Saturday, May 11, 13

Page 47: My mom told me that Git doesn’t scale by Vicent Martí

Mem

ory

Usa

ge

Time

ScientificGraph™

Saturday, May 11, 13

Page 48: My mom told me that Git doesn’t scale by Vicent Martí

Mem

ory

Usa

ge

Time

ScientificGraph™

Saturday, May 11, 13

Page 49: My mom told me that Git doesn’t scale by Vicent Martí

Mem

ory

Usa

ge

Time

ScientificGraph™

Saturday, May 11, 13

Page 50: My mom told me that Git doesn’t scale by Vicent Martí

Mem

ory

Usa

ge

Time

ScientificGraph™

Saturday, May 11, 13

Page 51: My mom told me that Git doesn’t scale by Vicent Martí

Well, we didn’t think about

freeing memory, but...

Saturday, May 11, 13

Page 52: My mom told me that Git doesn’t scale by Vicent Martí

Well, we didn’t think about

freeing memory, but...THIS IS THE KIND

OF PROBLEMWE COULD SOLVE

WITH CGISaturday, May 11, 13

Page 53: My mom told me that Git doesn’t scale by Vicent Martí

Well, we didn’t think about

freeing memory, but...THIS IS THE KIND

OF PROBLEMWE COULD SOLVE

WITH CGIIN 1995

Saturday, May 11, 13

Page 54: My mom told me that Git doesn’t scale by Vicent Martí

ScientificGraph™

Saturday, May 11, 13

Page 55: My mom told me that Git doesn’t scale by Vicent Martí

Mem

ory

Usa

ge

Time

ScientificGraph™

Saturday, May 11, 13

Page 56: My mom told me that Git doesn’t scale by Vicent Martí

Mem

ory

Usa

ge

Time

ScientificGraph™

Saturday, May 11, 13

Page 57: My mom told me that Git doesn’t scale by Vicent Martí

Mem

ory

Usa

ge

Time

ScientificGraph™

Saturday, May 11, 13

Page 58: My mom told me that Git doesn’t scale by Vicent Martí

Mem

ory

Usa

ge

Time

ScientificGraph™

Saturday, May 11, 13

Page 59: My mom told me that Git doesn’t scale by Vicent Martí

Mem

ory

Usa

ge

Time

ScientificGraph™

Saturday, May 11, 13

Page 60: My mom told me that Git doesn’t scale by Vicent Martí

Mem

ory

Usa

ge

Time

ScientificGraph™

Saturday, May 11, 13

Page 61: My mom told me that Git doesn’t scale by Vicent Martí

Mem

ory

Usa

ge

Time

ScientificGraph™

Saturday, May 11, 13

Page 62: My mom told me that Git doesn’t scale by Vicent Martí

What do you mean

the server died?

Saturday, May 11, 13

Page 63: My mom told me that Git doesn’t scale by Vicent Martí

die("BUG: non-INDEX attr direction

in a bare repo");

die("a bad revision is needed");

die("'%s' is not a valid branch name.", name); die("Empty patc

h.

Aborted.");

die("unable to read index file");

What do you mean

the server died?

Saturday, May 11, 13

Page 64: My mom told me that Git doesn’t scale by Vicent Martí

libgit

Saturday, May 11, 13

Page 65: My mom told me that Git doesn’t scale by Vicent Martí

libgit2the “2” means this

one

frees memory

Saturday, May 11, 13

Page 66: My mom told me that Git doesn’t scale by Vicent Martí

libgit2the “2” means this

one

frees memory

NOT ENOUGH

ABSTRACT

FACTORIES

Saturday, May 11, 13

Page 67: My mom told me that Git doesn’t scale by Vicent Martí

JGitthe “J” means this oneis in Java

...not our thing.Saturday, May 11, 13

Page 68: My mom told me that Git doesn’t scale by Vicent Martí

Javaa brief timeline

New companies don’t use Java

because it’snot like Unix

1995

New companies use Java

because it’snew and shiny

1997

New companies don’t use Java

because it’sooooooold

2005

New companies use the JVM

because WEBSCALE

2011

Saturday, May 11, 13

Page 69: My mom told me that Git doesn’t scale by Vicent Martí

Javaa brief timeline

New companies don’t use Java

because it’snot like Unix

1995

New companies use Java

because it’snew and shiny

1997

New companies don’t use Java

because it’sooooooold

2005

New companies use the JVM

because WEBSCALE

2011

github

Saturday, May 11, 13

Page 70: My mom told me that Git doesn’t scale by Vicent Martí

If you think you understandthe JVM, you are either:

Saturday, May 11, 13

Page 71: My mom told me that Git doesn’t scale by Vicent Martí

If you think you understandthe JVM, you are either:

a) Very smart

Saturday, May 11, 13

Page 72: My mom told me that Git doesn’t scale by Vicent Martí

If you think you understandthe JVM, you are either:

a) Very smartb) Very wrong

Saturday, May 11, 13

Page 73: My mom told me that Git doesn’t scale by Vicent Martí

If you think you understandthe JVM, you are either:

a) Very smartb) Very wrong

Saturday, May 11, 13

Page 74: My mom told me that Git doesn’t scale by Vicent Martí

Some people think that github is a

Rails shopRuby shop.or even a

Saturday, May 11, 13

Page 75: My mom told me that Git doesn’t scale by Vicent Martí

Some people think that github is a

Rails shopRuby shop.or even a

github is a

Unix shopand everything else is

just a detail.

Saturday, May 11, 13

Page 76: My mom told me that Git doesn’t scale by Vicent Martí

libgit2So,

Saturday, May 11, 13

Page 77: My mom told me that Git doesn’t scale by Vicent Martí

Good Heavens,just look at the time.

It’s NoSQL o’clock

NoSQL

NoSQL NoSQL

NoSQL

NoSQL NoSQL

NoSQLNoSQL

Saturday, May 11, 13

Page 78: My mom told me that Git doesn’t scale by Vicent Martí

Saturday, May 11, 13

Page 79: My mom told me that Git doesn’t scale by Vicent Martí

...do you even

Saturday, May 11, 13

Page 80: My mom told me that Git doesn’t scale by Vicent Martí

...do you even mongo?

Saturday, May 11, 13

Page 81: My mom told me that Git doesn’t scale by Vicent Martí

a b r i e f i n t r o d u c t i o nt o t h e G i t d a t a m o d e l

Saturday, May 11, 13

Page 82: My mom told me that Git doesn’t scale by Vicent Martí

Saturday, May 11, 13

Page 83: My mom told me that Git doesn’t scale by Vicent Martí

Saturday, May 11, 13

Page 84: My mom told me that Git doesn’t scale by Vicent Martí

file.c src

file.h README.md COPYING.md

Saturday, May 11, 13

Page 85: My mom told me that Git doesn’t scale by Vicent Martí

file.c src

file.h README.md COPYING.md

treesrc/

README.md

COPYING.md

treefile.c

file.h

blob

blob

blob

blob

Saturday, May 11, 13

Page 86: My mom told me that Git doesn’t scale by Vicent Martí

commit

parent

tree Tmetadata

Saturday, May 11, 13

Page 87: My mom told me that Git doesn’t scale by Vicent Martí

commitT

commitT

commitT

commitT

commitT

commitT

Behold,a graph.

Saturday, May 11, 13

Page 88: My mom told me that Git doesn’t scale by Vicent Martí

Saturday, May 11, 13

Page 89: My mom told me that Git doesn’t scale by Vicent Martí

Well that was easy.

Saturday, May 11, 13

Page 90: My mom told me that Git doesn’t scale by Vicent Martí

Saturday, May 11, 13

Page 91: My mom told me that Git doesn’t scale by Vicent Martí

master

Ohgod

killme

Saturday, May 11, 13

Page 92: My mom told me that Git doesn’t scale by Vicent Martí

Li!le knowntorture methods:

Saturday, May 11, 13

Page 93: My mom told me that Git doesn’t scale by Vicent Martí

Saturday, May 11, 13

Page 94: My mom told me that Git doesn’t scale by Vicent Martí

warning:the rabbithole ispretty deep

Saturday, May 11, 13

Page 95: My mom told me that Git doesn’t scale by Vicent Martí

Git doesn’t give a #!%$ about CAP

Saturday, May 11, 13

Page 96: My mom told me that Git doesn’t scale by Vicent Martí

Saturday, May 11, 13

Page 97: My mom told me that Git doesn’t scale by Vicent Martí

Number of hops on a complex query 1,000,000

Saturday, May 11, 13

Page 98: My mom told me that Git doesn’t scale by Vicent Martí

Number of hops on a complex query 1,000,000

Required hops for a successful query 1,000,000

Saturday, May 11, 13

Page 99: My mom told me that Git doesn’t scale by Vicent Martí

Number of hops on a complex query 1,000,000

Required hops for a successful query 1,000,000

Replica count to ensure 100% availability

a metric shittonSaturday, May 11, 13

Page 100: My mom told me that Git doesn’t scale by Vicent Martí

We could fix it.

Saturday, May 11, 13

Page 101: My mom told me that Git doesn’t scale by Vicent Martí

We could fix it.But we won’t.

Saturday, May 11, 13

Page 102: My mom told me that Git doesn’t scale by Vicent Martí

libgit2

Saturday, May 11, 13

Page 103: My mom told me that Git doesn’t scale by Vicent Martí

libgit2

Saturday, May 11, 13

Page 104: My mom told me that Git doesn’t scale by Vicent Martí

GitRPCSaturday, May 11, 13

Page 105: My mom told me that Git doesn’t scale by Vicent Martí

GitRPCLess.

Saturday, May 11, 13

Page 106: My mom told me that Git doesn’t scale by Vicent Martí

GitRPC

Rugged

libgit2

server

Ruby

Ruby

C

Saturday, May 11, 13

Page 107: My mom told me that Git doesn’t scale by Vicent Martí

📸chimney(Redis)

frontend

fileserver

smoke

grit

ernie-corn

grit

GitRPC GitRPC

Saturday, May 11, 13

Page 108: My mom told me that Git doesn’t scale by Vicent Martí

📸chimney(Redis)

frontend fileserver

GitRPC GitRPCserverclient

Saturday, May 11, 13

Page 109: My mom told me that Git doesn’t scale by Vicent Martí

evolutionary(disappointing?)

Saturday, May 11, 13

Page 110: My mom told me that Git doesn’t scale by Vicent Martí

We’ve had a lot of

Saturday, May 11, 13

Page 111: My mom told me that Git doesn’t scale by Vicent Martí

We’ve had a lot of hard

engineering challenges

Saturday, May 11, 13

Page 112: My mom told me that Git doesn’t scale by Vicent Martí

We tackled them by:

Saturday, May 11, 13

Page 113: My mom told me that Git doesn’t scale by Vicent Martí

Using themost reliable

tools we know.

Saturday, May 11, 13

Page 114: My mom told me that Git doesn’t scale by Vicent Martí

Challenging ourselves to build

the simplest thing.Not because it’s easy,but because it works.

Saturday, May 11, 13

Page 115: My mom told me that Git doesn’t scale by Vicent Martí

Innovatingwhere it really ma!ers.

Saturday, May 11, 13

Page 116: My mom told me that Git doesn’t scale by Vicent Martí

revolutionaryproduct

building a

revolutionarybackend.

not a

Saturday, May 11, 13

Page 117: My mom told me that Git doesn’t scale by Vicent Martí

Having fun

Saturday, May 11, 13

Page 118: My mom told me that Git doesn’t scale by Vicent Martí

Saturday, May 11, 13