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

PPTX
Building fast,scalable game server in node.js
PDF
The Creation of Killzone 3
PDF
Lighting Shading by John Hable
PPTX
背景を作って苦労してみた ~Amplify Impostors~
PPTX
East Coast DevCon 2014: Concurrency & Parallelism in UE4 - Tips for programmi...
PPTX
East Coast DevCon 2014: The Slate UI Framework - Architecture & Tools
PPT
SIGGRAPH 2010 - Style and Gameplay in the Mirror's Edge
PDF
Unreal Summit 2016 Seoul Lighting the Planetary World of Project A1
Building fast,scalable game server in node.js
The Creation of Killzone 3
Lighting Shading by John Hable
背景を作って苦労してみた ~Amplify Impostors~
East Coast DevCon 2014: Concurrency & Parallelism in UE4 - Tips for programmi...
East Coast DevCon 2014: The Slate UI Framework - Architecture & Tools
SIGGRAPH 2010 - Style and Gameplay in the Mirror's Edge
Unreal Summit 2016 Seoul Lighting the Planetary World of Project A1

What's hot (20)

PDF
Incognito 2015 - 게임 리소스 추출과 변조 - 오효근
PDF
Editor Utility Widgetで色々便利にしてみた。
PDF
게임 디자이너와 게임 서버
PDF
언차티드4 테크아트 파트1 톤맵핑&색보정
PPTX
Introduction to Level Design
PPT
Introduction to Functional Safety and SIL Certification
PPTX
Bethesda's Iterative Level Design Process for Skyrim and Fallout 3
PPTX
UE4 Lightmass for Large Console Games (UE4 Lightmass Deep Dive)
PDF
エンタープライズ分野向けUE4最新機能のご紹介
PDF
Idle Clicker Games Presentation (Casual Connect USA 2017)
PPTX
Safety life cycle seminar IEC61511
PDF
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
PDF
Akka.NET 으로 만드는 온라인 게임 서버 (NDC2016)
PDF
Lighting of Killzone: Shadow Fall
PDF
Albion Online - Software Architecture of an MMO (talk at Quo Vadis 2016, Berlin)
PDF
Component-Based Entity Systems (Demo)
PDF
Game Design - Lecture 1
PPTX
More Performance! Five Rendering Ideas From Battlefield 3 and Need For Speed:...
PPTX
Horizon Zero Dawn: A Game Design Post-Mortem
Incognito 2015 - 게임 리소스 추출과 변조 - 오효근
Editor Utility Widgetで色々便利にしてみた。
게임 디자이너와 게임 서버
언차티드4 테크아트 파트1 톤맵핑&색보정
Introduction to Level Design
Introduction to Functional Safety and SIL Certification
Bethesda's Iterative Level Design Process for Skyrim and Fallout 3
UE4 Lightmass for Large Console Games (UE4 Lightmass Deep Dive)
エンタープライズ分野向けUE4最新機能のご紹介
Idle Clicker Games Presentation (Casual Connect USA 2017)
Safety life cycle seminar IEC61511
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
Akka.NET 으로 만드는 온라인 게임 서버 (NDC2016)
Lighting of Killzone: Shadow Fall
Albion Online - Software Architecture of an MMO (talk at Quo Vadis 2016, Berlin)
Component-Based Entity Systems (Demo)
Game Design - Lecture 1
More Performance! Five Rendering Ideas From Battlefield 3 and Need For Speed:...
Horizon Zero Dawn: A Game Design Post-Mortem
Ad

Viewers also liked (9)

PPTX
Game server development in node.js
PPTX
Pomelo Logistics 27 Nov 2011
PPT
Citrius family
PPTX
Clementines
PPTX
Citrus fruit variety
PPTX
Packaging
PDF
Bao cao do an Phát triển hệ thống game server Online
PDF
Pomelo y limon
PDF
[KGC 2012] Online Game Server Architecture Case Study Performance and Security
Game server development in node.js
Pomelo Logistics 27 Nov 2011
Citrius family
Clementines
Citrus fruit variety
Packaging
Bao cao do an Phát triển hệ thống game server Online
Pomelo y limon
[KGC 2012] Online Game Server Architecture Case Study Performance and Security
Ad

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

PDF
Real time web apps
PPTX
introduction to node.js
PDF
Node.js
PPTX
Microservices with Node and Docker
PDF
What is Reactive programming?
PPTX
Node.js meetup at Palo Alto Networks Tel Aviv
PDF
Nodejs - A quick tour (v5)
PPTX
Scalable Social Architectures by Biren Gandhi
PPT
Farms, Fabrics and Clouds
PDF
ngServer and-collaboratived-development-between-san-francisco-and-tokyo
PDF
NodeJS ecosystem
PPTX
Webdevcon Keynote hh-2012-09-18
KEY
Realtime webapp with node.js
PPTX
Scalable game-servers-tgc
PPT
Node js
PPT
Large-scale projects development (scaling LAMP)
PPTX
Game On! Exploring Microservices with a Text-Based Adventure Game
PDF
PartyRocking: Jugando con Javascript y Websockets
PDF
Nodejs - A quick tour (v6)
ODP
Scaling a Game Server: From 500 to 100,000 Users
Real time web apps
introduction to node.js
Node.js
Microservices with Node and Docker
What is Reactive programming?
Node.js meetup at Palo Alto Networks Tel Aviv
Nodejs - A quick tour (v5)
Scalable Social Architectures by Biren Gandhi
Farms, Fabrics and Clouds
ngServer and-collaboratived-development-between-san-francisco-and-tokyo
NodeJS ecosystem
Webdevcon Keynote hh-2012-09-18
Realtime webapp with node.js
Scalable game-servers-tgc
Node js
Large-scale projects development (scaling LAMP)
Game On! Exploring Microservices with a Text-Based Adventure Game
PartyRocking: Jugando con Javascript y Websockets
Nodejs - A quick tour (v6)
Scaling a Game Server: From 500 to 100,000 Users

Recently uploaded (20)

PPTX
20250228 LYD VKU AI Blended-Learning.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
A Presentation on Artificial Intelligence
PDF
Machine learning based COVID-19 study performance prediction
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Approach and Philosophy of On baking technology
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Electronic commerce courselecture one. Pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Encapsulation theory and applications.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPT
Teaching material agriculture food technology
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
MIND Revenue Release Quarter 2 2025 Press Release
20250228 LYD VKU AI Blended-Learning.pptx
The AUB Centre for AI in Media Proposal.docx
A Presentation on Artificial Intelligence
Machine learning based COVID-19 study performance prediction
Network Security Unit 5.pdf for BCA BBA.
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Approach and Philosophy of On baking technology
NewMind AI Weekly Chronicles - August'25-Week II
The Rise and Fall of 3GPP – Time for a Sabbatical?
Digital-Transformation-Roadmap-for-Companies.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Electronic commerce courselecture one. Pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Encapsulation theory and applications.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Teaching material agriculture food technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
Assigned Numbers - 2025 - Bluetooth® Document
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
MIND Revenue Release Quarter 2 2025 Press Release

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.