outgrowing an internet startup: database administration in a fast growing company

38
Spil Games: outgrowing an internet startup Art van Scheppingen Head of Database Engineering

Upload: spil-engineering

Post on 15-Jan-2015

127 views

Category:

Technology


2 download

Tags:

DESCRIPTION

Database administration in a fast growing company: problems and solutions.

TRANSCRIPT

Page 1: Outgrowing an internet startup: database administration in a fast growing company

Spil Games: outgrowing an internet startup Art van Scheppingen Head of Database Engineering

Page 2: Outgrowing an internet startup: database administration in a fast growing company

2  

1.  Who  is  Spil  Games?  2.  How  to  professionalize?  3.  Spil  Storage  Pla<orm  4.  Ques@ons?  

Overview

Page 3: Outgrowing an internet startup: database administration in a fast growing company

Who are we? Who  is  Spil  Games?    

Page 4: Outgrowing an internet startup: database administration in a fast growing company

4  

•  Company  founded  in  2001  •  350+  employees  world  wide  •  170M  unique  visitors  per  month  •  100K  unique  visitors  per  month  on  spilgames.com  

Facts

Page 5: Outgrowing an internet startup: database administration in a fast growing company

5  

Geographic Reach 170  Million  Monthly  Ac@ve  Users(*)  

Source:  (*)  Google  Analy3cs,  December  2011  

•  Over  40  localized  portals  in  19  languages  •  Focus  on  casual  and  social  games  •  170M  MAU  per  month  (30M  YoY  growth)  •  Over  40M  registered  users  

Page 6: Outgrowing an internet startup: database administration in a fast growing company

6  

Girls,  Teens  and  Family  Brands

Page 7: Outgrowing an internet startup: database administration in a fast growing company

7  

Games

Page 8: Outgrowing an internet startup: database administration in a fast growing company

8  

Games

Page 9: Outgrowing an internet startup: database administration in a fast growing company

9  

Games

Page 10: Outgrowing an internet startup: database administration in a fast growing company

10  

Games

Page 11: Outgrowing an internet startup: database administration in a fast growing company

11  

Games

Page 12: Outgrowing an internet startup: database administration in a fast growing company

12  

Games

•  Inhouse  game  studios  •  Partnerships  with  Social  Gaming  studios  •  Over  1500  licensed  games  

Page 13: Outgrowing an internet startup: database administration in a fast growing company

13  

DB  Servers  MAU  Employees  

2006   2007   2008   2009   2010   2011  

DB  Servers  

MAU  

Employees  

Spil Games is growing fast!

Page 14: Outgrowing an internet startup: database administration in a fast growing company

Database Engineering How  to  professionalize  your  department    

Page 15: Outgrowing an internet startup: database administration in a fast growing company

15  

•  Databases  maintained  by  Systems  Engineering  •  No  focus  on  performance,  structure  or  backups  •  Looking  only  one  or  two  weeks  into  the  future  

Startup

Page 16: Outgrowing an internet startup: database administration in a fast growing company

16  

•  Mul@ple  migra@ons  to  new  hardware  •  Ping-­‐pong  on  Master-­‐Master  setups  •  Lack  of  insight  into  performance  issues  

Lessons

Read+write

Page 17: Outgrowing an internet startup: database administration in a fast growing company

17  

•  Plan  ahead  up  to  three  months  •  Improve  database  pla<orm  •  Reduce  number  of  repe@@ve  tasks  

•  Write  them  down  step  by  step  (wiki)  •  Automate  where  possible  

•  Improve  monitoring  •  A  single  monitoring  system  is  not  enough!  

•  Forecast  growth  •  Week  /  Month  /  Year  •  Look  back  and  evaluate!  

•  Extend  department  

Professionalize

Page 18: Outgrowing an internet startup: database administration in a fast growing company

18  

•  Scaling  the  LDAP  pla<orm  •  LDAP  replaced  by  MySQL  based  solu@on  (with  help  from  Percona)  

LDAP isn’t suitable for the web

MMMDMM

Page 19: Outgrowing an internet startup: database administration in a fast growing company

19  

•  LVM  snapshot  method  •  took  4  hours  on  average  with  manual  interven@on  

•  Innobackupex  +  netcat  +  tar  +  script  =  quick  cloning  •  Takes  about  1  hour  per  100GB  •  Foolproof  •  Can  be  run  on  ac@ve  masters  (if  necessary)  

Cloning

Page 20: Outgrowing an internet startup: database administration in a fast growing company

20  

•  Different  monitoring  systems  give  different  insights  •  Different  angles/metrics/purposes  •  Early  problem  detec@on  •  Signal  abnormal  use  which  could  cause  outage  

Improve monitoring

Page 21: Outgrowing an internet startup: database administration in a fast growing company

21  

•  Uneven  growth:  •  Ac@ve  master  handling  all  write  requests  •  Ver@cal  scaling    

•  Write  only  •  More  writes  than  reads  

•  SOA  problems  •  Connec@on  spawning  •  Open  file  descriptors  

Growing pains

Page 22: Outgrowing an internet startup: database administration in a fast growing company

22  

•  An@cipate  more  than  one  year  in  advance  •  Acknowledge  shortcomings/problems,  look  for  solu@ons  or  alterna@ves  •  Don't  commit  to  one  single  solu@on!  •  Be  flexible!  

•  Plan  for  capacity  per  instance,  not  for  growth  alone!  •  Start  thinking  globally!  

Outgrowing our startup phase

Page 23: Outgrowing an internet startup: database administration in a fast growing company

Spil Storage Platform Sharding  is  inevitable    

Page 24: Outgrowing an internet startup: database administration in a fast growing company

24  

What is this exciting project about?

Page 25: Outgrowing an internet startup: database administration in a fast growing company

25  

•  Natural  growth  •  Grown  out  of  necessity  for  more  func@onality  •  Adding  func@onality  means  more  interac@on  •  Separa@on  of  database  func@on  •  Profiles  •  Highscores  •  Comments  •  User  Generated  Content  •  etc  

Functional sharding

Page 26: Outgrowing an internet startup: database administration in a fast growing company

26  

•  KISS  •  Problem  isola@on  

Advantages

Disadvantages •  Uneven  growth  •  Difference  in  query  panerns  •  No  data  consistency  •  No  clear  ownership  of  data  •  Capacity  planning  on  total  number  of  reads/writes  •  Horizontal  scaling  is  difficult  

Page 27: Outgrowing an internet startup: database administration in a fast growing company

27  

Spil Storage Platform

Page 28: Outgrowing an internet startup: database administration in a fast growing company

28  

•  What  is  the  bucket  model?  •  It  is  an  abstrac@on  layer  between  the  database  and  the  datamodel  

•  Each  record  has  one  unique  owner  anribute  (GID)  •  The  GID  (Global  IDen@fier)  iden@fies  different  data  types  

•  Different  buckets  per  func@on  •  Anributes  contain  record  data  •  Anributes  do  not  have  to  correspond  to  schema  

Bucket model

Page 29: Outgrowing an internet startup: database administration in a fast growing company

29  

•  Flexibility  •  Database  backend  independent  •  Seamless  schema  changes  and  upgrades  •  Sharded  on  both  func@onal  and  GID  level  

•  Even  distribu@on  of  queries  possible  •  Capacity  planning  on  number  and  type  of  en@@es  

•  Asynchronous  writes  possible  •  Transparent  data  migra@on  

Advantages

Disadvantages •  Harder  to  find  data  •  At  least  two  lookups  needed!  •  Datawarehousing  needs  a  different  approach  

Page 30: Outgrowing an internet startup: database administration in a fast growing company

30  

•  Globally  sharded  on  GID  •  (local)  GID  Lookup  

How do GIDs work?

GID lookup

Shard 1 Shard 2

Persistent storage

Page 31: Outgrowing an internet startup: database administration in a fast growing company

31  

Pipeline flow

Page 32: Outgrowing an internet startup: database administration in a fast growing company

Current functional shards

SPAPI

LEGACY adapter

New Application SSP

Legacy API

New GID based shards

Read only

Read + write

32  

Bucket mapping and migration

Page 33: Outgrowing an internet startup: database administration in a fast growing company

33  

•  Each  cluster  of  two  masters  will  contain  two  shards  •  Data  is  wrinen  interleaved  •  HA  for  both  shards  •  No  warmup  needed  

•  Both  masters  ac@ve  and  “warmed  up”  •  Slave  added  for  backups  and  Datawarehouse  

Master-Master Sharding

SSP  

Shard  1                                      

Shard  2                                      

Page 34: Outgrowing an internet startup: database administration in a fast growing company

34  

•  Erlang  cluster  with  many  workers  •  Every  GID  has  its  own  worker  process  •  (Inter)cluster  communica@on  •  (Near)  linear  scalability  

How are we implementing this SSP?

Page 35: Outgrowing an internet startup: database administration in a fast growing company

35  

•  Erlang  node  caching  •  Mul@ple  backend  connectors  •  MySQL  library  •  Handlersockets  •  Any  other  connectors  if  needed  

•  Connec@on  pooling  

Advantages

Disadvantages •  NOT  SEXY?  (  hnp://spil.com/notsexy  )  

Page 36: Outgrowing an internet startup: database administration in a fast growing company

36  

Do YOU want to be sexy?

Page 37: Outgrowing an internet startup: database administration in a fast growing company

Questions?

Page 38: Outgrowing an internet startup: database administration in a fast growing company

38  

Thank you!