SlideShare a Scribd company logo
1 of 68
Download to read offline
O’Reilly  RailsConf,  2011-­‐05-­‐18
Who  is  that  guy?

  Jesper  Richter-­‐Reichhelm  /  @jrirei
  Berlin,  Germany
  Head  of  Engineering  @  wooga
Wooga  does  social  games
Wooga  has  dedicated  game  teams

                                         Cooming
                                           soon


      PHP        Ruby        Ruby        Erlang
     Cloud       Cloud     Bare  metal   Cloud
Flash  client  sends  state  changes  to  backend

        Flash  client                Ruby  backend
Social  games  need  to  scale  quite  a  bit

   1  million  daily  users
   200  million  daily  HTTP  requests
Social  games  need  to  scale  quite  a  bit

   1  million  daily  users
   200  million  daily  HTTP  requests


   100,000  DB  operaGons  per  second
   40,000  DB  updates  per  second
Social  games  need  to  scale  quite  a  bit

   1  million  daily  users
   200  million  daily  HTTP  requests


   100,000  DB  operaGons  per  second
   40,000  DB  updates  per  second


   …  but  no  cache
A  journey  to  1,000,000  daily  users

  Start  of  the  journey
  6  weeks  of  pain
  Paradise
  Looking  back
We  used  two  MySQL  shards  right  from  the  start

  data_fabric  gem
  	
 Easy  to  use
  	
 Sharding  by  Facebook’s  user  id
  	
 Sharding  on  controller  level
Scaling  applicaLon  servers  was  very  easy

  Running  at  Amazon  EC2
  Scalarium  for  automaGon  and  deployment
    Role  based
    Chef  recipes  for  customiza5on
  Scaling  app  servers  up  and  out  was  simple
Master-­‐slave  replicaLon  for  DBs  worked  fine
                              lb




                      app     app    app




                       db            db


                       db            db
                      slave         slave
We  added  a  few  applicaLon  servers  over  Lme
                                  lb




        app   app   app   app     app    app    app   app   app




                           db            db


                           db            db
                          slave         slave
Basic  setup  worked  well  for  3  months




         May    Jun   Jul   Aug   Sep    Oct   Nov   Dec
A  journey  to  1,000,000  daily  users

  Start  of  the  journey
  6  weeks  of  pain
  Paradise
  Looking  back
SQL  queries  generated  by  Rubyamf  gem

  Rubyamf  serializes  returned  objects
  Wrong  config  =>  it  also  loads  associaGons
SQL  queries  generated  by  Rubyamf  gem

  Rubyamf  serializes  returned  objects
  Wrong  config  =>  it  also  loads  associaGons


  Really  bad  but  very  easy  to  fix
New  Relic  shows  what  happens  during  an  API  call
More  traffic  using  the  same  cluster
                                  lb




        app   app   app   app     app    app    app   app   app




                           db            db


                           db            db
                          slave         slave
Our  DB  problems  began




        May   Jun   Jul    Aug   Sep   Oct   Nov   Dec
MySQL  hiccups  were  becoming  more  frequent

  Everything  was  running  fine  ...
  ...  and  then  DB  throughput  went  down  to  10%


  A]er  a  few  minutes  everything  stabilizes  again  ...
  ...  just  to  repeat  the  cycle  20  minutes  later!
AcLveRecord’s  checks  caused  20%  extra  DB  load

  Check  connecGon  state  before  each  SQL  query
  MySQL  process  list  full  of  ‘status’  calls
AcLveRecord’s  status  checks  caused  20%  extra  DB  

  Check  connecGon  state  before  each  SQL  query
  MySQL  process  list  full  of  ‘status’  calls
I/O  on  MySQL  masters  sLll  was  the  boYleneck

  New  Relic  shows  DB  table  usage
  60%  of  all  UPDATEs  were  done  on  the  ‘Gles’  table
New  Relic  shows  most  used  tables
Tiles  are  part  of  the  core  game  loop
                                         Core  game  loop:
                                         1)  plant
                                         2)  wait
                                         3)  harvest

                                         All  are  
                                         operaGons
                                         on  Tiles  table.
We  started  to  shard  on  model,  too

  We  put  this  table  in  2  extra  shards




      old              old  
     master           slave
We  started  to  shard  on  model,  too

  We  put  this  table  in  2  extra  shards
    1)  Setup  new  masters  as  slaves  of  old  ones




      old             old             new  
     master          slave           master
We  started  to  shard  on  model,  too

  We  put  this  table  in  2  extra  shards
    1)  Setup  new  masters  as  slaves  of  old  ones




      old             old             new                new  
     master          slave           master              slave
We  started  to  shard  on  model,  too

  We  put  this  table  in  2  extra  shards
    1)  Setup  new  masters  as  slaves  of  old  ones
    2)  App  servers  start  using  new  masters,  too




      old             old             new                new  
     master          slave           master              slave
We  started  to  shard  on  model,  too

  We  put  this  table  in  2  extra  shards
    1)  Setup  new  masters  as  slaves  of  old  ones
    2)  App  servers  start  using  new  masters,  too
    3)  Cut  replica5on




      old             old             new                new  
     master          slave           master              slave
We  started  to  shard  on  model,  too

  We  put  this  table  in  2  extra  shards
    1)  Setup  new  masters  as  slave  of  old  ones
    2)  App  servers  start  using  new  masters,  too
    3)  Cut  replica5on
    4)  Truncate  not-­‐used  tables


      old             old             new                new  
     master          slave           master              slave
8  DBs  and  a  few  more  servers
                                          lb




           app   app     app        app        app       app     app   app


           app   app     app        app        app       app     app   app




                                                     5les      5les
                  db           db
                                                      db        db

                  db        db                       5les      5les
                 slave     slave                     slave     slave
Doubling  the  amount  of  DBs  didn’t  fix  it




         May    Jun    Jul   Aug   Sep    Oct    Nov   Dec
We  improved  our  MySQL  setup

  RAID-­‐0  of  EBS  volumes
  Using  XtraDB  instead  of  vanilla  MySQL
  Tweaking  my.cnf
    innodb_flush_log_at_trx_commit
    innodb_flush_method
Data-­‐fabric  gem  circumvented  AR’s  internal  cache

  2x  Tile.find_by_id(id)  =>  1x  SELECT  …
Data-­‐fabric  gem  circumvented  AR’s  internal  cache

  2x  Tile.find_by_id(id)  =>  1x  SELECT  …
2  +  2  masters  and  sLll  I/O  was  not  fast  enough

   We  were  geing  desperate:
   “If  2  +  2  is  not  enough,  ...
   …  perhaps  4  +  4  masters  will  do?”
It’s  no  fun  to  handle  16  MySQL  DBs
                                     lb




         app   app     app   app     app   app     app      app   app


         app   app     app   app     app   app     app      app   app




                                           5les     5les
                      db      db
                                            db       db

                      db      db           5les     5les
                     slave   slave         slave    slave
It’s  no  fun  to  handle  16  MySQL  DBs
                                              lb




             app        app     app   app     app   app     app      app          app


             app        app     app   app     app   app     app      app      app




                                                    5les     5les          5les         5les
      db           db          db      db
                                                     db       db            db           db

      db        db             db      db           5les     5les      5les             5les
     slave     slave          slave   slave         slave    slave     slave            slave
We  were  at  a  dead  end  with  MySQL




         May   Jun   Jul   Aug   Sep      Oct   Nov   Dec
I/O  remained  the  boYleneck  for  MySQL  UPDATEs

  Peak  throughput  overall:  5,000  writes/s
  Peak  throughput  single  master:  850  writes/s


  We  could  get  to  ~1,000  writes/s  …
  …  but  then  what?
Pick  the  right  tool  for  the  job!
Redis  is  fast  but  goes  beyond  simple  key/value

  Redis  is  a  key-­‐value  store
    Hashes,  Sets,  Sorted  Sets,  Lists
    Atomic  opera5ons  like  set,  get,  increment
  50,000  transacGons/s  on  EC2
    Writes  are  as  fast  as  reads
Shelf  Lles  :  An  ideal  candidate  for  using  Redis  




                                                 Shelf  Lles:
                                             {  plant1  =>  184,
                                              plant2  =>  141,
                                              plant3  =>  130,
                                              plant4  =>  112,
                                                     …  }
Shelf  Lles  :  An  ideal  candidate  for  using  Redis  

   Redis  Hash
     HGETALL:  load  whole  hash
     HGET:  load  a  single  key
     HSET:  set  a  single  key
     HINCRBY:  increase  value  of  single  key
     …
Migrate  on  the  fly  when  accessing  new  model
Migrate  on  the  fly  -­‐  but  only  once




                    true  if  id  could  be  added
                    else  false
Migrate  on  the  fly  -­‐  and  clean  up  later

   1. Let  this  running  everything  cools  down
   2. Then  migrate  the  rest  manually
   3. Remove  the  migraGon  code
   4. Wait  unGl  no  fallback  necessary
   5. Remove  the  SQL  table
MigraLons  on  the  fly  all  look  the  same

  Typical  migraGon  throughput  over  3  days
    Ini5al  peak  at  100  migra5ons  /  second
A  journey  to  1,000,000  daily  users

  Start  of  the  journey
  6  weeks  of  pain
  Paredise  (or  not?)
  Looking  back
Again:  Tiles  are  part  of  the  core  game  loop
                                         Core  game  loop:
                                         1)  plant
                                         2)  wait
                                         3)  harvest

                                         All  are  
                                         operaGons
                                         on  Tiles  table.
Size  maYers  for  migraLons

  MigraGon  check  overloaded  Redis
   Migra5on  only  on  startup


  We  overlooked  an  edge  case
   Next  5me  only  migrate  1%  of  users
   Migrate  the  rest  when  everything  worked  out
In-­‐memory  DBs  don’t  like  to  saving  to  disk

   You  sGll  need  to  write  data  to  disk  eventually
     SAVE  is  blocking
     BGSAVE  needs  free  RAM
   Dumping  on  master  increased  latency  by  100%
In-­‐memory  DBs  don’t  like  to  dump  to  disk

   You  sGll  need  to  write  data  to  disk  eventually
     SAVE  is  blocking
     BGSAVE  needs  free  RAM
   Dumping  on  master  increased  latency  by  100%


   Running  BGSAVE  slaves  every  15  minutes
ReplicaLon  puts  Redis  master  under  load

  ReplicaGon  on  master  starts  with  a  BGSAVE
    Not  enough  free  RAM  =>  big  problem


  Master  queue  requests  that  slave  cannot  process
    Restoring  dump  on  slaves  is  blocking
Redis  has  a  memory  fragmenLon  problem



                                     44  GB

                                         in  8  days

                                     24  GB
Redis  has  a  memory  fragmenLon  problem




                                     38  GB
                                          in  3  days
                                     24  GB
If  MySQL  is  a  truck...

   Fast  enough  for  reads
   Can  store  on  disk
   Robust  replicaGon




         hp://www.flickr.com/photos/erix/245657047/
If  MySQL  is  a  truck,  Redis  is  a  Ferrari

   Fast  enough  for  reads                           Super  fast  reads/writes
   Can  store  on  disk                               Out  of  memory  =>  dead
   Robust  replicaGon                                 Fragile  replicaGon




         hp://www.flickr.com/photos/erix/245657047/
Big    and  staLc  data  in  MySQL,  rest  goes  to  Redis

   Fast  enough  for  reads                           Super  fast  reads/writes
   Can  store  on  disk                               Out  of  memory  =>  dead
   Robust  replicaGon                                 Fragile  replicaGon


       256  GB  data                                      60  GB  data
        10%  writes                                       50%  writes
         hp://www.flickr.com/photos/erix/245657047/
95%  of  operaLon  effort  is  handling  DBs!
                                                  lb         lb


app     app      app        app     app   app          app        app     app      app   app     app   app


app     app      app        app     app   app          app        app     app      app   app     app   app


app     app      app        app     app   app          app        app     app      app   app     app   app



 db       db           db          db      db                     redis    redis     redis     redis   redis


 db       db        db             db      db                     redis    redis     redis     redis   redis
slave    slave     slave          slave   slave                   slave    slave     slave     slave   slave
We  fixed  all  our  problem  -­‐  we  were  in  Paradise!




          May    Jun    Jul   Aug    Sep    Oct   Nov       Dec
A  journey  to  1,000,000  daily  users

  Start  of  the  journey
  6  weeks  of  pain
  Paredise  (or  not?)
  Looking  back
Data  handling  is  most  important

  How  much  data  will  you  have?
  How  o]en  will  you  read/update  that  data?
  What  data  is  in  the  client,  what  in  the  server?


  It’s  hard  to  “refactor”  data  later  on
Monitor  and  measure  your  applicaLon  closely

  On  applicaGon  level  /  on  OS  level


  Learn  your  app’s  normal  behavior
  Store  historical  data  so  you  can  compare  later


  React  if  necessary!
Listen  closely  and  answer  truthfully




                       Q  &  A
    Jesper  Richter-­‐Reichhelm

             @jrirei              slideshare.net/wooga
If  you  are  in  Berlin  just  drop  by




                   Thank  you
     Jesper  Richter-­‐Reichhelm

               @jrirei              slideshare.net/wooga

More Related Content

Viewers also liked

Games for the Masses: Scaling Rails to the Extreme
Games for the Masses: Scaling Rails to the ExtremeGames for the Masses: Scaling Rails to the Extreme
Games for the Masses: Scaling Rails to the ExtremeWooga
 
Metrics. Driven. Design. (Developer Conference Hamburg 2012)
Metrics. Driven. Design. (Developer Conference Hamburg 2012)Metrics. Driven. Design. (Developer Conference Hamburg 2012)
Metrics. Driven. Design. (Developer Conference Hamburg 2012)Wooga
 
How to scale a company - game teams at Wooga
How to scale a company - game teams at WoogaHow to scale a company - game teams at Wooga
How to scale a company - game teams at WoogaWooga
 
Event Stream Processing with Kafka (Berlin Buzzwords 2012)
Event Stream Processing with Kafka (Berlin Buzzwords 2012)Event Stream Processing with Kafka (Berlin Buzzwords 2012)
Event Stream Processing with Kafka (Berlin Buzzwords 2012)Wooga
 
2013 04-29-evolution of backend
2013 04-29-evolution of backend2013 04-29-evolution of backend
2013 04-29-evolution of backendWooga
 
You are not alone - Scaling multiplayer games
You are not alone - Scaling multiplayer gamesYou are not alone - Scaling multiplayer games
You are not alone - Scaling multiplayer gamesWooga
 
More than syntax
More than syntaxMore than syntax
More than syntaxWooga
 
Stateful_Application_Server_RuPy 2012_Brno
Stateful_Application_Server_RuPy 2012_BrnoStateful_Application_Server_RuPy 2012_Brno
Stateful_Application_Server_RuPy 2012_BrnoWooga
 
Continuous Integration for iOS (iOS User Group Berlin)
Continuous Integration for iOS (iOS User Group Berlin)Continuous Integration for iOS (iOS User Group Berlin)
Continuous Integration for iOS (iOS User Group Berlin)Wooga
 
Painful success - lessons learned while scaling up
Painful success - lessons learned while scaling upPainful success - lessons learned while scaling up
Painful success - lessons learned while scaling upWooga
 
Wooga: Internationality meets Agility @Zutaten 2013
Wooga: Internationality meets Agility @Zutaten 2013Wooga: Internationality meets Agility @Zutaten 2013
Wooga: Internationality meets Agility @Zutaten 2013Wooga
 
NoSQL Games
NoSQL GamesNoSQL Games
NoSQL GamesWooga
 
Monitoring with Syslog and EventMachine
Monitoring with Syslog and EventMachineMonitoring with Syslog and EventMachine
Monitoring with Syslog and EventMachineWooga
 
Riak at Wooga_Riak Meetup Sept 2013
Riak at Wooga_Riak Meetup Sept 2013Riak at Wooga_Riak Meetup Sept 2013
Riak at Wooga_Riak Meetup Sept 2013Wooga
 
"Common Sense" instead of "Command and Control"_Start up Camp 2013
"Common Sense" instead of "Command and Control"_Start up Camp 2013"Common Sense" instead of "Command and Control"_Start up Camp 2013
"Common Sense" instead of "Command and Control"_Start up Camp 2013Wooga
 
Erlang, the big switch in social games
Erlang, the big switch in social gamesErlang, the big switch in social games
Erlang, the big switch in social gamesWooga
 
WebConf_Riga_Confessions of-a-traitor_Krzsysztof Szafranek
WebConf_Riga_Confessions of-a-traitor_Krzsysztof SzafranekWebConf_Riga_Confessions of-a-traitor_Krzsysztof Szafranek
WebConf_Riga_Confessions of-a-traitor_Krzsysztof SzafranekWooga
 

Viewers also liked (17)

Games for the Masses: Scaling Rails to the Extreme
Games for the Masses: Scaling Rails to the ExtremeGames for the Masses: Scaling Rails to the Extreme
Games for the Masses: Scaling Rails to the Extreme
 
Metrics. Driven. Design. (Developer Conference Hamburg 2012)
Metrics. Driven. Design. (Developer Conference Hamburg 2012)Metrics. Driven. Design. (Developer Conference Hamburg 2012)
Metrics. Driven. Design. (Developer Conference Hamburg 2012)
 
How to scale a company - game teams at Wooga
How to scale a company - game teams at WoogaHow to scale a company - game teams at Wooga
How to scale a company - game teams at Wooga
 
Event Stream Processing with Kafka (Berlin Buzzwords 2012)
Event Stream Processing with Kafka (Berlin Buzzwords 2012)Event Stream Processing with Kafka (Berlin Buzzwords 2012)
Event Stream Processing with Kafka (Berlin Buzzwords 2012)
 
2013 04-29-evolution of backend
2013 04-29-evolution of backend2013 04-29-evolution of backend
2013 04-29-evolution of backend
 
You are not alone - Scaling multiplayer games
You are not alone - Scaling multiplayer gamesYou are not alone - Scaling multiplayer games
You are not alone - Scaling multiplayer games
 
More than syntax
More than syntaxMore than syntax
More than syntax
 
Stateful_Application_Server_RuPy 2012_Brno
Stateful_Application_Server_RuPy 2012_BrnoStateful_Application_Server_RuPy 2012_Brno
Stateful_Application_Server_RuPy 2012_Brno
 
Continuous Integration for iOS (iOS User Group Berlin)
Continuous Integration for iOS (iOS User Group Berlin)Continuous Integration for iOS (iOS User Group Berlin)
Continuous Integration for iOS (iOS User Group Berlin)
 
Painful success - lessons learned while scaling up
Painful success - lessons learned while scaling upPainful success - lessons learned while scaling up
Painful success - lessons learned while scaling up
 
Wooga: Internationality meets Agility @Zutaten 2013
Wooga: Internationality meets Agility @Zutaten 2013Wooga: Internationality meets Agility @Zutaten 2013
Wooga: Internationality meets Agility @Zutaten 2013
 
NoSQL Games
NoSQL GamesNoSQL Games
NoSQL Games
 
Monitoring with Syslog and EventMachine
Monitoring with Syslog and EventMachineMonitoring with Syslog and EventMachine
Monitoring with Syslog and EventMachine
 
Riak at Wooga_Riak Meetup Sept 2013
Riak at Wooga_Riak Meetup Sept 2013Riak at Wooga_Riak Meetup Sept 2013
Riak at Wooga_Riak Meetup Sept 2013
 
"Common Sense" instead of "Command and Control"_Start up Camp 2013
"Common Sense" instead of "Command and Control"_Start up Camp 2013"Common Sense" instead of "Command and Control"_Start up Camp 2013
"Common Sense" instead of "Command and Control"_Start up Camp 2013
 
Erlang, the big switch in social games
Erlang, the big switch in social gamesErlang, the big switch in social games
Erlang, the big switch in social games
 
WebConf_Riga_Confessions of-a-traitor_Krzsysztof Szafranek
WebConf_Riga_Confessions of-a-traitor_Krzsysztof SzafranekWebConf_Riga_Confessions of-a-traitor_Krzsysztof Szafranek
WebConf_Riga_Confessions of-a-traitor_Krzsysztof Szafranek
 

More from Wooga

Story of Warlords: Bringing a turn-based strategy game to mobile
Story of Warlords: Bringing a turn-based strategy game to mobile Story of Warlords: Bringing a turn-based strategy game to mobile
Story of Warlords: Bringing a turn-based strategy game to mobile Wooga
 
Instagram Celebrities: are they the new cats? - Targetsummit Berlin 2015
Instagram Celebrities: are they the new cats? - Targetsummit Berlin 2015Instagram Celebrities: are they the new cats? - Targetsummit Berlin 2015
Instagram Celebrities: are they the new cats? - Targetsummit Berlin 2015Wooga
 
In it for the long haul - How Wooga boosts long-term retention
In it for the long haul - How Wooga boosts long-term retentionIn it for the long haul - How Wooga boosts long-term retention
In it for the long haul - How Wooga boosts long-term retentionWooga
 
Leveling up in localization! - Susan Alma & Dario Quondamstefano
Leveling up in localization! - Susan Alma & Dario QuondamstefanoLeveling up in localization! - Susan Alma & Dario Quondamstefano
Leveling up in localization! - Susan Alma & Dario QuondamstefanoWooga
 
Evoloution of Ideas
Evoloution of IdeasEvoloution of Ideas
Evoloution of IdeasWooga
 
Entitas System Architecture with Unity - Maxim Zaks and Simon Schmid
Entitas System Architecture with Unity - Maxim Zaks and Simon Schmid Entitas System Architecture with Unity - Maxim Zaks and Simon Schmid
Entitas System Architecture with Unity - Maxim Zaks and Simon Schmid Wooga
 
Saying No to the CEO: A Deep Look at Independent Teams - Adam Telfer
Saying No to the CEO: A Deep Look at Independent Teams - Adam TelferSaying No to the CEO: A Deep Look at Independent Teams - Adam Telfer
Saying No to the CEO: A Deep Look at Independent Teams - Adam TelferWooga
 
Innovation dank DevOps (DevOpsCon Berlin 2015)
Innovation dank DevOps (DevOpsCon Berlin 2015)Innovation dank DevOps (DevOpsCon Berlin 2015)
Innovation dank DevOps (DevOpsCon Berlin 2015)Wooga
 
Big Fish, small pond - strategies for surviving in a maturing market - Ed Biden
Big Fish, small pond - strategies for surviving in a maturing market - Ed BidenBig Fish, small pond - strategies for surviving in a maturing market - Ed Biden
Big Fish, small pond - strategies for surviving in a maturing market - Ed BidenWooga
 
Review mining aps2014 berlin
Review mining aps2014 berlinReview mining aps2014 berlin
Review mining aps2014 berlinWooga
 
Riak & Wooga_Geeek2Geeek Meetup2014 Berlin
Riak & Wooga_Geeek2Geeek Meetup2014 BerlinRiak & Wooga_Geeek2Geeek Meetup2014 Berlin
Riak & Wooga_Geeek2Geeek Meetup2014 BerlinWooga
 
Staying in the Game: Game localization practices for the mobile market
Staying in the Game: Game localization practices for the mobile marketStaying in the Game: Game localization practices for the mobile market
Staying in the Game: Game localization practices for the mobile marketWooga
 
Startup Weekend_Makers and Games_Philipp Stelzer
Startup Weekend_Makers and Games_Philipp StelzerStartup Weekend_Makers and Games_Philipp Stelzer
Startup Weekend_Makers and Games_Philipp StelzerWooga
 
DevOps goes Mobile (daho.am)
DevOps goes Mobile (daho.am)DevOps goes Mobile (daho.am)
DevOps goes Mobile (daho.am)Wooga
 
DevOps goes Mobile - Jax 2014 - Jesper Richter-Reichhelm
DevOps goes Mobile - Jax 2014 - Jesper Richter-ReichhelmDevOps goes Mobile - Jax 2014 - Jesper Richter-Reichhelm
DevOps goes Mobile - Jax 2014 - Jesper Richter-ReichhelmWooga
 
CodeFest 2014_Mobile Game Development
CodeFest 2014_Mobile Game DevelopmentCodeFest 2014_Mobile Game Development
CodeFest 2014_Mobile Game DevelopmentWooga
 
Jelly Splash: Puzzling your way to the top of the App Stores - GDC 2014
Jelly Splash: Puzzling your way to the top of the App Stores - GDC 2014Jelly Splash: Puzzling your way to the top of the App Stores - GDC 2014
Jelly Splash: Puzzling your way to the top of the App Stores - GDC 2014Wooga
 
How to hire the best people for your startup-Gitta Blat-Head of People
How to hire the best people for your startup-Gitta Blat-Head of PeopleHow to hire the best people for your startup-Gitta Blat-Head of People
How to hire the best people for your startup-Gitta Blat-Head of PeopleWooga
 
Two Ann(e)s and one Julia_Wooga Lady Power from Berlin_SGA2014
Two Ann(e)s and one Julia_Wooga Lady Power from Berlin_SGA2014Two Ann(e)s and one Julia_Wooga Lady Power from Berlin_SGA2014
Two Ann(e)s and one Julia_Wooga Lady Power from Berlin_SGA2014Wooga
 
Pocket Gamer Connects 2014_The Experience of Entering the Korean Market
Pocket Gamer Connects 2014_The Experience of Entering the Korean MarketPocket Gamer Connects 2014_The Experience of Entering the Korean Market
Pocket Gamer Connects 2014_The Experience of Entering the Korean MarketWooga
 

More from Wooga (20)

Story of Warlords: Bringing a turn-based strategy game to mobile
Story of Warlords: Bringing a turn-based strategy game to mobile Story of Warlords: Bringing a turn-based strategy game to mobile
Story of Warlords: Bringing a turn-based strategy game to mobile
 
Instagram Celebrities: are they the new cats? - Targetsummit Berlin 2015
Instagram Celebrities: are they the new cats? - Targetsummit Berlin 2015Instagram Celebrities: are they the new cats? - Targetsummit Berlin 2015
Instagram Celebrities: are they the new cats? - Targetsummit Berlin 2015
 
In it for the long haul - How Wooga boosts long-term retention
In it for the long haul - How Wooga boosts long-term retentionIn it for the long haul - How Wooga boosts long-term retention
In it for the long haul - How Wooga boosts long-term retention
 
Leveling up in localization! - Susan Alma & Dario Quondamstefano
Leveling up in localization! - Susan Alma & Dario QuondamstefanoLeveling up in localization! - Susan Alma & Dario Quondamstefano
Leveling up in localization! - Susan Alma & Dario Quondamstefano
 
Evoloution of Ideas
Evoloution of IdeasEvoloution of Ideas
Evoloution of Ideas
 
Entitas System Architecture with Unity - Maxim Zaks and Simon Schmid
Entitas System Architecture with Unity - Maxim Zaks and Simon Schmid Entitas System Architecture with Unity - Maxim Zaks and Simon Schmid
Entitas System Architecture with Unity - Maxim Zaks and Simon Schmid
 
Saying No to the CEO: A Deep Look at Independent Teams - Adam Telfer
Saying No to the CEO: A Deep Look at Independent Teams - Adam TelferSaying No to the CEO: A Deep Look at Independent Teams - Adam Telfer
Saying No to the CEO: A Deep Look at Independent Teams - Adam Telfer
 
Innovation dank DevOps (DevOpsCon Berlin 2015)
Innovation dank DevOps (DevOpsCon Berlin 2015)Innovation dank DevOps (DevOpsCon Berlin 2015)
Innovation dank DevOps (DevOpsCon Berlin 2015)
 
Big Fish, small pond - strategies for surviving in a maturing market - Ed Biden
Big Fish, small pond - strategies for surviving in a maturing market - Ed BidenBig Fish, small pond - strategies for surviving in a maturing market - Ed Biden
Big Fish, small pond - strategies for surviving in a maturing market - Ed Biden
 
Review mining aps2014 berlin
Review mining aps2014 berlinReview mining aps2014 berlin
Review mining aps2014 berlin
 
Riak & Wooga_Geeek2Geeek Meetup2014 Berlin
Riak & Wooga_Geeek2Geeek Meetup2014 BerlinRiak & Wooga_Geeek2Geeek Meetup2014 Berlin
Riak & Wooga_Geeek2Geeek Meetup2014 Berlin
 
Staying in the Game: Game localization practices for the mobile market
Staying in the Game: Game localization practices for the mobile marketStaying in the Game: Game localization practices for the mobile market
Staying in the Game: Game localization practices for the mobile market
 
Startup Weekend_Makers and Games_Philipp Stelzer
Startup Weekend_Makers and Games_Philipp StelzerStartup Weekend_Makers and Games_Philipp Stelzer
Startup Weekend_Makers and Games_Philipp Stelzer
 
DevOps goes Mobile (daho.am)
DevOps goes Mobile (daho.am)DevOps goes Mobile (daho.am)
DevOps goes Mobile (daho.am)
 
DevOps goes Mobile - Jax 2014 - Jesper Richter-Reichhelm
DevOps goes Mobile - Jax 2014 - Jesper Richter-ReichhelmDevOps goes Mobile - Jax 2014 - Jesper Richter-Reichhelm
DevOps goes Mobile - Jax 2014 - Jesper Richter-Reichhelm
 
CodeFest 2014_Mobile Game Development
CodeFest 2014_Mobile Game DevelopmentCodeFest 2014_Mobile Game Development
CodeFest 2014_Mobile Game Development
 
Jelly Splash: Puzzling your way to the top of the App Stores - GDC 2014
Jelly Splash: Puzzling your way to the top of the App Stores - GDC 2014Jelly Splash: Puzzling your way to the top of the App Stores - GDC 2014
Jelly Splash: Puzzling your way to the top of the App Stores - GDC 2014
 
How to hire the best people for your startup-Gitta Blat-Head of People
How to hire the best people for your startup-Gitta Blat-Head of PeopleHow to hire the best people for your startup-Gitta Blat-Head of People
How to hire the best people for your startup-Gitta Blat-Head of People
 
Two Ann(e)s and one Julia_Wooga Lady Power from Berlin_SGA2014
Two Ann(e)s and one Julia_Wooga Lady Power from Berlin_SGA2014Two Ann(e)s and one Julia_Wooga Lady Power from Berlin_SGA2014
Two Ann(e)s and one Julia_Wooga Lady Power from Berlin_SGA2014
 
Pocket Gamer Connects 2014_The Experience of Entering the Korean Market
Pocket Gamer Connects 2014_The Experience of Entering the Korean MarketPocket Gamer Connects 2014_The Experience of Entering the Korean Market
Pocket Gamer Connects 2014_The Experience of Entering the Korean Market
 

Recently uploaded

Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialJoão Esperancinha
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentMahmoud Rabie
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Nikki Chapple
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 

Recently uploaded (20)

Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorial
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career Development
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 

1,000,000 daily users and no cache

  • 2. Who  is  that  guy? Jesper  Richter-­‐Reichhelm  /  @jrirei Berlin,  Germany Head  of  Engineering  @  wooga
  • 4. Wooga  has  dedicated  game  teams Cooming soon PHP Ruby Ruby Erlang Cloud Cloud Bare  metal Cloud
  • 5. Flash  client  sends  state  changes  to  backend Flash  client Ruby  backend
  • 6. Social  games  need  to  scale  quite  a  bit 1  million  daily  users 200  million  daily  HTTP  requests
  • 7. Social  games  need  to  scale  quite  a  bit 1  million  daily  users 200  million  daily  HTTP  requests 100,000  DB  operaGons  per  second 40,000  DB  updates  per  second
  • 8. Social  games  need  to  scale  quite  a  bit 1  million  daily  users 200  million  daily  HTTP  requests 100,000  DB  operaGons  per  second 40,000  DB  updates  per  second …  but  no  cache
  • 9. A  journey  to  1,000,000  daily  users Start  of  the  journey 6  weeks  of  pain Paradise Looking  back
  • 10. We  used  two  MySQL  shards  right  from  the  start data_fabric  gem Easy  to  use Sharding  by  Facebook’s  user  id Sharding  on  controller  level
  • 11. Scaling  applicaLon  servers  was  very  easy Running  at  Amazon  EC2 Scalarium  for  automaGon  and  deployment Role  based Chef  recipes  for  customiza5on Scaling  app  servers  up  and  out  was  simple
  • 12. Master-­‐slave  replicaLon  for  DBs  worked  fine lb app app app db db db db slave slave
  • 13. We  added  a  few  applicaLon  servers  over  Lme lb app app app app app app app app app db db db db slave slave
  • 14. Basic  setup  worked  well  for  3  months May Jun Jul Aug Sep Oct Nov Dec
  • 15. A  journey  to  1,000,000  daily  users Start  of  the  journey 6  weeks  of  pain Paradise Looking  back
  • 16. SQL  queries  generated  by  Rubyamf  gem Rubyamf  serializes  returned  objects Wrong  config  =>  it  also  loads  associaGons
  • 17. SQL  queries  generated  by  Rubyamf  gem Rubyamf  serializes  returned  objects Wrong  config  =>  it  also  loads  associaGons Really  bad  but  very  easy  to  fix
  • 18. New  Relic  shows  what  happens  during  an  API  call
  • 19. More  traffic  using  the  same  cluster lb app app app app app app app app app db db db db slave slave
  • 20. Our  DB  problems  began May Jun Jul Aug Sep Oct Nov Dec
  • 21. MySQL  hiccups  were  becoming  more  frequent Everything  was  running  fine  ... ...  and  then  DB  throughput  went  down  to  10% A]er  a  few  minutes  everything  stabilizes  again  ... ...  just  to  repeat  the  cycle  20  minutes  later!
  • 22. AcLveRecord’s  checks  caused  20%  extra  DB  load Check  connecGon  state  before  each  SQL  query MySQL  process  list  full  of  ‘status’  calls
  • 23. AcLveRecord’s  status  checks  caused  20%  extra  DB   Check  connecGon  state  before  each  SQL  query MySQL  process  list  full  of  ‘status’  calls
  • 24. I/O  on  MySQL  masters  sLll  was  the  boYleneck New  Relic  shows  DB  table  usage 60%  of  all  UPDATEs  were  done  on  the  ‘Gles’  table
  • 25. New  Relic  shows  most  used  tables
  • 26. Tiles  are  part  of  the  core  game  loop Core  game  loop: 1)  plant 2)  wait 3)  harvest All  are   operaGons on  Tiles  table.
  • 27. We  started  to  shard  on  model,  too We  put  this  table  in  2  extra  shards old   old   master slave
  • 28. We  started  to  shard  on  model,  too We  put  this  table  in  2  extra  shards 1)  Setup  new  masters  as  slaves  of  old  ones old   old   new   master slave master
  • 29. We  started  to  shard  on  model,  too We  put  this  table  in  2  extra  shards 1)  Setup  new  masters  as  slaves  of  old  ones old   old   new   new   master slave master slave
  • 30. We  started  to  shard  on  model,  too We  put  this  table  in  2  extra  shards 1)  Setup  new  masters  as  slaves  of  old  ones 2)  App  servers  start  using  new  masters,  too old   old   new   new   master slave master slave
  • 31. We  started  to  shard  on  model,  too We  put  this  table  in  2  extra  shards 1)  Setup  new  masters  as  slaves  of  old  ones 2)  App  servers  start  using  new  masters,  too 3)  Cut  replica5on old   old   new   new   master slave master slave
  • 32. We  started  to  shard  on  model,  too We  put  this  table  in  2  extra  shards 1)  Setup  new  masters  as  slave  of  old  ones 2)  App  servers  start  using  new  masters,  too 3)  Cut  replica5on 4)  Truncate  not-­‐used  tables old   old   new   new   master slave master slave
  • 33. 8  DBs  and  a  few  more  servers lb app app app app app app app app app app app app app app app app 5les 5les db db db db db db 5les 5les slave slave slave slave
  • 34. Doubling  the  amount  of  DBs  didn’t  fix  it May Jun Jul Aug Sep Oct Nov Dec
  • 35. We  improved  our  MySQL  setup RAID-­‐0  of  EBS  volumes Using  XtraDB  instead  of  vanilla  MySQL Tweaking  my.cnf innodb_flush_log_at_trx_commit innodb_flush_method
  • 36. Data-­‐fabric  gem  circumvented  AR’s  internal  cache 2x  Tile.find_by_id(id)  =>  1x  SELECT  …
  • 37. Data-­‐fabric  gem  circumvented  AR’s  internal  cache 2x  Tile.find_by_id(id)  =>  1x  SELECT  …
  • 38. 2  +  2  masters  and  sLll  I/O  was  not  fast  enough We  were  geing  desperate: “If  2  +  2  is  not  enough,  ... …  perhaps  4  +  4  masters  will  do?”
  • 39. It’s  no  fun  to  handle  16  MySQL  DBs lb app app app app app app app app app app app app app app app app app app 5les 5les db db db db db db 5les 5les slave slave slave slave
  • 40. It’s  no  fun  to  handle  16  MySQL  DBs lb app app app app app app app app app app app app app app app app app app 5les 5les 5les 5les db db db db db db db db db db db db 5les 5les 5les 5les slave slave slave slave slave slave slave slave
  • 41. We  were  at  a  dead  end  with  MySQL May Jun Jul Aug Sep Oct Nov Dec
  • 42. I/O  remained  the  boYleneck  for  MySQL  UPDATEs Peak  throughput  overall:  5,000  writes/s Peak  throughput  single  master:  850  writes/s We  could  get  to  ~1,000  writes/s  … …  but  then  what?
  • 43. Pick  the  right  tool  for  the  job!
  • 44. Redis  is  fast  but  goes  beyond  simple  key/value Redis  is  a  key-­‐value  store Hashes,  Sets,  Sorted  Sets,  Lists Atomic  opera5ons  like  set,  get,  increment 50,000  transacGons/s  on  EC2 Writes  are  as  fast  as  reads
  • 45. Shelf  Lles  :  An  ideal  candidate  for  using  Redis   Shelf  Lles: {  plant1  =>  184, plant2  =>  141, plant3  =>  130, plant4  =>  112, …  }
  • 46. Shelf  Lles  :  An  ideal  candidate  for  using  Redis   Redis  Hash HGETALL:  load  whole  hash HGET:  load  a  single  key HSET:  set  a  single  key HINCRBY:  increase  value  of  single  key …
  • 47. Migrate  on  the  fly  when  accessing  new  model
  • 48. Migrate  on  the  fly  -­‐  but  only  once true  if  id  could  be  added else  false
  • 49. Migrate  on  the  fly  -­‐  and  clean  up  later 1. Let  this  running  everything  cools  down 2. Then  migrate  the  rest  manually 3. Remove  the  migraGon  code 4. Wait  unGl  no  fallback  necessary 5. Remove  the  SQL  table
  • 50. MigraLons  on  the  fly  all  look  the  same Typical  migraGon  throughput  over  3  days Ini5al  peak  at  100  migra5ons  /  second
  • 51. A  journey  to  1,000,000  daily  users Start  of  the  journey 6  weeks  of  pain Paredise  (or  not?) Looking  back
  • 52. Again:  Tiles  are  part  of  the  core  game  loop Core  game  loop: 1)  plant 2)  wait 3)  harvest All  are   operaGons on  Tiles  table.
  • 53. Size  maYers  for  migraLons MigraGon  check  overloaded  Redis Migra5on  only  on  startup We  overlooked  an  edge  case Next  5me  only  migrate  1%  of  users Migrate  the  rest  when  everything  worked  out
  • 54. In-­‐memory  DBs  don’t  like  to  saving  to  disk You  sGll  need  to  write  data  to  disk  eventually SAVE  is  blocking BGSAVE  needs  free  RAM Dumping  on  master  increased  latency  by  100%
  • 55. In-­‐memory  DBs  don’t  like  to  dump  to  disk You  sGll  need  to  write  data  to  disk  eventually SAVE  is  blocking BGSAVE  needs  free  RAM Dumping  on  master  increased  latency  by  100% Running  BGSAVE  slaves  every  15  minutes
  • 56. ReplicaLon  puts  Redis  master  under  load ReplicaGon  on  master  starts  with  a  BGSAVE Not  enough  free  RAM  =>  big  problem Master  queue  requests  that  slave  cannot  process Restoring  dump  on  slaves  is  blocking
  • 57. Redis  has  a  memory  fragmenLon  problem 44  GB in  8  days 24  GB
  • 58. Redis  has  a  memory  fragmenLon  problem 38  GB in  3  days 24  GB
  • 59. If  MySQL  is  a  truck... Fast  enough  for  reads Can  store  on  disk Robust  replicaGon hp://www.flickr.com/photos/erix/245657047/
  • 60. If  MySQL  is  a  truck,  Redis  is  a  Ferrari Fast  enough  for  reads Super  fast  reads/writes Can  store  on  disk Out  of  memory  =>  dead Robust  replicaGon Fragile  replicaGon hp://www.flickr.com/photos/erix/245657047/
  • 61. Big    and  staLc  data  in  MySQL,  rest  goes  to  Redis Fast  enough  for  reads Super  fast  reads/writes Can  store  on  disk Out  of  memory  =>  dead Robust  replicaGon Fragile  replicaGon 256  GB  data 60  GB  data 10%  writes 50%  writes hp://www.flickr.com/photos/erix/245657047/
  • 62. 95%  of  operaLon  effort  is  handling  DBs! lb lb app app app app app app app app app app app app app app app app app app app app app app app app app app app app app app app app app app app app app app app db db db db db redis redis redis redis redis db db db db db redis redis redis redis redis slave slave slave slave slave slave slave slave slave slave
  • 63. We  fixed  all  our  problem  -­‐  we  were  in  Paradise! May Jun Jul Aug Sep Oct Nov Dec
  • 64. A  journey  to  1,000,000  daily  users Start  of  the  journey 6  weeks  of  pain Paredise  (or  not?) Looking  back
  • 65. Data  handling  is  most  important How  much  data  will  you  have? How  o]en  will  you  read/update  that  data? What  data  is  in  the  client,  what  in  the  server? It’s  hard  to  “refactor”  data  later  on
  • 66. Monitor  and  measure  your  applicaLon  closely On  applicaGon  level  /  on  OS  level Learn  your  app’s  normal  behavior Store  historical  data  so  you  can  compare  later React  if  necessary!
  • 67. Listen  closely  and  answer  truthfully Q  &  A Jesper  Richter-­‐Reichhelm @jrirei slideshare.net/wooga
  • 68. If  you  are  in  Berlin  just  drop  by Thank  you Jesper  Richter-­‐Reichhelm @jrirei slideshare.net/wooga