How A Small Team Scales Instagram
How A Small Team Scales Instagram
of Scaling Instagram
(with a tiny team)
Mike Krieger
QConSF 2013
'_
' . _
,. ..
' _
,..
'
',
' ' ,
_ ' '' '
, , '
__ '
' '
_
Core principles
' ' '_ '
, _ ' '
' , ' ' _
' '
,'_
'
Early days
Year 1: Scaling Up
Year 2: Scaling Out
Year 3-present: Stability, Video, FB
Getting Started
.
. _,
'
, '
Django + Apache mod_wsgi
Postgres
Redis
Gearman
Memcached
Nginx
',
Django + uWSGI
Postgres
Redis
Celery
Memcached
HAproxy
' '
_ _'
'
Year 1: Scaling Up
_,
_
' _
_' '
'
.
' '_
. '' _
' _ ' _'
' _
,
'
' , ,
_ '
Scaling up DB
' ''
' ' '
'_ '
' ''_
_ '
''
Media
Likes
Comments
Everything else
' '
''
_' some '
' ' _ _
,' ' , ,
,
_' , , '
Scaling up Redis
,
,
' ''_ ,
' ',
, _' ',
', '_
'_ '_
' _''
_ '
Scaling Memcached
'' _
'
'' '
, '
_
'
Cong Management
& Deployment
_'
,, '
'
'
'
''
'_
'
Ending the year
__ '
'
'
'_ '_ '
' '
'_ '
' '
'' ' '' ''
Database Scale Out
' _
,
__' '
'_
, ''_ _
' _' _'
' ' '
_ ,. ' '
'
'
'_ ' , ,
' _'
'
' '
'
, ' ,
' ,
_
_ '_
' '
'
, _
_ ''_
' '
' '_
''
'
''
' '
. ' '
'_
'
'
',
',
.
',
',
',
',
.
',
',
',
',
.
',
',
',
',
.
',
',
',
',
.
',
',
'
',
. _ '
,
_'
'
No extra moving parts
64 bits max
Time ordered
Containing partition key
41 ' ' , ,
13 ' _
10 ' ''_
.
_' .
'
Lesson learned
'
''
'', ' ,
'_ '
_ '
Scaling congs/host
discovery
' ' '
''
.'_
'''
,_' ,
' '
'
' ' _'
' , ' _
Monitoring
' '
' ''
'' '
'
statsd.timer
statsd.incr
' _
''' ' ''
'_ '
' _ _
580 '' '
164 '' '
Ending the year
,_ '
',
'
'
, , _
'
Year 3+: Stability,
Video, FB
' ' '
'
Deployment &
Cong Management
,
'_ '
,
,
, ' ,
' '_'
' '
'
'' _ ,'
' _ _
,' '_
''_
Hit issue
Develop manual approach
Build tools to improve manual / hands on
approach
Replace manual with automated system
Monitoring
,
_ __
'_
,''_
''' '
___ _
'' _'_'
' '_
s = time.time()
# do work
statsd.incr("waittime.VIEWNAME.C
OMPONENT", time.time() - s)
',
Feeds and Inboxes
, '
, '
'
'
_
''
' . '
,' '
Knobs
,
_
,
,
,
, '
'
,
knobs.get(feature_name,
default)
'
_
'_
''
,, ' ' '
,
. '_
', ' '
_ '
', ''
'' '
_
___
' ,
,' ' '
, ' ' '
FB
,
,'
_'_
re.compile(f[o0][1l][o0]w)
' '_ ' '
'
_
'
',
, _
. '_
- ' '_
'
Wrap up
Core principles
' ' '_ '
, _ ' '
' , ' ' _
' '
,'_
Takeaways
' , '
, '
' ,
, ,
' _
,' '
_ ' '
_
,'_