SlideShare a Scribd company logo
1 of 18
Download to read offline
构建 ActionScript 游戏服务器,
 支持超过 15000 并发连接
Building an ActionScript Game Server with over
        15,000 Concurrent Connections


             Renaun Erickson

                                       1
Basic MMO Game Architecture

                 •   Clients
                 •   Servers
                 •   Databases
                 •   Networking




                          2
MMO Network Considerations


•   Protocols (TCP, UDP, HTTP)
•   Firewalls
•   Latency
•   Packet Size
•   Data Schema



                                 3
Have to be able to create large
 number of connections that can
send packets at a reasonable rate
        and bandwidth




                             4
Socket Implementations
• Check each file descriptor each frame
  – Select, poll
     • Slow for large number of connections
• OS Optimized
  – Epoll, kqueue, /dev/poll, pollset, I/O Completion
    Ports
     • OS specific fast implementations
• Event based libraries
  – Libevent and libev
     • Fast for large number of connections
     • Portable code, hides OS specific implementations


                                                 5
Server Configuration

• Tell OS to allow large number of file
  descriptors
• Tell OS how much ram for each file
  descriptor
• Tell OS buffer sizes for network protocols
• Tell OS what ports range to use, only 65k
  ports per IP

                                      6
Flash on the Client and Server

• Many MMOs in China use Flash as the
  Client
• Server naturally has MMO game logic
• Put game logic on server for security
• Many benefits of using the same
  language on client and server

Is ActionScript on the server possible?

                                      7
ActionScript on the Server

• Flash Player Dissected
  – Core – VM, Primitives, ActionScript syntax
  – APIs – C/C++ classes implementing rich Flash
    Player API and features
• Tamarin
  – Open sourced core parts of the Flash Player
  – No rich API or features, you have to write
    them yourself


                                         8
Tamarin Projects

• Thane (part of Whirled SDK by ThreeRings)
  – http://wiki.whirled.com/Whirled_SDK
• Redtamarin (by zwetan and others)
  – http://code.google.com/p/redtamarin/
• PushButton Engines Network component by
  Ben Garney
  – https://github.com/PushButtonLabs/PBNetwork
    ing


                                           9
Case Study: SpellTraction




Design By: Garth Braithwaite http://www.garthdb.com/ @garthdb
                                                    10
Live Demo and Source Code


• http://renaun.com/serveras/test
• http://renaun.com/serveras/spelltraction/
• https://github.com/renaun/ActionScriptGa
  meServerExamples




                                    11
Server Setup
• Game Server
  – Amazon EC2 Medium Server
  – 64 bit Ubuntu OS
  – Running two game instances
    • Main
    • Load Test
• Load Test Server
  – Amazon EC2 Medium Server
  – Custom test scripts


                                 12
Server Code

• Redtamarin
  – Created ServerSocket.as – libev socket
    implementation
  – Compile ActionScript files into ActionScript
    Byte Code (abc files)
  – Command line redtamarin shell runs the abc
    files



                                          13
Server ActionScript Code
function loopHandler():void
{
        if (!ss.listening)
                ss.listen("10.111.33.190", 12122);
        else
                serverBrain.beat(); // Game Tick
}

var serverDispatcher:SocketServerNerveDispatcher
        = new SocketServerNerveDispatcher();
var serverBrain:ServerBrain = new ServerBrain();
var serverNerve:ServerNerveSystem
         = new ServerNerveSystem(serverBrain, serverDispatcher);
serverBrain.addNerve(serverNerve);
var ss:ServerSocket
         = serverDispatcher.createServerSocket(serverNerve);
ss.loop.add(loopHandler);
ss.start(250);




                                                        14
Libev Socket Implementation
bool ServerSocketObject::_listen(Stringp host, const int port)
{
    struct socket_io w_accept;

    StUTF8String hostUTF8(host);
    const char* hostAddr = hostUTF8.c_str();

    if( (w_accept.fd = socket(PF_INET, SOCK_STREAM, 0)) < 0 ) return false;
    int flags = fcntl(w_accept.fd, F_GETFL, 0);
    fcntl(w_accept.fd, F_SETFL, (flags > 0 ? flags : 0) | O_NONBLOCK);

    sockaddr_in addr;
    memset(&addr, 0, sizeof(addr));
    addr.sin_family = AF_INET;
    addr.sin_addr.s_addr = inet_addr(hostAddr);
    addr.sin_port = htons(port);
    int status = bind(w_accept.fd, reinterpret_cast<struct sockaddr *>(&addr), sizeof(addr));
    if (status != 0) return false;

    _socket = w_accept.fd;
    if (listen(w_accept.fd, 2) < 0) return false;
    w_accept.socketObject = this;

    // Initialize and start a watcher to accepts client requests
    ev_io_init(&w_accept.io, accept_cb, w_accept.fd, EV_READ);
    ev_io_start(loop_ev, &w_accept.io);
    ev_loop(loop_ev, 0);
    return true;
}



                                                                                 15
Linux Kernel Configurations
/etc/sysctl.conf
net.core.rmem_max = 33554432
net.core.wmem_max = 33554432
net.core.rmem_default = 1048576
net.core.wmem_default = 1048576
net.core.optmem_max = 33554432
net.ipv4.tcp_rmem = 4096 4096 33554432
net.ipv4.tcp_wmem = 4096 4096 33554432
net.ipv4.tcp_mem = 786432 1048576 26777216
net.ipv4.tcp_max_tw_buckets = 360000
net.core.netdev_max_backlog = 30000
net.ipv4.ip_local_port_range = 2048 65535
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_no_metrics_save = 1
net.core.somaxconn = 131072
fs.file-max = 131072

/usr/include/linux/limits.h
NR_OPEN = 65536
/etc/security/limits.conf
*                soft     nofile        65535
*                hard     nofile        65535




                                                16
Client Code
Client




                       Shared Code




Server



                             17
Q/A


  renaun@adobe.com

  http://github.com/renaun

  @renaun

  http://renaun.com/blog




                       18

More Related Content

What's hot

Photon Session / Unite12 Conference
Photon Session / Unite12 ConferencePhoton Session / Unite12 Conference
Photon Session / Unite12 ConferenceChristof Wegmann
 
BGF 2012 (Browsergames Forum)
BGF 2012 (Browsergames Forum)BGF 2012 (Browsergames Forum)
BGF 2012 (Browsergames Forum)Christof Wegmann
 
Highly available Drupal on a Raspberry Pi cluster
Highly available Drupal on a Raspberry Pi clusterHighly available Drupal on a Raspberry Pi cluster
Highly available Drupal on a Raspberry Pi clusterJeff Geerling
 
Drupal RPG - A Backend Server Story
Drupal RPG - A Backend Server StoryDrupal RPG - A Backend Server Story
Drupal RPG - A Backend Server StoryEladio Jose Abquina
 
Happy Browser, Happy User! WordSesh 2019
Happy Browser, Happy User! WordSesh 2019Happy Browser, Happy User! WordSesh 2019
Happy Browser, Happy User! WordSesh 2019Katie Sylor-Miller
 
MongoDB on Azure - Tips, Tricks and Examples
MongoDB on Azure - Tips, Tricks and ExamplesMongoDB on Azure - Tips, Tricks and Examples
MongoDB on Azure - Tips, Tricks and ExamplesMongoDB
 
Server architecture & scaling strategy for a sports website
Server architecture & scaling strategy for a sports websiteServer architecture & scaling strategy for a sports website
Server architecture & scaling strategy for a sports websiteLeonidas Tsementzis
 
Heroes of Paragon: publishing Unity WebGL game on Facebook
Heroes of Paragon: publishing Unity WebGL game on FacebookHeroes of Paragon: publishing Unity WebGL game on Facebook
Heroes of Paragon: publishing Unity WebGL game on FacebookDevGAMM Conference
 
Microsoft Azure Media Services
Microsoft Azure Media ServicesMicrosoft Azure Media Services
Microsoft Azure Media ServicesPavel Revenkov
 
Stream processing in Mercari - Devsumi 2015 autumn LT
Stream processing in Mercari - Devsumi 2015 autumn LTStream processing in Mercari - Devsumi 2015 autumn LT
Stream processing in Mercari - Devsumi 2015 autumn LTMasahiro Nagano
 
Windows Azure Virtual Machines And Virtual Networks
Windows Azure Virtual Machines And Virtual NetworksWindows Azure Virtual Machines And Virtual Networks
Windows Azure Virtual Machines And Virtual NetworksKristof Rennen
 
Level Up: 5 Expert Tips for Optimizing WordPress Performance
Level Up: 5 Expert Tips for Optimizing WordPress PerformanceLevel Up: 5 Expert Tips for Optimizing WordPress Performance
Level Up: 5 Expert Tips for Optimizing WordPress PerformancePantheon
 
Building a Docker Swarm cluster on ARM by Dieter Reuter and Stefan Scherer
Building a Docker Swarm cluster on ARM by Dieter Reuter and Stefan Scherer Building a Docker Swarm cluster on ARM by Dieter Reuter and Stefan Scherer
Building a Docker Swarm cluster on ARM by Dieter Reuter and Stefan Scherer Docker, Inc.
 
Building Multiplayer Games (w/ Unity)
Building Multiplayer Games (w/ Unity)Building Multiplayer Games (w/ Unity)
Building Multiplayer Games (w/ Unity)Noam Gat
 
OGDC Datastorage Solution_Mr.Dung, Dinh Nguyen Anh
OGDC Datastorage Solution_Mr.Dung, Dinh Nguyen AnhOGDC Datastorage Solution_Mr.Dung, Dinh Nguyen Anh
OGDC Datastorage Solution_Mr.Dung, Dinh Nguyen AnhBuff Nguyen
 

What's hot (20)

Photon Session / Unite12 Conference
Photon Session / Unite12 ConferencePhoton Session / Unite12 Conference
Photon Session / Unite12 Conference
 
BGF 2012 (Browsergames Forum)
BGF 2012 (Browsergames Forum)BGF 2012 (Browsergames Forum)
BGF 2012 (Browsergames Forum)
 
Highly available Drupal on a Raspberry Pi cluster
Highly available Drupal on a Raspberry Pi clusterHighly available Drupal on a Raspberry Pi cluster
Highly available Drupal on a Raspberry Pi cluster
 
Drupal RPG - A Backend Server Story
Drupal RPG - A Backend Server StoryDrupal RPG - A Backend Server Story
Drupal RPG - A Backend Server Story
 
Automating with Ansible
Automating with AnsibleAutomating with Ansible
Automating with Ansible
 
Happy Browser, Happy User! WordSesh 2019
Happy Browser, Happy User! WordSesh 2019Happy Browser, Happy User! WordSesh 2019
Happy Browser, Happy User! WordSesh 2019
 
Ansible 101
Ansible 101Ansible 101
Ansible 101
 
MongoDB on Azure - Tips, Tricks and Examples
MongoDB on Azure - Tips, Tricks and ExamplesMongoDB on Azure - Tips, Tricks and Examples
MongoDB on Azure - Tips, Tricks and Examples
 
Nodejs web,db,hosting
Nodejs web,db,hostingNodejs web,db,hosting
Nodejs web,db,hosting
 
Server architecture & scaling strategy for a sports website
Server architecture & scaling strategy for a sports websiteServer architecture & scaling strategy for a sports website
Server architecture & scaling strategy for a sports website
 
Heroes of Paragon: publishing Unity WebGL game on Facebook
Heroes of Paragon: publishing Unity WebGL game on FacebookHeroes of Paragon: publishing Unity WebGL game on Facebook
Heroes of Paragon: publishing Unity WebGL game on Facebook
 
Microsoft Azure Media Services
Microsoft Azure Media ServicesMicrosoft Azure Media Services
Microsoft Azure Media Services
 
Photon Load Test #1
Photon Load Test #1Photon Load Test #1
Photon Load Test #1
 
Stream processing in Mercari - Devsumi 2015 autumn LT
Stream processing in Mercari - Devsumi 2015 autumn LTStream processing in Mercari - Devsumi 2015 autumn LT
Stream processing in Mercari - Devsumi 2015 autumn LT
 
Windows Azure Virtual Machines And Virtual Networks
Windows Azure Virtual Machines And Virtual NetworksWindows Azure Virtual Machines And Virtual Networks
Windows Azure Virtual Machines And Virtual Networks
 
ansible why ?
ansible why ?ansible why ?
ansible why ?
 
Level Up: 5 Expert Tips for Optimizing WordPress Performance
Level Up: 5 Expert Tips for Optimizing WordPress PerformanceLevel Up: 5 Expert Tips for Optimizing WordPress Performance
Level Up: 5 Expert Tips for Optimizing WordPress Performance
 
Building a Docker Swarm cluster on ARM by Dieter Reuter and Stefan Scherer
Building a Docker Swarm cluster on ARM by Dieter Reuter and Stefan Scherer Building a Docker Swarm cluster on ARM by Dieter Reuter and Stefan Scherer
Building a Docker Swarm cluster on ARM by Dieter Reuter and Stefan Scherer
 
Building Multiplayer Games (w/ Unity)
Building Multiplayer Games (w/ Unity)Building Multiplayer Games (w/ Unity)
Building Multiplayer Games (w/ Unity)
 
OGDC Datastorage Solution_Mr.Dung, Dinh Nguyen Anh
OGDC Datastorage Solution_Mr.Dung, Dinh Nguyen AnhOGDC Datastorage Solution_Mr.Dung, Dinh Nguyen Anh
OGDC Datastorage Solution_Mr.Dung, Dinh Nguyen Anh
 

Viewers also liked

Social Game
Social GameSocial Game
Social Gameematrix
 
构建ActionScript游戏服务器,支持超过15000并发连接
构建ActionScript游戏服务器,支持超过15000并发连接 构建ActionScript游戏服务器,支持超过15000并发连接
构建ActionScript游戏服务器,支持超过15000并发连接 Renaun Erickson
 
Astral game server
Astral game serverAstral game server
Astral game serverastralgame
 
China game-server-vpn-to-reduce-delay-abroad
China game-server-vpn-to-reduce-delay-abroadChina game-server-vpn-to-reduce-delay-abroad
China game-server-vpn-to-reduce-delay-abroadJ enny
 
閒聊Python應用在game server的開發
閒聊Python應用在game server的開發閒聊Python應用在game server的開發
閒聊Python應用在game server的開發Eric Chen
 
How_to_build_GameServer_2
How_to_build_GameServer_2How_to_build_GameServer_2
How_to_build_GameServer_2Peter Rybar
 
Multi thread game server
Multi thread game serverMulti thread game server
Multi thread game serverOnGameServer
 
SDC 3rd 안중원님 - InGame CashShop 개발 하기
SDC 3rd 안중원님 - InGame CashShop 개발 하기SDC 3rd 안중원님 - InGame CashShop 개발 하기
SDC 3rd 안중원님 - InGame CashShop 개발 하기OnGameServer
 
Next-generation MMORPG service architecture
Next-generation MMORPG service architectureNext-generation MMORPG service architecture
Next-generation MMORPG service architectureJongwon Kim
 
C/C++调试、跟踪及性能分析工具综述
C/C++调试、跟踪及性能分析工具综述C/C++调试、跟踪及性能分析工具综述
C/C++调试、跟踪及性能分析工具综述Xiaozhe Wang
 
TIP1 - Overview of C/C++ Debugging/Tracing/Profiling Tools
TIP1 - Overview of C/C++ Debugging/Tracing/Profiling ToolsTIP1 - Overview of C/C++ Debugging/Tracing/Profiling Tools
TIP1 - Overview of C/C++ Debugging/Tracing/Profiling ToolsXiaozhe Wang
 
Маркетинг 2015 - основни правила за малкия и среден бизнес
Маркетинг 2015 - основни правила за малкия и среден бизнесМаркетинг 2015 - основни правила за малкия и среден бизнес
Маркетинг 2015 - основни правила за малкия и среден бизнесJustine Toms
 
Почему не работают корпоративные социальные сети?
Почему не работают корпоративные социальные сети?Почему не работают корпоративные социальные сети?
Почему не работают корпоративные социальные сети?Anna Nesmeeva
 
はじめてのLWF for Open Hack Day
はじめてのLWF for Open Hack DayはじめてのLWF for Open Hack Day
はじめてのLWF for Open Hack DayDaniel-Hiroyuki Haga
 
Checkout proceso optimizavimas el. parduotuvėse
Checkout proceso optimizavimas el. parduotuvėseCheckout proceso optimizavimas el. parduotuvėse
Checkout proceso optimizavimas el. parduotuvėseVladas Sapranavicius
 
Innovative Uses of Technology in International Education
Innovative Uses of Technology in International Education Innovative Uses of Technology in International Education
Innovative Uses of Technology in International Education Marty Bennett
 
Ultizing Online Space: Virtual Fairs and Online Conversion Tools (with poll r...
Ultizing Online Space: Virtual Fairs and Online Conversion Tools (with poll r...Ultizing Online Space: Virtual Fairs and Online Conversion Tools (with poll r...
Ultizing Online Space: Virtual Fairs and Online Conversion Tools (with poll r...Marty Bennett
 
anybuild/Hosting casual #1
anybuild/Hosting casual #1anybuild/Hosting casual #1
anybuild/Hosting casual #1Ryo Kuroda
 

Viewers also liked (20)

Social Game
Social GameSocial Game
Social Game
 
构建ActionScript游戏服务器,支持超过15000并发连接
构建ActionScript游戏服务器,支持超过15000并发连接 构建ActionScript游戏服务器,支持超过15000并发连接
构建ActionScript游戏服务器,支持超过15000并发连接
 
Astral game server
Astral game serverAstral game server
Astral game server
 
China game-server-vpn-to-reduce-delay-abroad
China game-server-vpn-to-reduce-delay-abroadChina game-server-vpn-to-reduce-delay-abroad
China game-server-vpn-to-reduce-delay-abroad
 
閒聊Python應用在game server的開發
閒聊Python應用在game server的開發閒聊Python應用在game server的開發
閒聊Python應用在game server的開發
 
How_to_build_GameServer_2
How_to_build_GameServer_2How_to_build_GameServer_2
How_to_build_GameServer_2
 
Multi thread game server
Multi thread game serverMulti thread game server
Multi thread game server
 
SDC 3rd 안중원님 - InGame CashShop 개발 하기
SDC 3rd 안중원님 - InGame CashShop 개발 하기SDC 3rd 안중원님 - InGame CashShop 개발 하기
SDC 3rd 안중원님 - InGame CashShop 개발 하기
 
Next-generation MMORPG service architecture
Next-generation MMORPG service architectureNext-generation MMORPG service architecture
Next-generation MMORPG service architecture
 
C/C++调试、跟踪及性能分析工具综述
C/C++调试、跟踪及性能分析工具综述C/C++调试、跟踪及性能分析工具综述
C/C++调试、跟踪及性能分析工具综述
 
TIP1 - Overview of C/C++ Debugging/Tracing/Profiling Tools
TIP1 - Overview of C/C++ Debugging/Tracing/Profiling ToolsTIP1 - Overview of C/C++ Debugging/Tracing/Profiling Tools
TIP1 - Overview of C/C++ Debugging/Tracing/Profiling Tools
 
Маркетинг 2015 - основни правила за малкия и среден бизнес
Маркетинг 2015 - основни правила за малкия и среден бизнесМаркетинг 2015 - основни правила за малкия и среден бизнес
Маркетинг 2015 - основни правила за малкия и среден бизнес
 
Почему не работают корпоративные социальные сети?
Почему не работают корпоративные социальные сети?Почему не работают корпоративные социальные сети?
Почему не работают корпоративные социальные сети?
 
はじめてのLWF for Open Hack Day
はじめてのLWF for Open Hack DayはじめてのLWF for Open Hack Day
はじめてのLWF for Open Hack Day
 
resumeh aali1
resumeh aali1resumeh aali1
resumeh aali1
 
Checkout proceso optimizavimas el. parduotuvėse
Checkout proceso optimizavimas el. parduotuvėseCheckout proceso optimizavimas el. parduotuvėse
Checkout proceso optimizavimas el. parduotuvėse
 
Innovative Uses of Technology in International Education
Innovative Uses of Technology in International Education Innovative Uses of Technology in International Education
Innovative Uses of Technology in International Education
 
Ultizing Online Space: Virtual Fairs and Online Conversion Tools (with poll r...
Ultizing Online Space: Virtual Fairs and Online Conversion Tools (with poll r...Ultizing Online Space: Virtual Fairs and Online Conversion Tools (with poll r...
Ultizing Online Space: Virtual Fairs and Online Conversion Tools (with poll r...
 
anybuild/Hosting casual #1
anybuild/Hosting casual #1anybuild/Hosting casual #1
anybuild/Hosting casual #1
 
portfolio_tmajasaari
portfolio_tmajasaariportfolio_tmajasaari
portfolio_tmajasaari
 

Similar to Building an ActionScript Game Server with over 15,000 Concurrent Connections

Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsOhad Kravchick
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Bare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and ChefBare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and ChefMatt Ray
 
PostgresOpen 2013 A Comparison of PostgreSQL Encryption Options
PostgresOpen 2013 A Comparison of PostgreSQL Encryption OptionsPostgresOpen 2013 A Comparison of PostgreSQL Encryption Options
PostgresOpen 2013 A Comparison of PostgreSQL Encryption OptionsFaisal Akber
 
Kubernetes deployment on bare metal with container linux
Kubernetes deployment on bare metal with container linuxKubernetes deployment on bare metal with container linux
Kubernetes deployment on bare metal with container linuxmacchiang
 
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...NGINX, Inc.
 
Exploring the Final Frontier of Data Center Orchestration: Network Elements -...
Exploring the Final Frontier of Data Center Orchestration: Network Elements -...Exploring the Final Frontier of Data Center Orchestration: Network Elements -...
Exploring the Final Frontier of Data Center Orchestration: Network Elements -...Puppet
 
php & performance
 php & performance php & performance
php & performancesimon8410
 
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon YangPractical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon YangLyon Yang
 
Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012Joe Arnold
 
Advanced RAC troubleshooting: Network
Advanced RAC troubleshooting: NetworkAdvanced RAC troubleshooting: Network
Advanced RAC troubleshooting: NetworkRiyaj Shamsudeen
 
End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...
End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...
End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...DataWorks Summit/Hadoop Summit
 
Ironic 140622212631-phpapp02
Ironic 140622212631-phpapp02Ironic 140622212631-phpapp02
Ironic 140622212631-phpapp02Narender Kumar
 
Ironic 140622212631-phpapp02
Ironic 140622212631-phpapp02Ironic 140622212631-phpapp02
Ironic 140622212631-phpapp02Narender Kumar
 
Container & kubernetes
Container & kubernetesContainer & kubernetes
Container & kubernetesTed Jung
 
FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101Rami Sayar
 
Game server development in node.js in jsconf eu
Game server development in node.js in jsconf euGame server development in node.js in jsconf eu
Game server development in node.js in jsconf euXie ChengChao
 

Similar to Building an ActionScript Game Server with over 15,000 Concurrent Connections (20)

Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js Applications
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Bare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and ChefBare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and Chef
 
PostgresOpen 2013 A Comparison of PostgreSQL Encryption Options
PostgresOpen 2013 A Comparison of PostgreSQL Encryption OptionsPostgresOpen 2013 A Comparison of PostgreSQL Encryption Options
PostgresOpen 2013 A Comparison of PostgreSQL Encryption Options
 
Kubernetes deployment on bare metal with container linux
Kubernetes deployment on bare metal with container linuxKubernetes deployment on bare metal with container linux
Kubernetes deployment on bare metal with container linux
 
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
 
Exploring the Final Frontier of Data Center Orchestration: Network Elements -...
Exploring the Final Frontier of Data Center Orchestration: Network Elements -...Exploring the Final Frontier of Data Center Orchestration: Network Elements -...
Exploring the Final Frontier of Data Center Orchestration: Network Elements -...
 
php & performance
 php & performance php & performance
php & performance
 
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon YangPractical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
 
Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012
 
Advanced RAC troubleshooting: Network
Advanced RAC troubleshooting: NetworkAdvanced RAC troubleshooting: Network
Advanced RAC troubleshooting: Network
 
End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...
End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...
End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...
 
Unidade3 roteiro proxy
Unidade3 roteiro proxyUnidade3 roteiro proxy
Unidade3 roteiro proxy
 
Ironic 140622212631-phpapp02
Ironic 140622212631-phpapp02Ironic 140622212631-phpapp02
Ironic 140622212631-phpapp02
 
Ironic 140622212631-phpapp02
Ironic 140622212631-phpapp02Ironic 140622212631-phpapp02
Ironic 140622212631-phpapp02
 
Ironic
IronicIronic
Ironic
 
Container & kubernetes
Container & kubernetesContainer & kubernetes
Container & kubernetes
 
A.java
A.javaA.java
A.java
 
FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101
 
Game server development in node.js in jsconf eu
Game server development in node.js in jsconf euGame server development in node.js in jsconf eu
Game server development in node.js in jsconf eu
 

Recently uploaded

UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPathCommunity
 
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
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7DianaGray10
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-pyJamie (Taka) Wang
 
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
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Will Schroeder
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
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
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
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
 
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
 
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
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXTarek Kalaji
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
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
 

Recently uploaded (20)

UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation Developers
 
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 )
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-py
 
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.
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
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
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
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...
 
20150722 - AGV
20150722 - AGV20150722 - AGV
20150722 - AGV
 
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
 
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
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBX
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).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
 

Building an ActionScript Game Server with over 15,000 Concurrent Connections

  • 1. 构建 ActionScript 游戏服务器, 支持超过 15000 并发连接 Building an ActionScript Game Server with over 15,000 Concurrent Connections Renaun Erickson 1
  • 2. Basic MMO Game Architecture • Clients • Servers • Databases • Networking 2
  • 3. MMO Network Considerations • Protocols (TCP, UDP, HTTP) • Firewalls • Latency • Packet Size • Data Schema 3
  • 4. Have to be able to create large number of connections that can send packets at a reasonable rate and bandwidth 4
  • 5. Socket Implementations • Check each file descriptor each frame – Select, poll • Slow for large number of connections • OS Optimized – Epoll, kqueue, /dev/poll, pollset, I/O Completion Ports • OS specific fast implementations • Event based libraries – Libevent and libev • Fast for large number of connections • Portable code, hides OS specific implementations 5
  • 6. Server Configuration • Tell OS to allow large number of file descriptors • Tell OS how much ram for each file descriptor • Tell OS buffer sizes for network protocols • Tell OS what ports range to use, only 65k ports per IP 6
  • 7. Flash on the Client and Server • Many MMOs in China use Flash as the Client • Server naturally has MMO game logic • Put game logic on server for security • Many benefits of using the same language on client and server Is ActionScript on the server possible? 7
  • 8. ActionScript on the Server • Flash Player Dissected – Core – VM, Primitives, ActionScript syntax – APIs – C/C++ classes implementing rich Flash Player API and features • Tamarin – Open sourced core parts of the Flash Player – No rich API or features, you have to write them yourself 8
  • 9. Tamarin Projects • Thane (part of Whirled SDK by ThreeRings) – http://wiki.whirled.com/Whirled_SDK • Redtamarin (by zwetan and others) – http://code.google.com/p/redtamarin/ • PushButton Engines Network component by Ben Garney – https://github.com/PushButtonLabs/PBNetwork ing 9
  • 10. Case Study: SpellTraction Design By: Garth Braithwaite http://www.garthdb.com/ @garthdb 10
  • 11. Live Demo and Source Code • http://renaun.com/serveras/test • http://renaun.com/serveras/spelltraction/ • https://github.com/renaun/ActionScriptGa meServerExamples 11
  • 12. Server Setup • Game Server – Amazon EC2 Medium Server – 64 bit Ubuntu OS – Running two game instances • Main • Load Test • Load Test Server – Amazon EC2 Medium Server – Custom test scripts 12
  • 13. Server Code • Redtamarin – Created ServerSocket.as – libev socket implementation – Compile ActionScript files into ActionScript Byte Code (abc files) – Command line redtamarin shell runs the abc files 13
  • 14. Server ActionScript Code function loopHandler():void { if (!ss.listening) ss.listen("10.111.33.190", 12122); else serverBrain.beat(); // Game Tick } var serverDispatcher:SocketServerNerveDispatcher = new SocketServerNerveDispatcher(); var serverBrain:ServerBrain = new ServerBrain(); var serverNerve:ServerNerveSystem = new ServerNerveSystem(serverBrain, serverDispatcher); serverBrain.addNerve(serverNerve); var ss:ServerSocket = serverDispatcher.createServerSocket(serverNerve); ss.loop.add(loopHandler); ss.start(250); 14
  • 15. Libev Socket Implementation bool ServerSocketObject::_listen(Stringp host, const int port) { struct socket_io w_accept; StUTF8String hostUTF8(host); const char* hostAddr = hostUTF8.c_str(); if( (w_accept.fd = socket(PF_INET, SOCK_STREAM, 0)) < 0 ) return false; int flags = fcntl(w_accept.fd, F_GETFL, 0); fcntl(w_accept.fd, F_SETFL, (flags > 0 ? flags : 0) | O_NONBLOCK); sockaddr_in addr; memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_addr.s_addr = inet_addr(hostAddr); addr.sin_port = htons(port); int status = bind(w_accept.fd, reinterpret_cast<struct sockaddr *>(&addr), sizeof(addr)); if (status != 0) return false; _socket = w_accept.fd; if (listen(w_accept.fd, 2) < 0) return false; w_accept.socketObject = this; // Initialize and start a watcher to accepts client requests ev_io_init(&w_accept.io, accept_cb, w_accept.fd, EV_READ); ev_io_start(loop_ev, &w_accept.io); ev_loop(loop_ev, 0); return true; } 15
  • 16. Linux Kernel Configurations /etc/sysctl.conf net.core.rmem_max = 33554432 net.core.wmem_max = 33554432 net.core.rmem_default = 1048576 net.core.wmem_default = 1048576 net.core.optmem_max = 33554432 net.ipv4.tcp_rmem = 4096 4096 33554432 net.ipv4.tcp_wmem = 4096 4096 33554432 net.ipv4.tcp_mem = 786432 1048576 26777216 net.ipv4.tcp_max_tw_buckets = 360000 net.core.netdev_max_backlog = 30000 net.ipv4.ip_local_port_range = 2048 65535 net.ipv4.tcp_window_scaling = 1 net.ipv4.tcp_no_metrics_save = 1 net.core.somaxconn = 131072 fs.file-max = 131072 /usr/include/linux/limits.h NR_OPEN = 65536 /etc/security/limits.conf * soft nofile 65535 * hard nofile 65535 16
  • 17. Client Code Client Shared Code Server 17
  • 18. Q/A renaun@adobe.com http://github.com/renaun @renaun http://renaun.com/blog 18

Editor's Notes

  1. MMO Server Architecture
  2. Explain what SpellTraction is.