SlideShare a Scribd company logo
Game server development in
node.js
Charlie Crane
@xiecc
Who am I
 NASDAQ: NTES
 Senior engineer, architect(8 years) in NetEase
Inc. , developed many web, game products
 Recently created the open source game server
framework in node.js: pomelo
Agenda
 The state of pomelo
 Motivation
 Framework
 Practice
 Performance
The state of pomelo
Fast, scalable, distributed game
server framework for node.js
Open sourced in 2012.11.20
Newest version: V0.6
https://github.com/NetEase/pomelo
Pomelo position
 Game server framework
 Mobile game
 Web game
 Social game
 MMO RPG(middle scale)
 Realtime application server framework
Realtime Multiple User Interaction
State of pomelo
 Pomelo is not a
single project
 Almost 40 repos in total
Framework ---
State of pomelo -- clients
Success stories
 Chinese mythology
Community
Agenda
 The state of pomelo
 Motivation
 Framework
 Practice
 Performance
Motivation--node.js and game
server
 Game Server
Fast Scalable
Network Real-time
Node.js is a platform built on Chrome's JavaScript
runtime for easily building fast, scalable network
applications. Node.js uses an event-driven, non-
blocking I/O model that makes it lightweight and
efficient, perfect for data-intensive real-time
applications that run across distributed devices.
Motivation--node.js advantages
 Scalability -- event driven I/O
 Game, network-insentive, massive network flow
 Language, javascript
 Browser, HTML5, unity3d, cocos2d-x, other
platform – same language in client and server
 Multi-Process, Single thread
 No lock
 Simple logic
 Lightweight, development efficiency, really quick
Motivation–node.js disadvantage
 Some CPU sensitive actions
 Path finding
 AI
 Solution
 Optimization
 Divide process
 All can be solved in practice
Node.js game—Mozilla
BrowserQuest
Node.js game—google gritsgame
Motivation -- our demo
http://pomelo.netease.com/lordofpomelo
Motivation--architecture of demo
Motivation -- game VS web
 Long connection VS Short connection
 Partition: area based VS Load balanced
cluster
 Stateful VS Stateless
 Request/broadcast VS
Request/response
Motivation--complicate servers
 Game VS web
Motivation--how to solve
complexity
Too … complicated?
solution: framework
Agenda
 The state of pomelo
 Motivation
 Framework
 Practice
 Performance
Pomelo Framework
The essence of pomelo:
A distributed, scalable, realtime
application framework.
Framework --- design goal
 Abstract of servers(processes)
 Auto extend server types
 Auto extend servers
 Abstract of request/response and broadcast/push
 Zero config request
 Simple broadcast api
 Servers communication---rpc framework
Framework --- server abstraction
frontend
frontend
backend
backend
backend
backend
master
Framework--- server abstraction
Duck type
frontend
con
nect
or
backend
area
chat
status
Server abstraction
servers
The
Duck
Framework---server abstraction
Framework --- request
abstraction
 Client call remote method on server
 Client, like ajax
 Server, like web mvc framework
Framework --- request
abstraction
Connector
SIOConnector HybridConnector
Pomelo
component
Loader
MQTTConnecto
r
Socket.io client Socket, websocket
client
Mobile client
Framework -- request abstraction
Socket.io
Socket/We
bSocket
Support socket.io and socket in one project
Framework --- push&broadcast
Push messages to a group of users
channelService.pushMessageByUids(msg,
uids, callback);
var channel =
channelService.getChannel(‘area1’);
channel.pushMessage(msg);
Framework ---
channel&broadcast
area
connectors
client
channel
uids
connector1
connector2
client1
client2
clientn
…
regroup
uids1
uids2
… …
broadcast
 Easy API
 Most frequent action
 Potentially performance
problem
Framework -- rpc framework
Framework – rpc framework
 Why rpc is so easy in pomelo?
 Thrift
 Writing a .thrift file
 Generate Thrift file to source code
thrift --gen <language> <Thrift filename>
 Copy the source to application
 Pomelo—start up, all done
 Client and server in one project
 Servers folder convention
 Auto generate proxy and remote on start up
Agenda
 The state of pomelo
 Overview
 Framework
 Practice
 Performance
Practice --- simplest player move
client
Area1
connector
client1
client2
clientn
…
1、Move
request
3、Move
Handler
2、Forward
4、Backward
5、Broadcast
6、Play move
animation Route rule
1.5
Practice --- Client Move Request
… find path, move animation
pomelo.request(’area.playeHandler.move’
,
{path: path}, function (result){
…
});
Practice --- area server handler
handler.move = function( msg, session,
next) {
… verify path
… handle move, add move action to
tick
channelService.pushMessagesByUids
(
route:’onMove’,
….);
next(null, {pos: playerPos, code:OK});
Practice --- client play move
pomelo.on(‘onMove’,
function(data) {
play move animation
…
});
Practice – route rule
Define once:
app.route(‘area’, routeUtil.area);
Practice --- character move
Character Move, isn’t that easy?
In reality , it’s hard
Practice --- handle move
 Different situations
 Player move, mob move
 AI driven or player driven
 Smooth effect
 Client prediction
 Latency Compensate
 How to notify
 AOI(area of interest)
Agenda
 The state of pomelo
 Overview
 Framework
 Practice
 Performance
Performance --- overview
 The performance varies largely in different
applications
 The variation
 Application type: Game or realtime application
 Game type: round or realtime fight, room or infinite
 Game design: Map size, character density, balance
of areas
 Test parameters: Think time, test action
Performance --- reference data
 Online users per process
 next-gen: support 20,000 concurrent players in one
area
 World record – not in one area
 world of tanks(bigworld), 74,536 online users
 But in real world(MMO rpg)
 The real online data: maximum 800 concurrent users per
area, 7,000 concurrent users per group game servers
Performance--Server
configuration
Server: Openstack virtual machine
Performance --- stress testing
 Use Case 1: fight
 Stress on single area(area 3), increasing
step by step, login every 2 seconds
 Game logic: attack monstors or other
players every 2~5 seconds
Performance --- stress testing
Performance – too crowded
Performance --- stress testing
Performance--result
 486 onlines
Performance -- top
 Using toobusy to limit cpu: 80%
Performance – stress test
 Use case 2 – move
 Stress on single area(area 3), increasing
step by step, login every 2 seconds
 Game logic: move around in the map every
2~5 seconds
Performance – stress test
 800 onlines in 1 area
Performance --- stress testing
 Use Case 3: fight & move
 Stress on single area(area 3), increasing
step by step, login every 2 seconds
 Game logic: 50% attack monstors or other
players every 2~5 seconds, 50% move
around
 Result: 558 onlines in one area
What’s more
 Plugin, components
 Realtime application framework – a better one,
more scalable, adaptable
 AI – pomleo-bt
 Broadcast strategy – pomelo-aoi , schedule
 Data sync strategy – pomelo-sync
 Admin all the servers -- pomelo-admin pomelo-
cli
 How to build a full game – lordofpomelo play
online
 High availability – master and zookeeper
Looking for contributors
 We need you!!!
Q&
A
https://github.com/NetEase/pomelo

More Related Content

What's hot (20)

게임서버프로그래밍 #1 - IOCP
게임서버프로그래밍 #1 - IOCP
Seungmo Koo
 
게임 디자이너와 게임 서버
게임 디자이너와 게임 서버
ByungChun2
 
임태현, 게임 서버 디자인 가이드, NDC2013
임태현, 게임 서버 디자인 가이드, NDC2013
devCAT Studio, NEXON
 
NoSQL 위에서 MMORPG 개발하기
NoSQL 위에서 MMORPG 개발하기
Hoyoung Choi
 
[IGC2018] 에이스프로젝트 안현석 - 유니티로 실시간 멀티플레이 게임서버를 만들 수 있을까?
[IGC2018] 에이스프로젝트 안현석 - 유니티로 실시간 멀티플레이 게임서버를 만들 수 있을까?
강 민우
 
중앙 서버 없는 게임 로직
중앙 서버 없는 게임 로직
Hoyoung Choi
 
게임제작개론 : #6 게임 시스템 구조에 대한 이해
게임제작개론 : #6 게임 시스템 구조에 대한 이해
Seungmo Koo
 
Albion Online - Software Architecture of an MMO (talk at Quo Vadis 2016, Berlin)
Albion Online - Software Architecture of an MMO (talk at Quo Vadis 2016, Berlin)
David Salz
 
임태현, MMO 서버 개발 포스트 모템, NDC2012
임태현, MMO 서버 개발 포스트 모템, NDC2012
devCAT Studio, NEXON
 
게임 개발자가 되고 싶어요
게임 개발자가 되고 싶어요
Lee Sangkyoon (Kay)
 
쿠키런 1년, 서버개발 분투기
쿠키런 1년, 서버개발 분투기
Brian Hong
 
Deterministic Simulation - What modern online games can learn from the Game B...
Deterministic Simulation - What modern online games can learn from the Game B...
David Salz
 
혼자서 만드는 MMO게임 서버
혼자서 만드는 MMO게임 서버
iFunFactory Inc.
 
게임에서 흔히 쓰이는 최적화 전략 by 엄윤섭 @ 지스타 컨퍼런스 2013
게임에서 흔히 쓰이는 최적화 전략 by 엄윤섭 @ 지스타 컨퍼런스 2013
영욱 오
 
Deploy Secure and Scalable Services Across Kubernetes Clusters with NATS
Deploy Secure and Scalable Services Across Kubernetes Clusters with NATS
NATS
 
3 lessons from 9 years of locomotive offers: Data based user segmentation and...
3 lessons from 9 years of locomotive offers: Data based user segmentation and...
GameCamp
 
프로그래머에게 사랑받는 게임 기획서 작성법
프로그래머에게 사랑받는 게임 기획서 작성법
Lee Sangkyoon (Kay)
 
로그 기깔나게 잘 디자인하는 법
로그 기깔나게 잘 디자인하는 법
Jeongsang Baek
 
New tools and services to take your live ops to the next level
New tools and services to take your live ops to the next level
Crystin Cox
 
[NDC14] (공개용)게임 QA에 적용할 수 있는 테스팅 기법과 패턴 활용_황우람
[NDC14] (공개용)게임 QA에 적용할 수 있는 테스팅 기법과 패턴 활용_황우람
Wooram Hwang
 
게임서버프로그래밍 #1 - IOCP
게임서버프로그래밍 #1 - IOCP
Seungmo Koo
 
게임 디자이너와 게임 서버
게임 디자이너와 게임 서버
ByungChun2
 
임태현, 게임 서버 디자인 가이드, NDC2013
임태현, 게임 서버 디자인 가이드, NDC2013
devCAT Studio, NEXON
 
NoSQL 위에서 MMORPG 개발하기
NoSQL 위에서 MMORPG 개발하기
Hoyoung Choi
 
[IGC2018] 에이스프로젝트 안현석 - 유니티로 실시간 멀티플레이 게임서버를 만들 수 있을까?
[IGC2018] 에이스프로젝트 안현석 - 유니티로 실시간 멀티플레이 게임서버를 만들 수 있을까?
강 민우
 
중앙 서버 없는 게임 로직
중앙 서버 없는 게임 로직
Hoyoung Choi
 
게임제작개론 : #6 게임 시스템 구조에 대한 이해
게임제작개론 : #6 게임 시스템 구조에 대한 이해
Seungmo Koo
 
Albion Online - Software Architecture of an MMO (talk at Quo Vadis 2016, Berlin)
Albion Online - Software Architecture of an MMO (talk at Quo Vadis 2016, Berlin)
David Salz
 
임태현, MMO 서버 개발 포스트 모템, NDC2012
임태현, MMO 서버 개발 포스트 모템, NDC2012
devCAT Studio, NEXON
 
게임 개발자가 되고 싶어요
게임 개발자가 되고 싶어요
Lee Sangkyoon (Kay)
 
쿠키런 1년, 서버개발 분투기
쿠키런 1년, 서버개발 분투기
Brian Hong
 
Deterministic Simulation - What modern online games can learn from the Game B...
Deterministic Simulation - What modern online games can learn from the Game B...
David Salz
 
혼자서 만드는 MMO게임 서버
혼자서 만드는 MMO게임 서버
iFunFactory Inc.
 
게임에서 흔히 쓰이는 최적화 전략 by 엄윤섭 @ 지스타 컨퍼런스 2013
게임에서 흔히 쓰이는 최적화 전략 by 엄윤섭 @ 지스타 컨퍼런스 2013
영욱 오
 
Deploy Secure and Scalable Services Across Kubernetes Clusters with NATS
Deploy Secure and Scalable Services Across Kubernetes Clusters with NATS
NATS
 
3 lessons from 9 years of locomotive offers: Data based user segmentation and...
3 lessons from 9 years of locomotive offers: Data based user segmentation and...
GameCamp
 
프로그래머에게 사랑받는 게임 기획서 작성법
프로그래머에게 사랑받는 게임 기획서 작성법
Lee Sangkyoon (Kay)
 
로그 기깔나게 잘 디자인하는 법
로그 기깔나게 잘 디자인하는 법
Jeongsang Baek
 
New tools and services to take your live ops to the next level
New tools and services to take your live ops to the next level
Crystin Cox
 
[NDC14] (공개용)게임 QA에 적용할 수 있는 테스팅 기법과 패턴 활용_황우람
[NDC14] (공개용)게임 QA에 적용할 수 있는 테스팅 기법과 패턴 활용_황우람
Wooram Hwang
 

Viewers also liked (9)

Game server development in node.js
Game server development in node.js
Xie ChengChao
 
Pomelo Logistics 27 Nov 2011
Pomelo Logistics 27 Nov 2011
thaikoraa
 
Citrius family
Citrius family
bonophool banerjee
 
Clementines
Clementines
Katie Boyd McGlenn
 
Citrus fruit variety
Citrus fruit variety
Santi Catanesi
 
Packaging
Packaging
vikash
 
Bao cao do an Phát triển hệ thống game server Online
Bao cao do an Phát triển hệ thống game server Online
Hoàng Phạm
 
Pomelo y limon
Pomelo y limon
cepecole
 
[KGC 2012] Online Game Server Architecture Case Study Performance and Security
[KGC 2012] Online Game Server Architecture Case Study Performance and Security
Seungmin Shin
 
Game server development in node.js
Game server development in node.js
Xie ChengChao
 
Pomelo Logistics 27 Nov 2011
Pomelo Logistics 27 Nov 2011
thaikoraa
 
Packaging
Packaging
vikash
 
Bao cao do an Phát triển hệ thống game server Online
Bao cao do an Phát triển hệ thống game server Online
Hoàng Phạm
 
Pomelo y limon
Pomelo y limon
cepecole
 
[KGC 2012] Online Game Server Architecture Case Study Performance and Security
[KGC 2012] Online Game Server Architecture Case Study Performance and Security
Seungmin Shin
 
Ad

Similar to Game server development in node.js in jsconf eu (20)

Real time web apps
Real time web apps
Sepehr Rasouli
 
introduction to node.js
introduction to node.js
orkaplan
 
Microservices with Node and Docker
Microservices with Node and Docker
Tony Pujals
 
What is Reactive programming?
What is Reactive programming?
Kevin Webber
 
Node.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel Aviv
Ron Perlmuter
 
Nodejs - A quick tour (v5)
Nodejs - A quick tour (v5)
Felix Geisendörfer
 
Scalable Social Architectures by Biren Gandhi
Scalable Social Architectures by Biren Gandhi
Biren Gandhi
 
Farms, Fabrics and Clouds
Farms, Fabrics and Clouds
Steve Loughran
 
ngServer and-collaboratived-development-between-san-francisco-and-tokyo
ngServer and-collaboratived-development-between-san-francisco-and-tokyo
Satoshi Tanaka
 
NodeJS ecosystem
NodeJS ecosystem
Yukti Kaura
 
Webdevcon Keynote hh-2012-09-18
Webdevcon Keynote hh-2012-09-18
Pierre Joye
 
Realtime webapp with node.js
Realtime webapp with node.js
robin_sy
 
Scalable game-servers-tgc
Scalable game-servers-tgc
Ashkan Saeedi Mazdeh
 
Node js
Node js
Chirag Parmar
 
Large-scale projects development (scaling LAMP)
Large-scale projects development (scaling LAMP)
Alexey Rybak
 
Game On! Exploring Microservices with a Text-Based Adventure Game
Game On! Exploring Microservices with a Text-Based Adventure Game
Erin Schnabel
 
PartyRocking: Jugando con Javascript y Websockets
PartyRocking: Jugando con Javascript y Websockets
Ruben Chavarri
 
Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)
Felix Geisendörfer
 
Scaling a Game Server: From 500 to 100,000 Users
Scaling a Game Server: From 500 to 100,000 Users
GeekNightHyderabad
 
introduction to node.js
introduction to node.js
orkaplan
 
Microservices with Node and Docker
Microservices with Node and Docker
Tony Pujals
 
What is Reactive programming?
What is Reactive programming?
Kevin Webber
 
Node.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel Aviv
Ron Perlmuter
 
Scalable Social Architectures by Biren Gandhi
Scalable Social Architectures by Biren Gandhi
Biren Gandhi
 
Farms, Fabrics and Clouds
Farms, Fabrics and Clouds
Steve Loughran
 
ngServer and-collaboratived-development-between-san-francisco-and-tokyo
ngServer and-collaboratived-development-between-san-francisco-and-tokyo
Satoshi Tanaka
 
NodeJS ecosystem
NodeJS ecosystem
Yukti Kaura
 
Webdevcon Keynote hh-2012-09-18
Webdevcon Keynote hh-2012-09-18
Pierre Joye
 
Realtime webapp with node.js
Realtime webapp with node.js
robin_sy
 
Large-scale projects development (scaling LAMP)
Large-scale projects development (scaling LAMP)
Alexey Rybak
 
Game On! Exploring Microservices with a Text-Based Adventure Game
Game On! Exploring Microservices with a Text-Based Adventure Game
Erin Schnabel
 
PartyRocking: Jugando con Javascript y Websockets
PartyRocking: Jugando con Javascript y Websockets
Ruben Chavarri
 
Scaling a Game Server: From 500 to 100,000 Users
Scaling a Game Server: From 500 to 100,000 Users
GeekNightHyderabad
 
Ad

Recently uploaded (20)

FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
Edge AI and Vision Alliance
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
SOFTTECHHUB
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Supporting the NextGen 911 Digital Transformation with FME
Supporting the NextGen 911 Digital Transformation with FME
Safe Software
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
Edge AI and Vision Alliance
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
SOFTTECHHUB
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Supporting the NextGen 911 Digital Transformation with FME
Supporting the NextGen 911 Digital Transformation with FME
Safe Software
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 

Game server development in node.js in jsconf eu

Editor's Notes

  • #13: Node.js is extremely suitable for game server development. Look at the definition of node.js, all these key words: fast, scalable, network, real-time are the character of game server. What a perfect match!!!
  • #14: There are many advantages of developing games with node.js. First, scalability, of course, node was designed for event driven IO, and game server is such a high network communication application, which makes node a killer application. Second, javascript language, HTML5 can enjoy the share language between client and server, but not only html5, other languages are also suitable for it. Third, lightweight, traditionaly game server development heavy, but node.js makes game server development light and happy, it is crucial for efficiency. Forth, multi-process single thread model, game logic is complicated, multi-thread lock can make a mass, but the single thread model of node.js makes logic clean and simple. Awesome!
  • #15: There are also some disadvantages in node.js since node is not good at CPU sensitive actions. Some AI and path finding actions is CPU sensitive. But in practice, all these problems can be solved. In our demo, all these CPU problems are solve by dividing process and other optimizations.
  • #16: We are not the first guy who use node.js as game servers. Mozilla published an open source game demo called BrowserQuest a few months before we open sourced. It is really a good demo for HTML5, but on the server side, it uses a single process node server, which can not hold too much online users.
  • #17: Google also published a game demo called gritsgame, which have an excellent presentation on google io 2012. But same problem, the demo focus on client side,the server side is a simple single process node.js server, which can not hold too much online users.
  • #18: This is our demo. Believe me, the art material sucks. So what is the difference between our game and BrowserQuest. The server side!!! We have a strong server side, which can hold thousands of online users.
  • #19: This the backend of our server architecture, each rectangle represents a process. In the frontend, there are a group of processes called connector, whose job is holding connection of clients. Connector do not do the real logic, all the logics are sent to the backend processes. There are many types of back end processes, including, area, login, chat, status, team etc., in reality, there may have 10 types of processes. The main game logic is handled in area servers.
  • #20: I believe most of you are from web background. So I will give a comparison between web and game. First, long connection VS short connection, it is obvious, realtime game need instant reaction, we must use long connection to push message.Second, partition, game is partitioned by area or room, it is decided by the nature of game. In the previous demo, all the players in the same map are actually in the same processes. When you walk to another map, you are most likely in another process. Because in game, most of the player interations are in a same map, making them in same process can minimize the inter-process communication. Third, game is stateful, because of the parition strategy, the request of certain player can only be handled by specific server. This is why game can not as scalable as web. Fourth, request/broadcast, most of player action need to be broadcasted to other players immediately, which is a scalability killer, we need many optimizations.
  • #21: So, because of all the differences, the architecture of web and game is different. Web application can enjoy the benefit of load balancer, since all the processes are equal. Game, on the other hand, is a complicated spider web,different types of servers communicate to each other. It is hard to manage all these servers, and the communication can be complicated, which lead us to distributed programming.
  • #22: Since the runtime architecture of a game is so complicated, we need a solution to simplify it. And these is a solution: framework, which lead us to next chapter.
  • #23: So, let’s take a look at the pomelo framework.
  • #24: You will be surprised to find ot that pomelo framework is nothing to do with game. In essence, it is a distributed scalable realtime application framework.
  • #33: Last, channel and broadcast. It push messages to a group of users. The API above is just simple. But as you know, broadcast is one of the most frequent actions in game, and it can can cause many performance problems.
  • #35: Now, rpc, it works like magic. Zero config, you do not need to specify target server IP, port or anything. Just a function call, the client will automaticlly routed to target server, send to specific file and method. You don’t event feel that you are doing remote call. Of course, you need define a route function before hand, it’s quite simple.
  • #36: We have known a bunch of rpc frameworks, but none is as simple as pomelo. Why? For example, thrift, you need to write a .thrift file, and generate it to source code, copy the source to application. If the interface is changed, damn, do it again. But nothing need to be done in pomelo, you just start up, boo.. Just call rpc like local method, all done. Why? Because we have servers abstraction in our framework. When we start up, we scan the server’s folder, generate the proxy automatically on start up.
  • #37: The fourth part, practice.
  • #38: As time is limited, I’m going to talk about the simplest game logic, player move! As you see, there are 6 steps in player move, basicly, the client send a message of move request to server, the connector route the request to specific area server. The area server do move logic, and broadcast to the clients who can see the movement of first client. The clients play the move animation. Done! The blue part is accomplished by framework, You only need to write the code of step 1,3,6.
  • #39: Step one, client move, the client side need to find path and move animation. We find path on client side can save many cpu resources on the server and make the animation more smooth. Then the client send the move request to the server, it is the basic API of pomelo client, just like AJAX call.
  • #40: Step 3, the area server receive the request, route to this method ‘handler.move’ based on convention over configuration. The method signature is similar to http, except we need a session message, and a next callback. The method verify path, handle move logic, and then it need a broadcast to tell all the users who can see the first players’ move. After that, it send the response back with a next method.
  • #41: The last step, every players received the broadcast message should play the move animation, really simple!
  • #43: So easy, right? But, in reality, it is not as simple as you think. There are many issues you should consider.
  • #44: First, different situations. I only demonstrate player move before. The mob move is quite different, it is driven by AI. Second, smooth effect. If you play animation after server send message, there will be some delay. To achieve smooth effect, you must use client prediction. But all the complexity will come since there is disaccord between client and server. Third , how to notify, broadcast to all the users is wasteful, you must use some algorithm to minimized the price of broadcast. This is where AOI fit in.
  • #45: Last part performance
  • #50: This the game picture of our stress test. Too much players in the map!!!
  • #52: This is another picture, we make the map a little bigger, so the players in one screen is dropped, which is good to broadcast.
  • #58: The time is limited , we do not have time to talk all the details. Two weeks later in Lisbon, I will give a talk focus on performance.