SlideShare une entreprise Scribd logo
1  sur  41
Télécharger pour lire hors ligne
AT	
  SCALE	
  WITH	
  STYLE
                      Erlang	
  <3	
  <3	
  <3	
  Ruby




Mar$n	
  Rehfeld,	
  @klickmich
At	
  Scale	
  With	
  Style

 How	
  we	
  roll

 Server	
  architectures

 How	
  to	
  innovate

 Mind	
  the	
  limits
Typical	
  game	
  architecture

         Client         HTTP      Backend
                         API
Typical	
  game	
  architecture

                                  Backend




     State	
  Changes
       ValidaHon
      Persistence
The	
  scale	
  is	
  interesHng


              14	
  billion	
  requests	
  /	
  month



          >100,000	
  DB	
  operaHons	
  /	
  second



             >50,000	
  DB	
  updates	
  /	
  second
Wooga’s	
  approach	
  to	
  development

Small	
  independent	
  teams	
  for	
  each	
  game

Team	
  gets	
  to	
  choose	
  tools	
  and	
  technologies
  Same	
  team	
  also	
  does	
  ops	
  a,er	
  going	
  live

Culture	
  of	
  sharing
  Look	
  around	
  what	
  is	
  there,	
  pick/adapt	
  exis;ng	
  
   solu;ons,	
  but	
  take	
  ownership	
  for	
  what	
  you	
  
   include
ExisHng	
  backends	
  –	
  Technology	
  landscape
At	
  Scale	
  With	
  Style

 How	
  we	
  roll

 Server	
  architectures

 How	
  to	
  innovate

 Mind	
  the	
  limits
Most	
  games	
  use	
  stateless	
  applicaHon	
  servers

         Server                          Database
And	
  then	
  there’s	
  sharding

                                  lb




        app   app   app   app     app    app    app   app   app




                          My            My
                          SQL           SQL


                          slave         slave
More	
  app	
  servers,	
  more	
  sharding

                                              lb




            app         app     app   app     app   app     app      app         app


            app     app         app   app     app   app     app      app         app




    My            My          My      My            My       My            My          My
    SQL           SQL         SQL     SQL           SQL      SQL           SQL         SQL


    slave     slave           slave   slave         slave    slave     slave           slave
Wait,	
  seriously?!

                                               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


My       My            My      My      My
                                                               redis    redis     redis     redis   redis
SQL      SQL           SQL     SQL     SQL


slave    slave     slave       slave   slave                   slave    slave     slave     slave   slave
Find	
  the	
  flaw

 “Stateless	
  applicaHon	
  servers	
  
      guarantee	
  one	
  thing:
       The	
  data	
  is	
  never
      where	
  you	
  need	
  it!”
          Paolo	
  Negri,	
  Developer	
  @	
  Wooga
Strong	
  session	
  pa`ern


   User	
  starts	
  playing

     many	
  transformaHons
     of	
  the	
  same	
  set	
  of	
  data


   User	
  stops	
  playing
Stateful	
  servers	
  and	
  DBs

          Server                              Database




                     One	
  Game	
  Session
Stateful	
  game	
  server

One	
  process	
  per	
  acHve	
  user	
  gaming	
  session

    ...	
  holds	
  the	
  current	
  state	
  and	
  is	
  the	
  only	
  one	
  that	
  can	
  
         modify	
  it	
  (strong	
  encapsulaHon)

    ...	
  handles	
  all	
  API	
  calls	
  for	
  the	
  given	
  user	
  one	
  a,er	
  the	
  other	
  
         (concurrency	
  control	
  through	
  actor	
  model)

    ...	
  loads	
  the	
  game	
  state	
  from	
  storage	
  and	
  writes	
  it	
  back	
  
         periodically	
  and	
  on	
  process	
  termina;on
         (;meout	
  =	
  user	
  stopped	
  playing)
The	
  DB	
  is	
  no	
  longer	
  the	
  bo`leneck


                     Stateless                     Stateful

  30.000
  22.500
  15.000
                                                   700
   7.500
        0
                      DB	
  operations	
  /	
  second
Magic	
  Land	
  uses	
  Erlang

Details:
Awesome	
  presentaHon	
  on
the	
  Magic	
  Land	
  game	
  server
by	
  @knuHn	
  &	
  @hungryblank


h`p://www.slideshare.net/wooga/from-­‐0-­‐to-­‐1000000-­‐daily-­‐users-­‐with-­‐erlang
At	
  Scale	
  With	
  Style

 How	
  we	
  roll

 Server	
  architectures

 How	
  to	
  innovate

 Mind	
  the	
  limits
Erlang	
  &	
  Ruby

Erlang	
  is	
  great
   Concurrent,	
  robust
   Great	
  for	
  opera;on

Ruby	
  is	
  great
  Concise,	
  expressive,	
  flexible
  Great	
  for	
  development
Bringing	
  two	
  worlds	
  together




                 Server                 Worker

       session
                          sender        Worker

       session
                                        Worker

         ...
                                        Worker
                          receiver
       session
                                        Worker
Do	
  you	
  know	
  Mongrel2?

                          Web	
  Server	
  that	
  hooks
                          up	
  applicaHons	
  via


➡ We	
  chose	
  the	
  same	
  queue	
  setup	
  &	
  
  message	
  format
                                            Server              Worker

                                  session

                                                     sender
                                                                Worker

                                  session
                                                                Worker

                                    ...
                                                                Worker
                                                     receiver


                                  session
                                                                Worker
ConnecHng	
  the	
  dots

Mongrel2	
  h`p://mongrel2.org/	
  protocol	
  &	
  ZeroMQ	
  setup
Erlang:	
  h`ps://github.com/hungryblank/emongrel2
Ruby
    rack-­‐mongrel2	
  fork	
  hKps://github.com/khiltd/khi-­‐rack-­‐mongrel2
    rack	
  protocol	
  hKp://rack.rubyforge.org
    Sinatra	
  hKp://www.sinatrarb.com/


➡      essenHally	
  we	
  are	
  speaking	
  HTTP	
  over	
  ZeroMQ
       and	
  can	
  hook	
  up	
  any	
  Rack-­‐based	
  Ruby	
  web	
  
       framework
Example	
  controller	
  in	
  Ruby
  app.game_action '/:actor/fruit_tree/self/shake',
                  :observable => true,
                  :affects => [:fruit_trees, :user],
                  :params => [:x, :y] do

    x, y = params[:x], params[:y]
    fruit_trees[x, y].shake

 end




DSL-­‐like	
  definiHon	
  of	
  game	
  acHon
Skinny	
  as	
  controllers	
  should	
  be
Example	
  model	
  in	
  Ruby
  class FruitTree < Tree

    property :last_shake_time,         :type => Integer, :default => 0
    property :collectable_fruit_count, :type => Integer, :default => 0

    def shake
      raise G8::Error::Validation, "no fruit!" unless carries_fruit?

      session.user.xp += 1
      session.user.energy -= 1
      self.last_shake_time = game_time
      self.collectable_fruit_count = config.fruit_count
    end

  end


Easily	
  unit	
  testable
Minimal	
  amount	
  of	
  code
Game	
  state

Game	
  state	
  is	
  split	
  in	
  mulHple	
  parts
  user,	
  map,	
  fruit_trees	
  etc.

Erlang	
  does	
  not	
  care	
  about	
  content
   Serialized	
  Ruby	
  objects

Erlang	
  does	
  know	
  mapping	
  of	
  state	
  parts	
  to	
  URLs
Looking	
  back	
  at	
  the	
  game	
  acHon
app.game_action '/:actor/fruit_tree/self/shake',
                :observable => true,
                :affects => [:fruit_trees, :user],
                :params => [:x, :y] do

  x, y = params[:x], params[:y]
  fruit_trees[x, y].shake
end



Mapping	
  of	
  state	
  parts	
  to	
  game	
  acHons
  Worker	
  knows	
  mapping
  Worker	
  pushes	
  mapping	
  to	
  Erlang	
  on	
  startup
  Erlang	
  can	
  query	
  mapping	
  if	
  needed
NICE!
        http://www.flickr.com/photos/aigle_dore/
At	
  Scale	
  With	
  Style

 How	
  we	
  roll

 Server	
  architectures

 How	
  to	
  innovate

 Mind	
  the	
  limits
Performance	
  impact	
  for	
  large	
  payloads
                                200	
  kB	
  payload
                     6000

                     5000
Requests	
  /	
  s




                     4000
                                                            Pure
                     3000                                  Erlang
                     2000
                                                            Ruby
                     1000                                   ZMQ
                                                           400	
  rps
                       0
                            1     #	
  of	
  workers   8
NOT	
  CPU	
  bound




25%



         Fixed	
  bandwith	
  limit	
  @	
  300	
  MB/s
This	
  has	
  happened	
  before
2,000,000"




1,500,000"




1,000,000"




 500,000"




        0"
        Apr*10"   Jul*10"   Oct*10"   Jan*11"   Apr*11"   Jul*11"   Oct*11"
Example	
  controller	
  in	
  Erlang

  shake(Args, State) ->
      Coords      = g8_map:coords(Args),
      Map         = g8_game:get_map(State),
      Tree        = g8_map:find(Coords, Map),

      NewTree     = g8_fruit_tree:shake(Tree),
      UserEffects = [incr_xp, decr_energy],
      NewMap      = g8_map:place(Coords, NewTree, Map),

      [observable,
       {state, g8_game:set_map(NewMap,
                 g8_user:apply(UserEffects, State))}].
Example	
  model	
  in	
  Erlang

  shake(Tree) ->
      validate_carries_fruit(Tree),

      FruitCount = g8_fruit_tree_config:fruit_count(Tree),
      Tree#fruit_tree{last_shake_time = g8_game:gametime(),
                      collectable_fruit_count = FruitCount}.
✓ Y ES
QuesHons?

   MarHn	
  Rehfeld
    @klickmich

slideshare.net/wooga
   wooga.com/jobs

Contenu connexe

Tendances

Complex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxComplex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxbobmcwhirter
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...bobmcwhirter
 
A Tale of a Server Architecture (Frozen Rails 2012)
A Tale of a Server Architecture (Frozen Rails 2012)A Tale of a Server Architecture (Frozen Rails 2012)
A Tale of a Server Architecture (Frozen Rails 2012)Flowdock
 
TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011Lance Ball
 
Rocket Fuelled Cucumbers
Rocket Fuelled CucumbersRocket Fuelled Cucumbers
Rocket Fuelled CucumbersJoseph Wilk
 
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyTorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyBruno Oliveira
 
Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaKeith Bennett
 
Java, Ruby & Rails
Java, Ruby & RailsJava, Ruby & Rails
Java, Ruby & RailsPeter Lind
 
Above the clouds: introducing Akka
Above the clouds: introducing AkkaAbove the clouds: introducing Akka
Above the clouds: introducing Akkanartamonov
 
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)ngotogenome
 
A tour of (advanced) Akka features in 40 minutes
A tour of (advanced) Akka features in 40 minutesA tour of (advanced) Akka features in 40 minutes
A tour of (advanced) Akka features in 40 minutesJohan Janssen
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes BackBurke Libbey
 
Modern Objective-C @ Pragma Night
Modern Objective-C @ Pragma NightModern Objective-C @ Pragma Night
Modern Objective-C @ Pragma NightGiuseppe Arici
 
When Two Worlds Collide: Java and Ruby in the Enterprise
When Two Worlds Collide: Java and Ruby in the EnterpriseWhen Two Worlds Collide: Java and Ruby in the Enterprise
When Two Worlds Collide: Java and Ruby in the Enterprisebenbrowning
 
Automatic Reference Counting @ Pragma Night
Automatic Reference Counting @ Pragma NightAutomatic Reference Counting @ Pragma Night
Automatic Reference Counting @ Pragma NightGiuseppe Arici
 
When Ruby Meets Java - The Power of Torquebox
When Ruby Meets Java - The Power of TorqueboxWhen Ruby Meets Java - The Power of Torquebox
When Ruby Meets Java - The Power of Torqueboxrockyjaiswal
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyNick Sieger
 

Tendances (18)

Complex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxComplex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBox
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
 
A Tale of a Server Architecture (Frozen Rails 2012)
A Tale of a Server Architecture (Frozen Rails 2012)A Tale of a Server Architecture (Frozen Rails 2012)
A Tale of a Server Architecture (Frozen Rails 2012)
 
TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011
 
Rocket Fuelled Cucumbers
Rocket Fuelled CucumbersRocket Fuelled Cucumbers
Rocket Fuelled Cucumbers
 
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyTorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
 
Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-java
 
Java, Ruby & Rails
Java, Ruby & RailsJava, Ruby & Rails
Java, Ruby & Rails
 
Above the clouds: introducing Akka
Above the clouds: introducing AkkaAbove the clouds: introducing Akka
Above the clouds: introducing Akka
 
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
 
A tour of (advanced) Akka features in 40 minutes
A tour of (advanced) Akka features in 40 minutesA tour of (advanced) Akka features in 40 minutes
A tour of (advanced) Akka features in 40 minutes
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes Back
 
Modern Objective-C @ Pragma Night
Modern Objective-C @ Pragma NightModern Objective-C @ Pragma Night
Modern Objective-C @ Pragma Night
 
When Two Worlds Collide: Java and Ruby in the Enterprise
When Two Worlds Collide: Java and Ruby in the EnterpriseWhen Two Worlds Collide: Java and Ruby in the Enterprise
When Two Worlds Collide: Java and Ruby in the Enterprise
 
Message queueing
Message queueingMessage queueing
Message queueing
 
Automatic Reference Counting @ Pragma Night
Automatic Reference Counting @ Pragma NightAutomatic Reference Counting @ Pragma Night
Automatic Reference Counting @ Pragma Night
 
When Ruby Meets Java - The Power of Torquebox
When Ruby Meets Java - The Power of TorqueboxWhen Ruby Meets Java - The Power of Torquebox
When Ruby Meets Java - The Power of Torquebox
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 

Similaire à At Scale With Style

Combining the Strengths or Erlang and Ruby
Combining the Strengths or Erlang and RubyCombining the Strengths or Erlang and Ruby
Combining the Strengths or Erlang and RubyWooga
 
Evoloution of Ideas
Evoloution of IdeasEvoloution of Ideas
Evoloution of IdeasWooga
 
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
 
DB Replication With Rails
DB Replication With RailsDB Replication With Rails
DB Replication With Railsschoefmax
 
Erlang as a cloud citizen, a fractal approach to throughput
Erlang as a cloud citizen, a fractal approach to throughputErlang as a cloud citizen, a fractal approach to throughput
Erlang as a cloud citizen, a fractal approach to throughputPaolo Negri
 
Erlang and the Cloud: A Fractal Approach to Throughput
Erlang and the Cloud: A Fractal Approach to ThroughputErlang and the Cloud: A Fractal Approach to Throughput
Erlang and the Cloud: A Fractal Approach to ThroughputWooga
 
Erlang as a Cloud Citizen
Erlang as a Cloud CitizenErlang as a Cloud Citizen
Erlang as a Cloud CitizenWooga
 
Using Kubernetes to deliver a “serverless” service
Using Kubernetes to deliver a “serverless” serviceUsing Kubernetes to deliver a “serverless” service
Using Kubernetes to deliver a “serverless” serviceDoKC
 
Games for the Masses (Jax)
Games for the Masses (Jax)Games for the Masses (Jax)
Games for the Masses (Jax)Wooga
 
Wire once, rewire twice! (Haskell exchange-2018)
Wire once, rewire twice! (Haskell exchange-2018)Wire once, rewire twice! (Haskell exchange-2018)
Wire once, rewire twice! (Haskell exchange-2018)Eric Torreborre
 
AKKA and Scala @ Inneractive
AKKA and Scala @ InneractiveAKKA and Scala @ Inneractive
AKKA and Scala @ InneractiveGal Aviv
 
Where is my scalable api?
Where is my scalable api?Where is my scalable api?
Where is my scalable api?Altoros
 
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
 
Jesper Richter-Reichhelm - Continuous Evolution at Wooga - code.talks 2015
Jesper Richter-Reichhelm - Continuous Evolution at Wooga - code.talks 2015Jesper Richter-Reichhelm - Continuous Evolution at Wooga - code.talks 2015
Jesper Richter-Reichhelm - Continuous Evolution at Wooga - code.talks 2015AboutYouGmbH
 
How Yelp does Service Discovery
How Yelp does Service DiscoveryHow Yelp does Service Discovery
How Yelp does Service DiscoveryJohn Billings
 
Building an App with jQuery and JAXER
Building an App with jQuery and JAXERBuilding an App with jQuery and JAXER
Building an App with jQuery and JAXERBrian Moschel
 
Using Kubernetes to deliver a “serverless” service
Using Kubernetes to deliver a “serverless” serviceUsing Kubernetes to deliver a “serverless” service
Using Kubernetes to deliver a “serverless” serviceDoKC
 

Similaire à At Scale With Style (20)

Combining the Strengths or Erlang and Ruby
Combining the Strengths or Erlang and RubyCombining the Strengths or Erlang and Ruby
Combining the Strengths or Erlang and Ruby
 
Evoloution of Ideas
Evoloution of IdeasEvoloution of Ideas
Evoloution of Ideas
 
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,)
 
Architecture Evolution at Wooga
Architecture Evolution at WoogaArchitecture Evolution at Wooga
Architecture Evolution at Wooga
 
DB Replication With Rails
DB Replication With RailsDB Replication With Rails
DB Replication With Rails
 
Erlang as a cloud citizen, a fractal approach to throughput
Erlang as a cloud citizen, a fractal approach to throughputErlang as a cloud citizen, a fractal approach to throughput
Erlang as a cloud citizen, a fractal approach to throughput
 
Erlang and the Cloud: A Fractal Approach to Throughput
Erlang and the Cloud: A Fractal Approach to ThroughputErlang and the Cloud: A Fractal Approach to Throughput
Erlang and the Cloud: A Fractal Approach to Throughput
 
Erlang as a Cloud Citizen
Erlang as a Cloud CitizenErlang as a Cloud Citizen
Erlang as a Cloud Citizen
 
Using Kubernetes to deliver a “serverless” service
Using Kubernetes to deliver a “serverless” serviceUsing Kubernetes to deliver a “serverless” service
Using Kubernetes to deliver a “serverless” service
 
Games for the Masses (Jax)
Games for the Masses (Jax)Games for the Masses (Jax)
Games for the Masses (Jax)
 
Wire once, rewire twice! (Haskell exchange-2018)
Wire once, rewire twice! (Haskell exchange-2018)Wire once, rewire twice! (Haskell exchange-2018)
Wire once, rewire twice! (Haskell exchange-2018)
 
Where is my scalable API?
Where is my scalable API?Where is my scalable API?
Where is my scalable API?
 
AKKA and Scala @ Inneractive
AKKA and Scala @ InneractiveAKKA and Scala @ Inneractive
AKKA and Scala @ Inneractive
 
Where is my scalable api?
Where is my scalable api?Where is my scalable api?
Where is my scalable api?
 
Innovation dank DevOps (DevOpsCon Berlin 2015)
Innovation dank DevOps (DevOpsCon Berlin 2015)Innovation dank DevOps (DevOpsCon Berlin 2015)
Innovation dank DevOps (DevOpsCon Berlin 2015)
 
Jesper Richter-Reichhelm - Continuous Evolution at Wooga - code.talks 2015
Jesper Richter-Reichhelm - Continuous Evolution at Wooga - code.talks 2015Jesper Richter-Reichhelm - Continuous Evolution at Wooga - code.talks 2015
Jesper Richter-Reichhelm - Continuous Evolution at Wooga - code.talks 2015
 
From Ruby to Elixir
From Ruby to ElixirFrom Ruby to Elixir
From Ruby to Elixir
 
How Yelp does Service Discovery
How Yelp does Service DiscoveryHow Yelp does Service Discovery
How Yelp does Service Discovery
 
Building an App with jQuery and JAXER
Building an App with jQuery and JAXERBuilding an App with jQuery and JAXER
Building an App with jQuery and JAXER
 
Using Kubernetes to deliver a “serverless” service
Using Kubernetes to deliver a “serverless” serviceUsing Kubernetes to deliver a “serverless” service
Using Kubernetes to deliver a “serverless” service
 

Dernier

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
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
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
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
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
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
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
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
 
[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
 
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
 
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
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
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
 
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
 
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
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
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
 

Dernier (20)

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
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
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
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
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
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
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
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
 
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
 
[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
 
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
 
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
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
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...
 
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
 
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)
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
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
 

At Scale With Style

  • 1. AT  SCALE  WITH  STYLE Erlang  <3  <3  <3  Ruby Mar$n  Rehfeld,  @klickmich
  • 2. At  Scale  With  Style How  we  roll Server  architectures How  to  innovate Mind  the  limits
  • 3.
  • 4. Typical  game  architecture Client HTTP Backend API
  • 5. Typical  game  architecture Backend State  Changes ValidaHon Persistence
  • 6. The  scale  is  interesHng 14  billion  requests  /  month >100,000  DB  operaHons  /  second >50,000  DB  updates  /  second
  • 7. Wooga’s  approach  to  development Small  independent  teams  for  each  game Team  gets  to  choose  tools  and  technologies Same  team  also  does  ops  a,er  going  live Culture  of  sharing Look  around  what  is  there,  pick/adapt  exis;ng   solu;ons,  but  take  ownership  for  what  you   include
  • 8. ExisHng  backends  –  Technology  landscape
  • 9. At  Scale  With  Style How  we  roll Server  architectures How  to  innovate Mind  the  limits
  • 10. Most  games  use  stateless  applicaHon  servers Server Database
  • 11. And  then  there’s  sharding lb app app app app app app app app app My My SQL SQL slave slave
  • 12. More  app  servers,  more  sharding lb app app app app app app app app app app app app app app app app app app My My My My My My My My SQL SQL SQL SQL SQL SQL SQL SQL slave slave slave slave slave slave slave slave
  • 13. Wait,  seriously?! 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 My My My My My redis redis redis redis redis SQL SQL SQL SQL SQL slave slave slave slave slave slave slave slave slave slave
  • 14. Find  the  flaw “Stateless  applicaHon  servers   guarantee  one  thing: The  data  is  never where  you  need  it!” Paolo  Negri,  Developer  @  Wooga
  • 15. Strong  session  pa`ern User  starts  playing many  transformaHons of  the  same  set  of  data User  stops  playing
  • 16. Stateful  servers  and  DBs Server Database One  Game  Session
  • 17. Stateful  game  server One  process  per  acHve  user  gaming  session ...  holds  the  current  state  and  is  the  only  one  that  can   modify  it  (strong  encapsulaHon) ...  handles  all  API  calls  for  the  given  user  one  a,er  the  other   (concurrency  control  through  actor  model) ...  loads  the  game  state  from  storage  and  writes  it  back   periodically  and  on  process  termina;on (;meout  =  user  stopped  playing)
  • 18. The  DB  is  no  longer  the  bo`leneck Stateless Stateful 30.000 22.500 15.000 700 7.500 0 DB  operations  /  second
  • 19. Magic  Land  uses  Erlang Details: Awesome  presentaHon  on the  Magic  Land  game  server by  @knuHn  &  @hungryblank h`p://www.slideshare.net/wooga/from-­‐0-­‐to-­‐1000000-­‐daily-­‐users-­‐with-­‐erlang
  • 20. At  Scale  With  Style How  we  roll Server  architectures How  to  innovate Mind  the  limits
  • 21.
  • 22. Erlang  &  Ruby Erlang  is  great Concurrent,  robust Great  for  opera;on Ruby  is  great Concise,  expressive,  flexible Great  for  development
  • 23.
  • 24. Bringing  two  worlds  together Server Worker session sender Worker session Worker ... Worker receiver session Worker
  • 25. Do  you  know  Mongrel2? Web  Server  that  hooks up  applicaHons  via ➡ We  chose  the  same  queue  setup  &   message  format Server Worker session sender Worker session Worker ... Worker receiver session Worker
  • 26.
  • 27. ConnecHng  the  dots Mongrel2  h`p://mongrel2.org/  protocol  &  ZeroMQ  setup Erlang:  h`ps://github.com/hungryblank/emongrel2 Ruby rack-­‐mongrel2  fork  hKps://github.com/khiltd/khi-­‐rack-­‐mongrel2 rack  protocol  hKp://rack.rubyforge.org Sinatra  hKp://www.sinatrarb.com/ ➡ essenHally  we  are  speaking  HTTP  over  ZeroMQ and  can  hook  up  any  Rack-­‐based  Ruby  web   framework
  • 28. Example  controller  in  Ruby app.game_action '/:actor/fruit_tree/self/shake', :observable => true, :affects => [:fruit_trees, :user], :params => [:x, :y] do x, y = params[:x], params[:y] fruit_trees[x, y].shake end DSL-­‐like  definiHon  of  game  acHon Skinny  as  controllers  should  be
  • 29. Example  model  in  Ruby class FruitTree < Tree property :last_shake_time, :type => Integer, :default => 0 property :collectable_fruit_count, :type => Integer, :default => 0 def shake raise G8::Error::Validation, "no fruit!" unless carries_fruit? session.user.xp += 1 session.user.energy -= 1 self.last_shake_time = game_time self.collectable_fruit_count = config.fruit_count end end Easily  unit  testable Minimal  amount  of  code
  • 30. Game  state Game  state  is  split  in  mulHple  parts user,  map,  fruit_trees  etc. Erlang  does  not  care  about  content Serialized  Ruby  objects Erlang  does  know  mapping  of  state  parts  to  URLs
  • 31. Looking  back  at  the  game  acHon app.game_action '/:actor/fruit_tree/self/shake', :observable => true, :affects => [:fruit_trees, :user], :params => [:x, :y] do x, y = params[:x], params[:y] fruit_trees[x, y].shake end Mapping  of  state  parts  to  game  acHons Worker  knows  mapping Worker  pushes  mapping  to  Erlang  on  startup Erlang  can  query  mapping  if  needed
  • 32. NICE! http://www.flickr.com/photos/aigle_dore/
  • 33. At  Scale  With  Style How  we  roll Server  architectures How  to  innovate Mind  the  limits
  • 34. Performance  impact  for  large  payloads 200  kB  payload 6000 5000 Requests  /  s 4000 Pure 3000 Erlang 2000 Ruby 1000 ZMQ 400  rps 0 1 #  of  workers 8
  • 35. NOT  CPU  bound 25% Fixed  bandwith  limit  @  300  MB/s
  • 36. This  has  happened  before 2,000,000" 1,500,000" 1,000,000" 500,000" 0" Apr*10" Jul*10" Oct*10" Jan*11" Apr*11" Jul*11" Oct*11"
  • 37.
  • 38. Example  controller  in  Erlang shake(Args, State) -> Coords = g8_map:coords(Args), Map = g8_game:get_map(State), Tree = g8_map:find(Coords, Map), NewTree = g8_fruit_tree:shake(Tree), UserEffects = [incr_xp, decr_energy], NewMap = g8_map:place(Coords, NewTree, Map), [observable, {state, g8_game:set_map(NewMap, g8_user:apply(UserEffects, State))}].
  • 39. Example  model  in  Erlang shake(Tree) -> validate_carries_fruit(Tree), FruitCount = g8_fruit_tree_config:fruit_count(Tree), Tree#fruit_tree{last_shake_time = g8_game:gametime(), collectable_fruit_count = FruitCount}.
  • 41. QuesHons? MarHn  Rehfeld @klickmich slideshare.net/wooga wooga.com/jobs