SlideShare une entreprise Scribd logo
1  sur  67
Télécharger pour lire hors ligne
Lua + Erlang + VoltDB
An Erlang Game Stack




           An Erlang Game Stack




                        Erlang User Conference 2012
                                 H. Diedrich

                        http://www.eonblast.com – twitter @hdiedrich

1                                                                      Eonblast
An Erlang Game Stack



                  Henning Diedrich
        • Maintainer Emysql, Erlvolt, Erlualib
        • Eonblast: game + film
        • NewTracks: game + music
        • Bricks and mortar
        • Insurance tariff language

                               Octocat says: try markedoc!


2                                                    Eonblast
An Erlang Game Stack


                       Eonblast




3                                 Eonblast
An Erlang Game Stack


                       This Talk

            • A game server architecture
            • Its components
            • The glue




4                                          Eonblast
An Erlang Game Stack


                       This Talk
                  • Work in progress
                  • Unproven concepts
                  • Lies and conjecture
                             andalso

                  • 3 genius tools
                  • 10,000 lines of glue code

5                                               Eonblast
An Erlang Game Stack


                       Questions


        Please throw them in like Torben
      Mail me at hdiedrich at eonblast.com
               Erlang Mailing List




6                                     Eonblast
An Erlang Game Stack


                       Erlang Game Servers




    Zynga: FarmVille via membase, Activision Blizzard: Call of Duty, Bigpoint: Battle Star Galactica, Wooga: Magic Land




7                                                                                                       Eonblast
An Erlang Game Stack


                   Erlang + MySQL




                           http://eonblast.github.com/Emysql

                       Electronic Arts contributed emysql.


8                                                              Eonblast
An Erlang Game Stack


                       The Hurt
             • Leaks, Deadlocks
             • Bad Productivity
             • Game Design Language Gap

             • Less Features
             • Less Players
             • Lesser Product

9                                    Eonblast
An Erlang Game Stack


                        Target


             „The perfect game server“
                       (makes no sense)




10                                        Eonblast
An Erlang Game Stack


               Generals’ Problem




                                                            State




                       Two generals must agree on a time.



11                                                                  Eonblast
An Erlang Game Stack


               Generals’ Problem




                                           State




                       Send a messenger.



12                                                 Eonblast
An Erlang Game Stack


               Generals’ Problem




                                      State




                       Acknowledge.



13                                            Eonblast
An Erlang Game Stack


               Generals’ Problem




                                           State




                       ACK the ACK. Etc.



14                                                 Eonblast
An Erlang Game Stack


               Generals’ Problem




                                                     State




                       The messenger may get lost.



15                                                           Eonblast
An Erlang Game Stack


               Byzantine Generals




                                            State




                       The generals, too.



16                                                  Eonblast
An Erlang Game Stack


                        The Hunt

                        Server Stack
                       • Language
                       • Database
                       • Protocol
                       • Game Logic


17                                     Eonblast
An Erlang Game Stack


                          Spec
                       “Table Game”

           •   1 million active players
           •   1 million transactions per second
           •   1 second latency
           •   Linear scale
           •   100% data integrity



18                                                 Eonblast
An Erlang Game Stack


               Client Architecture


            • Fat JavaScript Browser Client
            • COMET



                       Not discussed in this talk.



19                                                   Eonblast
An Erlang Game Stack


                       Language

                            Wishlist
                       • Robustness
                       • Deadlock-free
                       • Multi-core
                       • Linear Scale
                                    er?



20                                        Eonblast
An Erlang Game Stack


                                     Database
                                         CAP
                                • Distributed
                                • Consistent
                                • Highly-available
                                • Partition-tolerant
                                       All of it!

     Brewer on CAP 2012: http://www.infoq.com/articles/cap-twelve-years-later-how-the-rules-have-changed


21                                                                                             Eonblast
An Erlang Game Stack


                       Database

                             ACID
                       • Atomicity
                       • Consistency
                       • Isolation
                       • Durability
                        For Granted?


22                                     Eonblast
An Erlang Game Stack


                       Database

               Double Bookkeeping
           • Not every game needs it
           • Requires ACID Transactions
           • Neigh impossible to emulate
           • Impossible with BASE /
             Eventual Consistency

23                                         Eonblast
An Erlang Game Stack


                                 Database

                Upcoming Blog Post
        • Looking at 14 databases
        •   Riak, Cassandra, Membase, H-Base, Voldemort, MySQL, MySQL Cluster, Redis, Redis
            Cluster, Tokyo Cabinet, Memcached, CouchDB, Couchbase, VoltDB, MongoDB, Postgres


        • In the light of what games need
        • Unbiased comparison
        • Twitter @hdiedrich


24                                                                                      Eonblast
An Erlang Game Stack


                          Protocol

                              Wishlist
                       • Small footprint
                       • Fast to encode
                       • Human-readable




25                                         Eonblast
An Erlang Game Stack


                            Logic

                              Wishlist
                       • Human Readable
                       • Stable
                       • Fast
                       • Concise
                       • Small Footprint


26                                         Eonblast
An Erlang Game Stack


                            The Answers

                    • Client
                    • Protocol
                    • Server
                    • Logic
                    • Data
              Client: HTML5/JS, Protocol: JSON, Server: Erlang, Logic: Lua, Data: VoltDB.


27                                                                                          Eonblast
An Erlang Game Stack




               “Embeddable scripting language”




28                                               Eonblast
An Erlang Game Stack


                                         Lua


                       ”Lua is strange.“
                                     R. Virding




                       “It has mutable variables, what more need I say.”


29                                                                         Eonblast
An Erlang Game Stack


                       Lua

            a = “Roberto”
            if a ~= nil then
               print “Hello ” .. a .. “!”
            end




30                                   Eonblast
An Erlang Game Stack


                                            Lua
               •   Created 1993
               •   Simple, imperative syntax
               •   Stable syntax, stable VMs
               •   Two main VMs: ISO C, JIT
               •   Game scripting champion
               •   Open Source, 100% dictatorial*
                   *benevolent, of course




                   Site: http://www.lua.org
                   List: lua-l@lists.lua.org
31                                                Eonblast
An Erlang Game Stack


                            Lua

        •   Made for non-programmers - imperative syntax
        •   Powerful for programmers - Scheme semantics
        •   Made for DSLs - extensible semantics
        •   Made to be extended - simple C API
        •   Made to be embedded - small VM footprint

        • Now with a native Erlang VM!



32                                                 Eonblast
An Erlang Game Stack


                       Lua Caveats

            •   Deceiving Looks
            •   Encourages magic
            •   Simple but not for beginners
            •   Syntax forked
            •   Only one collection type



33                                             Eonblast
An Erlang Game Stack


                        Lua VMs
       • PUC Reference VM      pure ISO C
          Lua 5.2              super compatible


       • JIT VM                X86, ARM, PPC, MIPS
          remains at Lua 5.1
                               super fast
          adds extensions


       • Luerl                 native Erlang VM
          Lua 5.2              super stable
          incomplete


34                                                Eonblast
An Erlang Game Stack


                       Architecture




35                                    Eonblast
An Erlang Game Stack




              Perceived reaction to asking about benchmarks on the Erlang mailing list.


36                                                                                        Eonblast
An Erlang Game Stack


                        World State


                                          State




                   Where does the state go? Into the Logic core, for speed.

37                                                                            Eonblast
An Erlang Game Stack


                       World State


            State      State    State   State   State




                               State


38                                                      Eonblast
An Erlang Game Stack


                       World State


            State      State    State   State   State




                               State


39                                                      Eonblast
An Erlang Game Stack


                       World State


            State              State   State   State
                           State




                           State


40                                                     Eonblast
An Erlang Game Stack


                       World State


            State      State    State   State   State




                               State


41                                                      Eonblast
An Erlang Game Stack




                       “High Velocity Database”




42                                                Eonblast
An Erlang Game Stack


                                  VoltDB
     •   Created 2009
     •   Simple SQL syntax
     •   Stable 2.5
     •   Commercial developer, support
     •   High Velocity Secret Tip
     •   Open Source, 100% dictatorial*
         *benevolent, of course



         Site: http://www.voltdb.com
         Help: http://community.voltdb.com/forum

43                                          Eonblast
An Erlang Game Stack


                          VoltDB

     •   ACID transactions – double bookkeeping
     •   SQL – subset of '92
     •   Linear scale - „unlimited“ data (but ...)
     •   Made for OLTP - fast, cheap writes, high throughput
     •   “More SQL than SQL” – invites clean sep. of data
     •   In-memory - 100x faster than MySQL
     •   Replication, Snapshots – 'hot backup built in'



44                                                   Eonblast
An Erlang Game Stack


                  VoltDB Caveats
           •   Less agile than MySQL/NoSQL
           •   Need to understand partitions
           •   Must program SPs in Java
           •   Not elastic (yet)
           •   No online schema change (yet)
           •   There is always a bottleneck
           •   Simple but not for beginners


45                                             Eonblast
An Erlang Game Stack


              Horizonzal Partitions
                       State
                         #




46                                    Eonblast
An Erlang Game Stack


                       Replication
                          State
                            #




47                                   Eonblast
An Erlang Game Stack


                Actual Connections


            State      State    State   State   State




                               State


48                                                      Eonblast
An Erlang Game Stack




                       The Mix




           Erlang + Lua + VoltDB
49                               Eonblast
An Erlang Game Stack




                       How do we connect these components?

50                                                           Eonblast
An Erlang Game Stack




                       Fleece




                       Erlualib



                       Erlvolt




51                                Eonblast
An Erlang Game Stack




                       Fleece



                        Luerl




                       Erlvolt




52                               Eonblast
An Erlang Game Stack


                       The Packages

     • Protocol        Fleece     Lua to JSON

     • Logic           Erlualib   Lua port

     • Logic            Luerl     Lua VM

     • Data             Erlvolt   VoltDB driver




53                                                Eonblast
An Erlang Game Stack


                       Erlualib

           • Lua embedding library for Erlang

           • Lua state in original PUC Lua VM
           • A fast way
           • A not secure way: can crash Erlang




54                                              Eonblast
An Erlang Game Stack


                             Erlualib
              hello() ->
                 % get handle of the Lua engine
                 {ok, L} = lua:new_s tate(),

                 % put " print" global on top of s tack
                 lua:getfield(L, global, " print" ),

                 % put hello on top
                 lua:pus hs tring(L, " Hello from Lua!" ),

                 % exec ute on top 2 values on s tac k
                 lua:c all(L, 1, 0).



55                                                           Eonblast
An Erlang Game Stack


                               Erlualib

             hello() ->

                {ok, L} = lua:new_s tate(),

                lua:getfield(L, global, " print" ),

                lua:pus hs tring(L, " Hello from Lua!" ),

                lua:c all(L, 1, 0).




56                                                          Eonblast
An Erlang Game Stack


                       Luerl

        • New Lua VM programmed in Erlang
        • Perfectly secure way
        • Precompiled Chunks
        • Re-usable State
        • Work in progress


57                                   Eonblast
An Erlang Game Stack


                                    Luerl


             hello() ->

                L = luerl:init(),

                luerl:do(" print('Hello from Lua!')" , L).




58                                                           Eonblast
An Erlang Game Stack


                                 Luerl

     hello() ->

        L = luerl:init(),
       C hunk = luerl:eval(" print('Hello from Lua!')" , L),
       luerl:call(C hunk, L)

     % C hunk and L c an be re-us ed.




59                                                             Eonblast
An Erlang Game Stack


                           Benchmark Luerl vs Erlualib




        Erlualib / PUC                                                     Luerl

        270 µs                           state Init                        250 µs

        10 µs                          parse 1 + 1                         15 µs

        2.5 µs                        execute 1 + 1                        13 µs

        23 µs                         parse formula                        63 µs

        2.5 µs                      execute formula                        35 µs

        2.5 µs                        call a function                      28 µs

                  Formula: a = 7.33; b = 9000; c = (33 * a / b) ^ 15 * a + b

60                                                                             Eonblast
An Erlang Game Stack




                       Fast Lua to JSON encoder




61                                                Eonblast
An Erlang Game Stack


                           Fleece

                •   Fastest Lua JSON encoder
                •   C+ASM or ISO C
                •   Faster than Lua JIT
                •   Faster than concat
                •   10x faster than other fastest




62                                                  Eonblast
An Erlang Game Stack




63                     Eonblast
An Erlang Game Stack


                            Erlvolt

                •   Native Erlang VoltDB driver
                •   Async parallel data shuffling
                •   Coming next quarter
                •   Your help is wanted
                •   Connect over github




64                                                  Eonblast
An Erlang Game Stack


               Server Architecture

                • Erlang   • Luerl
                • Lua      • Erlualib
                • JSON     • Fleece
                • VoltDB   • Erlvolt




65                                      Eonblast
An Erlang Game Stack


                       Invitation

            • All at github
            • All w/samples & docs
            • All maintained by Eonblast
            • Luerl maintained by R. Virding
            • Updates @hdiedrich, @rvirding


66                                        Eonblast
An Erlang Game Stack


                       Questions


           Mail: hdiedrich ∂ eonblast.com
                   Skype: eonblast
                  Twitter: @hdiedrich




67                                          Eonblast

Contenu connexe

Tendances

A Rails performance guidebook: from 0 to 1B requests/day
A Rails performance guidebook: from 0 to 1B requests/dayA Rails performance guidebook: from 0 to 1B requests/day
A Rails performance guidebook: from 0 to 1B requests/dayCristian González
 
Kotlin Coroutines Reloaded
Kotlin Coroutines ReloadedKotlin Coroutines Reloaded
Kotlin Coroutines ReloadedRoman Elizarov
 
The art of readable code ( pdf )
The art of readable code ( pdf )The art of readable code ( pdf )
The art of readable code ( pdf )Jocelyn Hsu
 
Jumpstart! From SQL to NoSQL -- Changing Your Mindset
Jumpstart! From SQL to NoSQL -- Changing Your MindsetJumpstart! From SQL to NoSQL -- Changing Your Mindset
Jumpstart! From SQL to NoSQL -- Changing Your MindsetLauren Hayward Schaefer
 
Mysql query optimization
Mysql query optimizationMysql query optimization
Mysql query optimizationBaohua Cai
 
JSON and PL/SQL: A Match Made in Database
JSON and PL/SQL: A Match Made in DatabaseJSON and PL/SQL: A Match Made in Database
JSON and PL/SQL: A Match Made in DatabaseSteven Feuerstein
 
Migration to Oracle Multitenant
Migration to Oracle MultitenantMigration to Oracle Multitenant
Migration to Oracle MultitenantJitendra Singh
 
COSCUP 2016 Workshop : 快快樂樂學Neo4j
COSCUP 2016 Workshop : 快快樂樂學Neo4jCOSCUP 2016 Workshop : 快快樂樂學Neo4j
COSCUP 2016 Workshop : 快快樂樂學Neo4jEric Lee
 
Running Free with the Monads
Running Free with the MonadsRunning Free with the Monads
Running Free with the Monadskenbot
 
Testcontainers - Geekout EE 2017 presentation
Testcontainers - Geekout EE 2017 presentationTestcontainers - Geekout EE 2017 presentation
Testcontainers - Geekout EE 2017 presentationRichard North
 
A Spring Data’s Guide to Persistence
A Spring Data’s Guide to PersistenceA Spring Data’s Guide to Persistence
A Spring Data’s Guide to PersistenceVMware Tanzu
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScriptNascenia IT
 
Database-Migration and -Upgrade with Transportable Tablespaces
Database-Migration and -Upgrade with Transportable TablespacesDatabase-Migration and -Upgrade with Transportable Tablespaces
Database-Migration and -Upgrade with Transportable TablespacesMarkus Flechtner
 
以 Kotlin Multiplatform Mobile (KMM) 開發跨平台行動應用
以 Kotlin Multiplatform Mobile (KMM) 開發跨平台行動應用以 Kotlin Multiplatform Mobile (KMM) 開發跨平台行動應用
以 Kotlin Multiplatform Mobile (KMM) 開發跨平台行動應用Shengyou Fan
 
Reporting with Oracle Application Express (APEX)
Reporting with Oracle Application Express (APEX)Reporting with Oracle Application Express (APEX)
Reporting with Oracle Application Express (APEX)Dimitri Gielis
 
SymfonyLive Online 2023 - Is SOLID dead? .pdf
SymfonyLive Online 2023 - Is SOLID dead? .pdfSymfonyLive Online 2023 - Is SOLID dead? .pdf
SymfonyLive Online 2023 - Is SOLID dead? .pdfŁukasz Chruściel
 
Liquibase for java developers
Liquibase for java developersLiquibase for java developers
Liquibase for java developersIllia Seleznov
 

Tendances (20)

A Rails performance guidebook: from 0 to 1B requests/day
A Rails performance guidebook: from 0 to 1B requests/dayA Rails performance guidebook: from 0 to 1B requests/day
A Rails performance guidebook: from 0 to 1B requests/day
 
Kotlin Coroutines Reloaded
Kotlin Coroutines ReloadedKotlin Coroutines Reloaded
Kotlin Coroutines Reloaded
 
The art of readable code ( pdf )
The art of readable code ( pdf )The art of readable code ( pdf )
The art of readable code ( pdf )
 
Jumpstart! From SQL to NoSQL -- Changing Your Mindset
Jumpstart! From SQL to NoSQL -- Changing Your MindsetJumpstart! From SQL to NoSQL -- Changing Your Mindset
Jumpstart! From SQL to NoSQL -- Changing Your Mindset
 
Mysql query optimization
Mysql query optimizationMysql query optimization
Mysql query optimization
 
Stored procedure
Stored procedureStored procedure
Stored procedure
 
Allyourbase
AllyourbaseAllyourbase
Allyourbase
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
JSON and PL/SQL: A Match Made in Database
JSON and PL/SQL: A Match Made in DatabaseJSON and PL/SQL: A Match Made in Database
JSON and PL/SQL: A Match Made in Database
 
Migration to Oracle Multitenant
Migration to Oracle MultitenantMigration to Oracle Multitenant
Migration to Oracle Multitenant
 
COSCUP 2016 Workshop : 快快樂樂學Neo4j
COSCUP 2016 Workshop : 快快樂樂學Neo4jCOSCUP 2016 Workshop : 快快樂樂學Neo4j
COSCUP 2016 Workshop : 快快樂樂學Neo4j
 
Running Free with the Monads
Running Free with the MonadsRunning Free with the Monads
Running Free with the Monads
 
Testcontainers - Geekout EE 2017 presentation
Testcontainers - Geekout EE 2017 presentationTestcontainers - Geekout EE 2017 presentation
Testcontainers - Geekout EE 2017 presentation
 
A Spring Data’s Guide to Persistence
A Spring Data’s Guide to PersistenceA Spring Data’s Guide to Persistence
A Spring Data’s Guide to Persistence
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
Database-Migration and -Upgrade with Transportable Tablespaces
Database-Migration and -Upgrade with Transportable TablespacesDatabase-Migration and -Upgrade with Transportable Tablespaces
Database-Migration and -Upgrade with Transportable Tablespaces
 
以 Kotlin Multiplatform Mobile (KMM) 開發跨平台行動應用
以 Kotlin Multiplatform Mobile (KMM) 開發跨平台行動應用以 Kotlin Multiplatform Mobile (KMM) 開發跨平台行動應用
以 Kotlin Multiplatform Mobile (KMM) 開發跨平台行動應用
 
Reporting with Oracle Application Express (APEX)
Reporting with Oracle Application Express (APEX)Reporting with Oracle Application Express (APEX)
Reporting with Oracle Application Express (APEX)
 
SymfonyLive Online 2023 - Is SOLID dead? .pdf
SymfonyLive Online 2023 - Is SOLID dead? .pdfSymfonyLive Online 2023 - Is SOLID dead? .pdf
SymfonyLive Online 2023 - Is SOLID dead? .pdf
 
Liquibase for java developers
Liquibase for java developersLiquibase for java developers
Liquibase for java developers
 

En vedette

Erlang, the big switch in social games
Erlang, the big switch in social gamesErlang, the big switch in social games
Erlang, the big switch in social gamesWooga
 
Intro to Erlang
Intro to ErlangIntro to Erlang
Intro to ErlangKen Pratt
 
First encounter with Elixir - Some random things
First encounter with Elixir - Some random thingsFirst encounter with Elixir - Some random things
First encounter with Elixir - Some random thingsSamuel Lampa
 
Making multiplayer game with Elixir and Elm
Making multiplayer game with Elixir and ElmMaking multiplayer game with Elixir and Elm
Making multiplayer game with Elixir and Elmnetzke
 
DevOps goes Mobile (daho.am)
DevOps goes Mobile (daho.am)DevOps goes Mobile (daho.am)
DevOps goes Mobile (daho.am)Wooga
 
The Two Generals Problem
The Two Generals ProblemThe Two Generals Problem
The Two Generals ProblemVoltDB
 
High Performance Erlang
High Performance ErlangHigh Performance Erlang
High Performance Erlangdidip
 
1300579454645 livro adm proc operacionais
1300579454645 livro adm proc operacionais1300579454645 livro adm proc operacionais
1300579454645 livro adm proc operacionaisPMP
 
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
 
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
 
Introdução à Computação Aula 05 - Sistemas Operacionais (arquitetura do SO, p...
Introdução à Computação Aula 05 - Sistemas Operacionais (arquitetura do SO, p...Introdução à Computação Aula 05 - Sistemas Operacionais (arquitetura do SO, p...
Introdução à Computação Aula 05 - Sistemas Operacionais (arquitetura do SO, p...Leinylson Fontinele
 
Evoloution of Ideas
Evoloution of IdeasEvoloution of Ideas
Evoloution of IdeasWooga
 
Online games traffic characterization and network support
Online games traffic characterization and network supportOnline games traffic characterization and network support
Online games traffic characterization and network supportJose Saldana
 
Brief Intro to Phoenix - Elixir Meetup at BukaLapak
Brief Intro to Phoenix - Elixir Meetup at BukaLapakBrief Intro to Phoenix - Elixir Meetup at BukaLapak
Brief Intro to Phoenix - Elixir Meetup at BukaLapakRiza Fahmi
 
A Practical Architecture Design for MMO Casual Game
A Practical Architecture Design for MMO Casual GameA Practical Architecture Design for MMO Casual Game
A Practical Architecture Design for MMO Casual Gameaction.vn
 
Space Ape's Live Ops Stack: Engineering Mobile Games for Live Ops from Day 1
Space Ape's Live Ops Stack: Engineering Mobile Games for Live Ops from Day 1Space Ape's Live Ops Stack: Engineering Mobile Games for Live Ops from Day 1
Space Ape's Live Ops Stack: Engineering Mobile Games for Live Ops from Day 1Simon Hade
 
MMO Design Architecture by Andrew
MMO Design Architecture by AndrewMMO Design Architecture by Andrew
MMO Design Architecture by AndrewAgate Studio
 
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
 

En vedette (20)

Erlang, the big switch in social games
Erlang, the big switch in social gamesErlang, the big switch in social games
Erlang, the big switch in social games
 
Intro to Erlang
Intro to ErlangIntro to Erlang
Intro to Erlang
 
Erlang OTP
Erlang OTPErlang OTP
Erlang OTP
 
First encounter with Elixir - Some random things
First encounter with Elixir - Some random thingsFirst encounter with Elixir - Some random things
First encounter with Elixir - Some random things
 
Erlang and Scalability
Erlang and ScalabilityErlang and Scalability
Erlang and Scalability
 
Making multiplayer game with Elixir and Elm
Making multiplayer game with Elixir and ElmMaking multiplayer game with Elixir and Elm
Making multiplayer game with Elixir and Elm
 
DevOps goes Mobile (daho.am)
DevOps goes Mobile (daho.am)DevOps goes Mobile (daho.am)
DevOps goes Mobile (daho.am)
 
The Two Generals Problem
The Two Generals ProblemThe Two Generals Problem
The Two Generals Problem
 
High Performance Erlang
High Performance ErlangHigh Performance Erlang
High Performance Erlang
 
1300579454645 livro adm proc operacionais
1300579454645 livro adm proc operacionais1300579454645 livro adm proc operacionais
1300579454645 livro adm proc operacionais
 
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
 
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
 
Introdução à Computação Aula 05 - Sistemas Operacionais (arquitetura do SO, p...
Introdução à Computação Aula 05 - Sistemas Operacionais (arquitetura do SO, p...Introdução à Computação Aula 05 - Sistemas Operacionais (arquitetura do SO, p...
Introdução à Computação Aula 05 - Sistemas Operacionais (arquitetura do SO, p...
 
Evoloution of Ideas
Evoloution of IdeasEvoloution of Ideas
Evoloution of Ideas
 
Online games traffic characterization and network support
Online games traffic characterization and network supportOnline games traffic characterization and network support
Online games traffic characterization and network support
 
Brief Intro to Phoenix - Elixir Meetup at BukaLapak
Brief Intro to Phoenix - Elixir Meetup at BukaLapakBrief Intro to Phoenix - Elixir Meetup at BukaLapak
Brief Intro to Phoenix - Elixir Meetup at BukaLapak
 
A Practical Architecture Design for MMO Casual Game
A Practical Architecture Design for MMO Casual GameA Practical Architecture Design for MMO Casual Game
A Practical Architecture Design for MMO Casual Game
 
Space Ape's Live Ops Stack: Engineering Mobile Games for Live Ops from Day 1
Space Ape's Live Ops Stack: Engineering Mobile Games for Live Ops from Day 1Space Ape's Live Ops Stack: Engineering Mobile Games for Live Ops from Day 1
Space Ape's Live Ops Stack: Engineering Mobile Games for Live Ops from Day 1
 
MMO Design Architecture by Andrew
MMO Design Architecture by AndrewMMO Design Architecture by Andrew
MMO Design Architecture by Andrew
 
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
 

Dernier

UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1DianaGray10
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?IES VE
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Websitedgelyza
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopBachir Benyammi
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Brian Pichman
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfAijun Zhang
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 

Dernier (20)

UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Website
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
201610817 - edge part1
201610817 - edge part1201610817 - edge part1
201610817 - edge part1
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 Workshop
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
20230104 - machine vision
20230104 - machine vision20230104 - machine vision
20230104 - machine vision
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdf
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 

An Erlang Game Stack

  • 1. Lua + Erlang + VoltDB An Erlang Game Stack An Erlang Game Stack Erlang User Conference 2012 H. Diedrich http://www.eonblast.com – twitter @hdiedrich 1 Eonblast
  • 2. An Erlang Game Stack Henning Diedrich • Maintainer Emysql, Erlvolt, Erlualib • Eonblast: game + film • NewTracks: game + music • Bricks and mortar • Insurance tariff language Octocat says: try markedoc! 2 Eonblast
  • 3. An Erlang Game Stack Eonblast 3 Eonblast
  • 4. An Erlang Game Stack This Talk • A game server architecture • Its components • The glue 4 Eonblast
  • 5. An Erlang Game Stack This Talk • Work in progress • Unproven concepts • Lies and conjecture andalso • 3 genius tools • 10,000 lines of glue code 5 Eonblast
  • 6. An Erlang Game Stack Questions Please throw them in like Torben Mail me at hdiedrich at eonblast.com Erlang Mailing List 6 Eonblast
  • 7. An Erlang Game Stack Erlang Game Servers Zynga: FarmVille via membase, Activision Blizzard: Call of Duty, Bigpoint: Battle Star Galactica, Wooga: Magic Land 7 Eonblast
  • 8. An Erlang Game Stack Erlang + MySQL http://eonblast.github.com/Emysql Electronic Arts contributed emysql. 8 Eonblast
  • 9. An Erlang Game Stack The Hurt • Leaks, Deadlocks • Bad Productivity • Game Design Language Gap • Less Features • Less Players • Lesser Product 9 Eonblast
  • 10. An Erlang Game Stack Target „The perfect game server“ (makes no sense) 10 Eonblast
  • 11. An Erlang Game Stack Generals’ Problem State Two generals must agree on a time. 11 Eonblast
  • 12. An Erlang Game Stack Generals’ Problem State Send a messenger. 12 Eonblast
  • 13. An Erlang Game Stack Generals’ Problem State Acknowledge. 13 Eonblast
  • 14. An Erlang Game Stack Generals’ Problem State ACK the ACK. Etc. 14 Eonblast
  • 15. An Erlang Game Stack Generals’ Problem State The messenger may get lost. 15 Eonblast
  • 16. An Erlang Game Stack Byzantine Generals State The generals, too. 16 Eonblast
  • 17. An Erlang Game Stack The Hunt Server Stack • Language • Database • Protocol • Game Logic 17 Eonblast
  • 18. An Erlang Game Stack Spec “Table Game” • 1 million active players • 1 million transactions per second • 1 second latency • Linear scale • 100% data integrity 18 Eonblast
  • 19. An Erlang Game Stack Client Architecture • Fat JavaScript Browser Client • COMET Not discussed in this talk. 19 Eonblast
  • 20. An Erlang Game Stack Language Wishlist • Robustness • Deadlock-free • Multi-core • Linear Scale er? 20 Eonblast
  • 21. An Erlang Game Stack Database CAP • Distributed • Consistent • Highly-available • Partition-tolerant All of it! Brewer on CAP 2012: http://www.infoq.com/articles/cap-twelve-years-later-how-the-rules-have-changed 21 Eonblast
  • 22. An Erlang Game Stack Database ACID • Atomicity • Consistency • Isolation • Durability For Granted? 22 Eonblast
  • 23. An Erlang Game Stack Database Double Bookkeeping • Not every game needs it • Requires ACID Transactions • Neigh impossible to emulate • Impossible with BASE / Eventual Consistency 23 Eonblast
  • 24. An Erlang Game Stack Database Upcoming Blog Post • Looking at 14 databases • Riak, Cassandra, Membase, H-Base, Voldemort, MySQL, MySQL Cluster, Redis, Redis Cluster, Tokyo Cabinet, Memcached, CouchDB, Couchbase, VoltDB, MongoDB, Postgres • In the light of what games need • Unbiased comparison • Twitter @hdiedrich 24 Eonblast
  • 25. An Erlang Game Stack Protocol Wishlist • Small footprint • Fast to encode • Human-readable 25 Eonblast
  • 26. An Erlang Game Stack Logic Wishlist • Human Readable • Stable • Fast • Concise • Small Footprint 26 Eonblast
  • 27. An Erlang Game Stack The Answers • Client • Protocol • Server • Logic • Data Client: HTML5/JS, Protocol: JSON, Server: Erlang, Logic: Lua, Data: VoltDB. 27 Eonblast
  • 28. An Erlang Game Stack “Embeddable scripting language” 28 Eonblast
  • 29. An Erlang Game Stack Lua ”Lua is strange.“ R. Virding “It has mutable variables, what more need I say.” 29 Eonblast
  • 30. An Erlang Game Stack Lua a = “Roberto” if a ~= nil then print “Hello ” .. a .. “!” end 30 Eonblast
  • 31. An Erlang Game Stack Lua • Created 1993 • Simple, imperative syntax • Stable syntax, stable VMs • Two main VMs: ISO C, JIT • Game scripting champion • Open Source, 100% dictatorial* *benevolent, of course Site: http://www.lua.org List: lua-l@lists.lua.org 31 Eonblast
  • 32. An Erlang Game Stack Lua • Made for non-programmers - imperative syntax • Powerful for programmers - Scheme semantics • Made for DSLs - extensible semantics • Made to be extended - simple C API • Made to be embedded - small VM footprint • Now with a native Erlang VM! 32 Eonblast
  • 33. An Erlang Game Stack Lua Caveats • Deceiving Looks • Encourages magic • Simple but not for beginners • Syntax forked • Only one collection type 33 Eonblast
  • 34. An Erlang Game Stack Lua VMs • PUC Reference VM pure ISO C Lua 5.2 super compatible • JIT VM X86, ARM, PPC, MIPS remains at Lua 5.1 super fast adds extensions • Luerl native Erlang VM Lua 5.2 super stable incomplete 34 Eonblast
  • 35. An Erlang Game Stack Architecture 35 Eonblast
  • 36. An Erlang Game Stack Perceived reaction to asking about benchmarks on the Erlang mailing list. 36 Eonblast
  • 37. An Erlang Game Stack World State State Where does the state go? Into the Logic core, for speed. 37 Eonblast
  • 38. An Erlang Game Stack World State State State State State State State 38 Eonblast
  • 39. An Erlang Game Stack World State State State State State State State 39 Eonblast
  • 40. An Erlang Game Stack World State State State State State State State 40 Eonblast
  • 41. An Erlang Game Stack World State State State State State State State 41 Eonblast
  • 42. An Erlang Game Stack “High Velocity Database” 42 Eonblast
  • 43. An Erlang Game Stack VoltDB • Created 2009 • Simple SQL syntax • Stable 2.5 • Commercial developer, support • High Velocity Secret Tip • Open Source, 100% dictatorial* *benevolent, of course Site: http://www.voltdb.com Help: http://community.voltdb.com/forum 43 Eonblast
  • 44. An Erlang Game Stack VoltDB • ACID transactions – double bookkeeping • SQL – subset of '92 • Linear scale - „unlimited“ data (but ...) • Made for OLTP - fast, cheap writes, high throughput • “More SQL than SQL” – invites clean sep. of data • In-memory - 100x faster than MySQL • Replication, Snapshots – 'hot backup built in' 44 Eonblast
  • 45. An Erlang Game Stack VoltDB Caveats • Less agile than MySQL/NoSQL • Need to understand partitions • Must program SPs in Java • Not elastic (yet) • No online schema change (yet) • There is always a bottleneck • Simple but not for beginners 45 Eonblast
  • 46. An Erlang Game Stack Horizonzal Partitions State # 46 Eonblast
  • 47. An Erlang Game Stack Replication State # 47 Eonblast
  • 48. An Erlang Game Stack Actual Connections State State State State State State 48 Eonblast
  • 49. An Erlang Game Stack The Mix Erlang + Lua + VoltDB 49 Eonblast
  • 50. An Erlang Game Stack How do we connect these components? 50 Eonblast
  • 51. An Erlang Game Stack Fleece Erlualib Erlvolt 51 Eonblast
  • 52. An Erlang Game Stack Fleece Luerl Erlvolt 52 Eonblast
  • 53. An Erlang Game Stack The Packages • Protocol Fleece Lua to JSON • Logic Erlualib Lua port • Logic Luerl Lua VM • Data Erlvolt VoltDB driver 53 Eonblast
  • 54. An Erlang Game Stack Erlualib • Lua embedding library for Erlang • Lua state in original PUC Lua VM • A fast way • A not secure way: can crash Erlang 54 Eonblast
  • 55. An Erlang Game Stack Erlualib hello() -> % get handle of the Lua engine {ok, L} = lua:new_s tate(), % put " print" global on top of s tack lua:getfield(L, global, " print" ), % put hello on top lua:pus hs tring(L, " Hello from Lua!" ), % exec ute on top 2 values on s tac k lua:c all(L, 1, 0). 55 Eonblast
  • 56. An Erlang Game Stack Erlualib hello() -> {ok, L} = lua:new_s tate(), lua:getfield(L, global, " print" ), lua:pus hs tring(L, " Hello from Lua!" ), lua:c all(L, 1, 0). 56 Eonblast
  • 57. An Erlang Game Stack Luerl • New Lua VM programmed in Erlang • Perfectly secure way • Precompiled Chunks • Re-usable State • Work in progress 57 Eonblast
  • 58. An Erlang Game Stack Luerl hello() -> L = luerl:init(), luerl:do(" print('Hello from Lua!')" , L). 58 Eonblast
  • 59. An Erlang Game Stack Luerl hello() -> L = luerl:init(), C hunk = luerl:eval(" print('Hello from Lua!')" , L), luerl:call(C hunk, L) % C hunk and L c an be re-us ed. 59 Eonblast
  • 60. An Erlang Game Stack Benchmark Luerl vs Erlualib Erlualib / PUC Luerl 270 µs state Init 250 µs 10 µs parse 1 + 1 15 µs 2.5 µs execute 1 + 1 13 µs 23 µs parse formula 63 µs 2.5 µs execute formula 35 µs 2.5 µs call a function 28 µs Formula: a = 7.33; b = 9000; c = (33 * a / b) ^ 15 * a + b 60 Eonblast
  • 61. An Erlang Game Stack Fast Lua to JSON encoder 61 Eonblast
  • 62. An Erlang Game Stack Fleece • Fastest Lua JSON encoder • C+ASM or ISO C • Faster than Lua JIT • Faster than concat • 10x faster than other fastest 62 Eonblast
  • 63. An Erlang Game Stack 63 Eonblast
  • 64. An Erlang Game Stack Erlvolt • Native Erlang VoltDB driver • Async parallel data shuffling • Coming next quarter • Your help is wanted • Connect over github 64 Eonblast
  • 65. An Erlang Game Stack Server Architecture • Erlang • Luerl • Lua • Erlualib • JSON • Fleece • VoltDB • Erlvolt 65 Eonblast
  • 66. An Erlang Game Stack Invitation • All at github • All w/samples & docs • All maintained by Eonblast • Luerl maintained by R. Virding • Updates @hdiedrich, @rvirding 66 Eonblast
  • 67. An Erlang Game Stack Questions Mail: hdiedrich ∂ eonblast.com Skype: eonblast Twitter: @hdiedrich 67 Eonblast