SlideShare a Scribd company logo
1 of 58
Download to read offline
Getting real with erlang
                             From the idea to a live system

                               Knut Nesheim @knutin
                              Paolo Negri @hungryblank




Thursday, November 3, 2011
Social Games
              Flash client (game)                                             HTTP API




                             http://www.flickr.com/photos/theplanetdotcom/4879421344
Thursday, November 3, 2011
Social Games
                                       HTTP API



• @ 1 000 000 daily users
• 5000 HTTP reqs/sec
• more than 90% writes

Thursday, November 3, 2011
November 2010

                    • At the erlang user group!
                    • Learn where/how erlang is used
                    • 0 lines of erlang code across all
                             @wooga code base



Thursday, November 3, 2011
Why looking into
                                 erlang?
                                         HTTP API



• @ 1 000 000 daily users
• 5000 HTTP reqs/sec
• around 60000 queries/sec

Thursday, November 3, 2011
60000 qps

                    • Most maintenance effort in databases
                    • mix of SQL / NoSQL
                    • Already using in RAM data stores (REDIS)
                    • RAM DB are fast but expensive / high
                             maintenance



Thursday, November 3, 2011
Social games data

            • User data self contained
            • Strong hot/cold pattern - gaming session
            • Heavy write load (caching is ineffective)

Thursday, November 3, 2011
User session                    User data

             1. start session   1. load all
             2. game actions    2. read/update many times
             3. end session     3. data becomes cold



Thursday, November 3, 2011
User session              Erlang process

             1. start session   1. start (load state)

             2. game actions    2. responds to messages
                                   (use state)
             3. end session
                                3. stop (save state)



Thursday, November 3, 2011
User session DB usage

                                                 Stateful server
                                Stateless server
                                                    (Erlang )
       start session             load user state load user state
      game actions               many queries

        end session                              save user state


Thursday, November 3, 2011
Erlang process

                    • Follows session lifecycle
                    • Contains and defends state (data)
                    • Acts as a lock/serializer (one message
                             at a time)



Thursday, November 3, 2011
December 2010
                    • Prototype
                                              erlang
              user1          user2   user3   process   = user session


             user4           user5   user6



              user7          user8   userN




Thursday, November 3, 2011
January 2011
                    • erlang team goes from 1 to 2 developers
                                Open topics
                  • Distribution/clustering
                  • Error handling
                  • Deployments
                  • Operations
Thursday, November 3, 2011
Architecture




Thursday, November 3, 2011
Architecture  goals
       • Move  data  into  the  applica4on  server
       • Be  as  simple  as  possible
       • Graceful  degrada4on  when  DBs  go  down
       • Easy  to  inspect  and  repair  state  of  cluster
       • Easy  to  add  more  machines  for  scaling  out




                                                              15

Thursday, November 3, 2011
Session
                              Session
                               Session




                                         16

Thursday, November 3, 2011
Worker
                             Session
                              Session
                               Session




                                         17

Thursday, November 3, 2011
Worker             Worker      Worker
          Session
           Session           Session
                              Session    Session
                                          Session
            Session            Session     Session




                                                     18

Thursday, November 3, 2011
Worker
                               Worker
                                Worker
                             Session
                              Session
                              Session
                               Session
                               Session
                                Session
                                 Session

               Coordinator
               Coordinator


                                           19

Thursday, November 3, 2011
Worker
                               Worker
                                Worker
                             Session
                              Session
                              Session
                               Session
                               Session
                                Session
                                 Session

               Coordinator
               Coordinator                 Lock


                                                  20

Thursday, November 3, 2011
Worker
                               Worker
                                Worker
                             Session
                              Session
                              Session
                               Session
                               Session
                                Session
                                 Session

               Coordinator
               Coordinator                 Lock

                                DBs
                                                  21

Thursday, November 3, 2011
New  user  comes  online


                                  Worker
                                   Worker
                                    Worker
                                 Session
                                  Session
                                  Session
                                   Session
                                   Session
                                    Session
                                     Session
       Coordinator

                                                        Lock

                                     DBs
                                                               22

Thursday, November 3, 2011
New  user  comes  online


                                                 Worker
                                                  Worker
                    Flash  calls  ”setup”
                                                   Worker
                                                Session
                                                 Session
                                                 Session
                                                  Session
                                                  Session
                                                   Session
                                                    Session
       Coordinator

                                                                       Lock

                                                    DBs
                                                                              22

Thursday, November 3, 2011
New  user  comes  online


                                                 Worker
                                                  Worker
                    Flash  calls  ”setup”
                                                   Worker
                                                Session
                                                 Session
                                                 Session
                                                  Session
                                                  Session
                                                   Session
                                                    Session
       Coordinator
                session:start(Uid)
                on  suitable  worker                                   Lock

                                                    DBs
                                                                              22

Thursday, November 3, 2011
New  user  comes  online


                                                 Worker
                                                  Worker
                    Flash  calls  ”setup”
                                                   Worker
                                                Session
                                                 Session
                                                 Session
                                                  Session
                                                  Session
                                                   Session
                                                    Session
       Coordinator
                session:start(Uid)                     s3:get(Uid)
                on  suitable  worker                                   Lock

                                                    DBs
                                                                              22

Thursday, November 3, 2011
New  user  comes  online


                                                 Worker
                                                  Worker
                    Flash  calls  ”setup”
                                                   Worker
                                                Session
                                                 Session
                                                 Session
                                                  Session
                                                  Session
                                                   Session
                                                    Session            lock:acquire(Uid)
       Coordinator                                                     test-­‐and-­‐set


                session:start(Uid)                     s3:get(Uid)
                on  suitable  worker                                        Lock

                                                    DBs
                                                                                           22

Thursday, November 3, 2011
New  user  comes  online

                                                                              Game  acFons  

                                                 Worker
                                                                              from  Flash

                                                  Worker
                                                   Worker
                    Flash  calls  ”setup”
                                                Session
                                                 Session
                                                 Session
                                                  Session
                                                  Session
                                                   Session
                                                    Session            lock:acquire(Uid)
       Coordinator                                                     test-­‐and-­‐set


                session:start(Uid)                     s3:get(Uid)
                on  suitable  worker                                        Lock

                                                    DBs
                                                                                           22

Thursday, November 3, 2011
User  goes  offline  (session  Fmes  out)


                                           Worker
                                            Worker
                                             Worker
 gen_server  Fmeout
                                          Session
                                           Session
                                           Session
                                            Session
                                            Session
                                             Session
                                              Session            lock:release/1



                                                  s3:put/1
               Coordinator                                             Lock

                                              DBs
                                                                                  23

Thursday, November 3, 2011
Implementa4on  of  game  logic




Thursday, November 3, 2011
Dream  game  logic

                             Fast                Safe


                                        +




                                                        25

Thursday, November 3, 2011
Dream  game  logic




                                                  26

Thursday, November 3, 2011
Dream  game  logic
       • We  want  high  throughput  (for  scaling)
             – Try  to  spend  as  liPle  CPU  Fme  as  possible
             – Avoid  heavy  computaFon
             – Try  to  avoid  creaFng  garbage
       • ..and  simple  and  testable  logic  (correctness)
             – FuncFonal  game  logic  makes  thinking  about  code  easy
             – Single  entry  point,  gets  ”request”  and  game  state
             – Code  for  happy  case,  roll  back  on  game-­‐related  excepFon



                                                                                   27

Thursday, November 3, 2011
How  we  avoid  using  CPU
       • Remove  need  for  DB  serializaFon  by  storing  data  in  
         process
       • Game  is  designed  to  avoid  heavy  liXing  in  the  backend,  
         very  simple  game  logic
       • OpFmize  hot  parts  on  the  criFcal  path,  like  collision  
         detecFon,  regrowing  of  forest
       • Generate  erlang  modules  for  read-­‐heavy  configuraFon  
         (~1  billion  reads/1  write  per  week)
       • Use  NIFs  for  parsing  JSON  (jiffy)

                                                                        28

Thursday, November 3, 2011
How  to  find  where  CPU  is  used
       • Profile  (eprof,  fprof,  kprof[1])
       • Measure  garbage  collecFon  (process_info/1,  gcprof[2])
       • Conduct  experiment:  change  code,  measure,  repeat
       • Is  the  increased  performance  worth  the  increase  in  
         complexity?
       • SomeFmes  a  radically  different  approach  is  needed..


            [1]:  github.com/knuFn/kprof
            [2]:  github.com/knuFn/gcprof

                                                                       29

Thursday, November 3, 2011
Opera4ons
                             August  2011  -­‐  ...




Thursday, November 3, 2011
Opera4ons
       • At  wooga,  developers  also  operate  the  game
       • Most  developers  are  ex-­‐sysadmins
       • Simple  tools:
             –remsh  for  deployments,  maintenance,  debugging
             –automaFon  with  chef
             –syslog,  tail,  cut,  awk,  grep
             –verbose  crash  logs  (SASL)
             –alarms  only  when  something  really  bad  happens

                                                                    31

Thursday, November 3, 2011
Deployments
       • Goal:  upgrade  without  annoying  users
       • SoT  purge
       • Set  system  quiet  (webserver  &  coordinator)
       • Reload
       • Open  the  flood  gates
       • Migrate  process  memory  state  on-­‐demand
       • Total  4me  not  answering  game  requests:  <  1s

                                                              32

Thursday, November 3, 2011
How  we  know  what’s  going  on
       • Event  logging  to  syslog
             – Session  start,  session  end  (process  memory,  gc,  game  stats)
             – Game-­‐related  excepFons
       • Latency  measurement  within  the  app
       • Use  munin  to  pull  overall  server  stats
             – CPU  and  memory  usage  by  beam.smp
             – Memory  used  by  processes,  ets  tables,  etc
             – Throughput  of  app,  dbs
             – Throughput  of  coordinator,  workers,  lock


                                                                                     33

Thursday, November 3, 2011
How  we  know  what’s  going  on




         Game  error:  The  game  acFon  is  not  allowed  with  the  current  server  state  and  configuraFon




                                                                                                                 34

Thursday, November 3, 2011
How  we  know  what’s  going  on




                    Half-­‐word  emulator




                                                       35

Thursday, November 3, 2011
How  we  know  what’s  going  on




                                                       36

Thursday, November 3, 2011
How  we  know  what’s  going  on




                                                       37

Thursday, November 3, 2011
How  we  know  what’s  going  on




                                                       38

Thursday, November 3, 2011
How  we  know  what’s  going  on




                                                       39

Thursday, November 3, 2011
Conclusions




Thursday, November 3, 2011
Conclusions  -­‐  database
                              Ruby Stateless           Erlang Stateful

          30000
          22500
          15000
             7500                                            700
                     0
                                         queries/sec



                                                                         41

Thursday, November 3, 2011
Conclusions
                                Db  maintenace
                             AWS  S3  as  a  main  datastore
                                  one  document/user
                              0  maintenance/setup  cost

              Redis  for  the  derived  data  (leaderboard  etc.)
                 load  very  far  from  Redis  max  capacity

                                                                42

Thursday, November 3, 2011
Conclusions
                             data  locality

       • average  game  call  <  1ms
       • no  db  roundtrip  at  every  request
       • no  need  for  low  latency  network
       • efficient  setup  for  cloud  environment



                                                   43

Thursday, November 3, 2011
Conclusions
                             data  locality

       • finally  CPU  bound
       • no  CPU  4me  for  serializing/deserializing  data  
         from  db
       • CPU  only  busy  transforming  data  (minimum  
         possible  ac4vity)



                                                                44

Thursday, November 3, 2011
Conclusions
                              CPU  usage

       • 300K  daily  users
       • 1000  hcp  req/sec  (game  ac4ons)
       • 4  m1.large  AWS  instances  (dual  core  8GB  RAM)
       • 2  instances  (coordinators)  5%  CPU  load
       • 2  instances  (workers)  20%  CPU  load


                                                               45

Thursday, November 3, 2011
Conclusions
                                  extra  benefits

                             en4re  user  state  in  one  process
                                              +
                                      immutability
                                              =
                                 Transac4onal  behavior


                                                                    46

Thursday, November 3, 2011
Conclusions
                                       extra  benefits

                             One  user  session  -­‐>  one  erlang  process
                               The  erlang  VM  is  aware  of  processes
                                                    =>
                             the  erlang  VM  is  aware  of  user  sessions



                                                                              47

Thursday, November 3, 2011
Conclusions

                  Thanks  to  VM  process  introspec4on
               process  reduc4ons  -­‐>  cost  of  a  game  ac4on
            process  used  memory  -­‐>  memory  used  by  session

          We  gained  a  lot  of  knowledge  about  a  fundamental  
                               ”business”  en4ty

                                                                 48

Thursday, November 3, 2011
Conclusions

       • a  radical  change  was  made  possible  by  a  radically  
         different  tool  (erlang)




                                                                   49

Thursday, November 3, 2011
Conclusions

       • a  radical  change  was  made  possible  by  a  radically  
         different  tool  (erlang)
       • erlang  can  be  good  for  data  intensive/high  
         throughput  applica4ons




                                                                   49

Thursday, November 3, 2011
Conclusions

       • a  radical  change  was  made  possible  by  a  radically  
         different  tool  (erlang)
       • erlang  can  be  good  for  data  intensive/high  
         throughput  applica4ons
       • stateful  is  not  necessarily  hard/dangerous/
         unmaintainable

                                                                   49

Thursday, November 3, 2011
Conclusions

       • november  2010:  0  lines  of  erlang  @wooga
       • november  2011:  1  erlang  game  server  live

       ...with  more  erlang  coming,  join  us




                                                          50

Thursday, November 3, 2011
Q&A
                               Knut Nesheim @knutin
                              Paolo Negri @hungryblank


                             hPp://wooga.com/jobs

                                                         51

Thursday, November 3, 2011

More Related Content

Viewers also liked

Comparing Cpp And Erlang For Motorola Telecoms Software
Comparing Cpp And Erlang For Motorola Telecoms SoftwareComparing Cpp And Erlang For Motorola Telecoms Software
Comparing Cpp And Erlang For Motorola Telecoms Softwarel xf
 
Benchmarks, performance, scalability, and capacity what's behind the numbers
Benchmarks, performance, scalability, and capacity what's behind the numbersBenchmarks, performance, scalability, and capacity what's behind the numbers
Benchmarks, performance, scalability, and capacity what's behind the numbersJustin Dorfman
 
Erlang as a Cloud Citizen
Erlang as a Cloud CitizenErlang as a Cloud Citizen
Erlang as a Cloud CitizenWooga
 
Getting the Most our of your Tools_FrontEnd DevConf2013_Minsk
Getting the Most our of your Tools_FrontEnd DevConf2013_MinskGetting the Most our of your Tools_FrontEnd DevConf2013_Minsk
Getting the Most our of your Tools_FrontEnd DevConf2013_MinskWooga
 
Stateful Application Server_JRubyConf13_Lukas Rieder
Stateful Application Server_JRubyConf13_Lukas RiederStateful Application Server_JRubyConf13_Lukas Rieder
Stateful Application Server_JRubyConf13_Lukas RiederWooga
 
NoSQL Games_NoSQL Roadshow Berlin
NoSQL Games_NoSQL Roadshow BerlinNoSQL Games_NoSQL Roadshow Berlin
NoSQL Games_NoSQL Roadshow BerlinWooga
 
JRubyConf2013_Tim Lossen_All your core
JRubyConf2013_Tim Lossen_All your coreJRubyConf2013_Tim Lossen_All your core
JRubyConf2013_Tim Lossen_All your coreWooga
 
Designing for Scale
Designing for ScaleDesigning for Scale
Designing for ScaleWooga
 
Architecture Evolution at Wooga (AWS Cloud Computing for Developers,)
Architecture Evolution at Wooga (AWS Cloud Computing for Developers,)Architecture Evolution at Wooga (AWS Cloud Computing for Developers,)
Architecture Evolution at Wooga (AWS Cloud Computing for Developers,)Wooga
 
When Devs Do Ops
When Devs Do OpsWhen Devs Do Ops
When Devs Do OpsWooga
 
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
 
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
 
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
 
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
 
Stateful_Application_Server_RuPy 2012_Brno
Stateful_Application_Server_RuPy 2012_BrnoStateful_Application_Server_RuPy 2012_Brno
Stateful_Application_Server_RuPy 2012_BrnoWooga
 

Viewers also liked (17)

Comparing Cpp And Erlang For Motorola Telecoms Software
Comparing Cpp And Erlang For Motorola Telecoms SoftwareComparing Cpp And Erlang For Motorola Telecoms Software
Comparing Cpp And Erlang For Motorola Telecoms Software
 
Benchmarks, performance, scalability, and capacity what's behind the numbers
Benchmarks, performance, scalability, and capacity what's behind the numbersBenchmarks, performance, scalability, and capacity what's behind the numbers
Benchmarks, performance, scalability, and capacity what's behind the numbers
 
Erlang as a Cloud Citizen
Erlang as a Cloud CitizenErlang as a Cloud Citizen
Erlang as a Cloud Citizen
 
Getting the Most our of your Tools_FrontEnd DevConf2013_Minsk
Getting the Most our of your Tools_FrontEnd DevConf2013_MinskGetting the Most our of your Tools_FrontEnd DevConf2013_Minsk
Getting the Most our of your Tools_FrontEnd DevConf2013_Minsk
 
Stateful Application Server_JRubyConf13_Lukas Rieder
Stateful Application Server_JRubyConf13_Lukas RiederStateful Application Server_JRubyConf13_Lukas Rieder
Stateful Application Server_JRubyConf13_Lukas Rieder
 
NoSQL Games_NoSQL Roadshow Berlin
NoSQL Games_NoSQL Roadshow BerlinNoSQL Games_NoSQL Roadshow Berlin
NoSQL Games_NoSQL Roadshow Berlin
 
JRubyConf2013_Tim Lossen_All your core
JRubyConf2013_Tim Lossen_All your coreJRubyConf2013_Tim Lossen_All your core
JRubyConf2013_Tim Lossen_All your core
 
Designing for Scale
Designing for ScaleDesigning for Scale
Designing for Scale
 
Architecture Evolution at Wooga (AWS Cloud Computing for Developers,)
Architecture Evolution at Wooga (AWS Cloud Computing for Developers,)Architecture Evolution at Wooga (AWS Cloud Computing for Developers,)
Architecture Evolution at Wooga (AWS Cloud Computing for Developers,)
 
When Devs Do Ops
When Devs Do OpsWhen Devs Do Ops
When Devs Do Ops
 
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)
 
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)
 
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
 
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
 
Stateful_Application_Server_RuPy 2012_Brno
Stateful_Application_Server_RuPy 2012_BrnoStateful_Application_Server_RuPy 2012_Brno
Stateful_Application_Server_RuPy 2012_Brno
 

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

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
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
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
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
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
 
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
 
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
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
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
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 

Recently uploaded (20)

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
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
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
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
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...
 
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
 
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...
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
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
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
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
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 

Getting real with Erlang: From the idea to a live system

  • 1. Getting real with erlang From the idea to a live system Knut Nesheim @knutin Paolo Negri @hungryblank Thursday, November 3, 2011
  • 2. Social Games Flash client (game) HTTP API http://www.flickr.com/photos/theplanetdotcom/4879421344 Thursday, November 3, 2011
  • 3. Social Games HTTP API • @ 1 000 000 daily users • 5000 HTTP reqs/sec • more than 90% writes Thursday, November 3, 2011
  • 4. November 2010 • At the erlang user group! • Learn where/how erlang is used • 0 lines of erlang code across all @wooga code base Thursday, November 3, 2011
  • 5. Why looking into erlang? HTTP API • @ 1 000 000 daily users • 5000 HTTP reqs/sec • around 60000 queries/sec Thursday, November 3, 2011
  • 6. 60000 qps • Most maintenance effort in databases • mix of SQL / NoSQL • Already using in RAM data stores (REDIS) • RAM DB are fast but expensive / high maintenance Thursday, November 3, 2011
  • 7. Social games data • User data self contained • Strong hot/cold pattern - gaming session • Heavy write load (caching is ineffective) Thursday, November 3, 2011
  • 8. User session User data 1. start session 1. load all 2. game actions 2. read/update many times 3. end session 3. data becomes cold Thursday, November 3, 2011
  • 9. User session Erlang process 1. start session 1. start (load state) 2. game actions 2. responds to messages (use state) 3. end session 3. stop (save state) Thursday, November 3, 2011
  • 10. User session DB usage Stateful server Stateless server (Erlang ) start session load user state load user state game actions many queries end session save user state Thursday, November 3, 2011
  • 11. Erlang process • Follows session lifecycle • Contains and defends state (data) • Acts as a lock/serializer (one message at a time) Thursday, November 3, 2011
  • 12. December 2010 • Prototype erlang user1 user2 user3 process = user session user4 user5 user6 user7 user8 userN Thursday, November 3, 2011
  • 13. January 2011 • erlang team goes from 1 to 2 developers Open topics • Distribution/clustering • Error handling • Deployments • Operations Thursday, November 3, 2011
  • 15. Architecture  goals • Move  data  into  the  applica4on  server • Be  as  simple  as  possible • Graceful  degrada4on  when  DBs  go  down • Easy  to  inspect  and  repair  state  of  cluster • Easy  to  add  more  machines  for  scaling  out 15 Thursday, November 3, 2011
  • 16. Session Session Session 16 Thursday, November 3, 2011
  • 17. Worker Session Session Session 17 Thursday, November 3, 2011
  • 18. Worker Worker Worker Session Session Session Session Session Session Session Session Session 18 Thursday, November 3, 2011
  • 19. Worker Worker Worker Session Session Session Session Session Session Session Coordinator Coordinator 19 Thursday, November 3, 2011
  • 20. Worker Worker Worker Session Session Session Session Session Session Session Coordinator Coordinator Lock 20 Thursday, November 3, 2011
  • 21. Worker Worker Worker Session Session Session Session Session Session Session Coordinator Coordinator Lock DBs 21 Thursday, November 3, 2011
  • 22. New  user  comes  online Worker Worker Worker Session Session Session Session Session Session Session Coordinator Lock DBs 22 Thursday, November 3, 2011
  • 23. New  user  comes  online Worker Worker Flash  calls  ”setup” Worker Session Session Session Session Session Session Session Coordinator Lock DBs 22 Thursday, November 3, 2011
  • 24. New  user  comes  online Worker Worker Flash  calls  ”setup” Worker Session Session Session Session Session Session Session Coordinator session:start(Uid) on  suitable  worker Lock DBs 22 Thursday, November 3, 2011
  • 25. New  user  comes  online Worker Worker Flash  calls  ”setup” Worker Session Session Session Session Session Session Session Coordinator session:start(Uid) s3:get(Uid) on  suitable  worker Lock DBs 22 Thursday, November 3, 2011
  • 26. New  user  comes  online Worker Worker Flash  calls  ”setup” Worker Session Session Session Session Session Session Session lock:acquire(Uid) Coordinator test-­‐and-­‐set session:start(Uid) s3:get(Uid) on  suitable  worker Lock DBs 22 Thursday, November 3, 2011
  • 27. New  user  comes  online Game  acFons   Worker from  Flash Worker Worker Flash  calls  ”setup” Session Session Session Session Session Session Session lock:acquire(Uid) Coordinator test-­‐and-­‐set session:start(Uid) s3:get(Uid) on  suitable  worker Lock DBs 22 Thursday, November 3, 2011
  • 28. User  goes  offline  (session  Fmes  out) Worker Worker Worker gen_server  Fmeout Session Session Session Session Session Session Session lock:release/1 s3:put/1 Coordinator Lock DBs 23 Thursday, November 3, 2011
  • 29. Implementa4on  of  game  logic Thursday, November 3, 2011
  • 30. Dream  game  logic Fast Safe + 25 Thursday, November 3, 2011
  • 31. Dream  game  logic 26 Thursday, November 3, 2011
  • 32. Dream  game  logic • We  want  high  throughput  (for  scaling) – Try  to  spend  as  liPle  CPU  Fme  as  possible – Avoid  heavy  computaFon – Try  to  avoid  creaFng  garbage • ..and  simple  and  testable  logic  (correctness) – FuncFonal  game  logic  makes  thinking  about  code  easy – Single  entry  point,  gets  ”request”  and  game  state – Code  for  happy  case,  roll  back  on  game-­‐related  excepFon 27 Thursday, November 3, 2011
  • 33. How  we  avoid  using  CPU • Remove  need  for  DB  serializaFon  by  storing  data  in   process • Game  is  designed  to  avoid  heavy  liXing  in  the  backend,   very  simple  game  logic • OpFmize  hot  parts  on  the  criFcal  path,  like  collision   detecFon,  regrowing  of  forest • Generate  erlang  modules  for  read-­‐heavy  configuraFon   (~1  billion  reads/1  write  per  week) • Use  NIFs  for  parsing  JSON  (jiffy) 28 Thursday, November 3, 2011
  • 34. How  to  find  where  CPU  is  used • Profile  (eprof,  fprof,  kprof[1]) • Measure  garbage  collecFon  (process_info/1,  gcprof[2]) • Conduct  experiment:  change  code,  measure,  repeat • Is  the  increased  performance  worth  the  increase  in   complexity? • SomeFmes  a  radically  different  approach  is  needed.. [1]:  github.com/knuFn/kprof [2]:  github.com/knuFn/gcprof 29 Thursday, November 3, 2011
  • 35. Opera4ons August  2011  -­‐  ... Thursday, November 3, 2011
  • 36. Opera4ons • At  wooga,  developers  also  operate  the  game • Most  developers  are  ex-­‐sysadmins • Simple  tools: –remsh  for  deployments,  maintenance,  debugging –automaFon  with  chef –syslog,  tail,  cut,  awk,  grep –verbose  crash  logs  (SASL) –alarms  only  when  something  really  bad  happens 31 Thursday, November 3, 2011
  • 37. Deployments • Goal:  upgrade  without  annoying  users • SoT  purge • Set  system  quiet  (webserver  &  coordinator) • Reload • Open  the  flood  gates • Migrate  process  memory  state  on-­‐demand • Total  4me  not  answering  game  requests:  <  1s 32 Thursday, November 3, 2011
  • 38. How  we  know  what’s  going  on • Event  logging  to  syslog – Session  start,  session  end  (process  memory,  gc,  game  stats) – Game-­‐related  excepFons • Latency  measurement  within  the  app • Use  munin  to  pull  overall  server  stats – CPU  and  memory  usage  by  beam.smp – Memory  used  by  processes,  ets  tables,  etc – Throughput  of  app,  dbs – Throughput  of  coordinator,  workers,  lock 33 Thursday, November 3, 2011
  • 39. How  we  know  what’s  going  on Game  error:  The  game  acFon  is  not  allowed  with  the  current  server  state  and  configuraFon 34 Thursday, November 3, 2011
  • 40. How  we  know  what’s  going  on Half-­‐word  emulator 35 Thursday, November 3, 2011
  • 41. How  we  know  what’s  going  on 36 Thursday, November 3, 2011
  • 42. How  we  know  what’s  going  on 37 Thursday, November 3, 2011
  • 43. How  we  know  what’s  going  on 38 Thursday, November 3, 2011
  • 44. How  we  know  what’s  going  on 39 Thursday, November 3, 2011
  • 46. Conclusions  -­‐  database Ruby Stateless Erlang Stateful 30000 22500 15000 7500 700 0 queries/sec 41 Thursday, November 3, 2011
  • 47. Conclusions Db  maintenace AWS  S3  as  a  main  datastore one  document/user 0  maintenance/setup  cost Redis  for  the  derived  data  (leaderboard  etc.) load  very  far  from  Redis  max  capacity 42 Thursday, November 3, 2011
  • 48. Conclusions data  locality • average  game  call  <  1ms • no  db  roundtrip  at  every  request • no  need  for  low  latency  network • efficient  setup  for  cloud  environment 43 Thursday, November 3, 2011
  • 49. Conclusions data  locality • finally  CPU  bound • no  CPU  4me  for  serializing/deserializing  data   from  db • CPU  only  busy  transforming  data  (minimum   possible  ac4vity) 44 Thursday, November 3, 2011
  • 50. Conclusions CPU  usage • 300K  daily  users • 1000  hcp  req/sec  (game  ac4ons) • 4  m1.large  AWS  instances  (dual  core  8GB  RAM) • 2  instances  (coordinators)  5%  CPU  load • 2  instances  (workers)  20%  CPU  load 45 Thursday, November 3, 2011
  • 51. Conclusions extra  benefits en4re  user  state  in  one  process + immutability = Transac4onal  behavior 46 Thursday, November 3, 2011
  • 52. Conclusions extra  benefits One  user  session  -­‐>  one  erlang  process The  erlang  VM  is  aware  of  processes => the  erlang  VM  is  aware  of  user  sessions 47 Thursday, November 3, 2011
  • 53. Conclusions Thanks  to  VM  process  introspec4on process  reduc4ons  -­‐>  cost  of  a  game  ac4on process  used  memory  -­‐>  memory  used  by  session We  gained  a  lot  of  knowledge  about  a  fundamental   ”business”  en4ty 48 Thursday, November 3, 2011
  • 54. Conclusions • a  radical  change  was  made  possible  by  a  radically   different  tool  (erlang) 49 Thursday, November 3, 2011
  • 55. Conclusions • a  radical  change  was  made  possible  by  a  radically   different  tool  (erlang) • erlang  can  be  good  for  data  intensive/high   throughput  applica4ons 49 Thursday, November 3, 2011
  • 56. Conclusions • a  radical  change  was  made  possible  by  a  radically   different  tool  (erlang) • erlang  can  be  good  for  data  intensive/high   throughput  applica4ons • stateful  is  not  necessarily  hard/dangerous/ unmaintainable 49 Thursday, November 3, 2011
  • 57. Conclusions • november  2010:  0  lines  of  erlang  @wooga • november  2011:  1  erlang  game  server  live ...with  more  erlang  coming,  join  us 50 Thursday, November 3, 2011
  • 58. Q&A Knut Nesheim @knutin Paolo Negri @hungryblank hPp://wooga.com/jobs 51 Thursday, November 3, 2011