Top Related Projects
A full-featured http proxy for node.js
Realtime application framework (Node.JS server)
Simple to use, blazing fast and thoroughly tested WebSocket client and server for Node.js
Simple, secure & standards compliant web server for the most demanding of applications
:zap: Primus, the creator god of the transformers & an abstraction layer for real-time to prevent module lock-in.
Quick Overview
Pomelo is a fast, scalable, distributed game server framework for Node.js. It provides a powerful set of tools and libraries for building multiplayer games and real-time applications. Pomelo is designed to handle large numbers of concurrent users and complex game logic efficiently.
Pros
- Highly scalable architecture suitable for large-scale multiplayer games
- Flexible component-based design allowing easy customization and extension
- Built-in support for various network protocols (TCP, UDP, WebSocket)
- Comprehensive documentation and active community support
Cons
- Steep learning curve for developers new to Node.js or game server development
- Limited built-in support for non-game real-time applications
- Requires careful configuration and optimization for optimal performance
- Some dependencies may be outdated or no longer maintained
Code Examples
- Creating a Pomelo application:
const pomelo = require('pomelo');
const app = pomelo.createApp();
app.set('name', 'MyGame');
app.configure('production', 'gate', function() {
app.set('connectorConfig', {
connector: pomelo.connectors.hybridconnector,
heartbeat: 3,
useDict: true,
useProtobuf: true
});
});
app.start();
- Defining a remote service:
module.exports = function(app) {
return new PlayerRemote(app);
};
class PlayerRemote {
constructor(app) {
this.app = app;
}
getPlayerInfo(playerId, cb) {
// Fetch player info from database
let playerInfo = { /* ... */ };
cb(null, playerInfo);
}
}
- Handling client requests in a handler:
module.exports = function(app) {
return new Handler(app);
};
class Handler {
constructor(app) {
this.app = app;
}
move(msg, session, next) {
let playerId = session.get('playerId');
let position = msg.position;
// Update player position
// ...
next(null, { code: 200, msg: 'move success' });
}
}
Getting Started
-
Install Pomelo globally:
npm install pomelo -g
-
Create a new Pomelo project:
pomelo init MyGame cd MyGame
-
Install dependencies:
npm install
-
Start the server:
pomelo start
-
Connect to the server using a Pomelo client library in your game client.
Competitor Comparisons
A full-featured http proxy for node.js
Pros of node-http-proxy
- Lightweight and focused on HTTP/HTTPS proxying
- Easy to set up and integrate into existing Node.js applications
- Supports WebSocket proxying
Cons of node-http-proxy
- Limited to proxying functionality, lacks game server-specific features
- Not designed for scalable, distributed systems out of the box
- Less active community and fewer updates compared to Pomelo
Code Comparison
node-http-proxy:
const httpProxy = require('http-proxy');
const proxy = httpProxy.createProxyServer({});
proxy.on('proxyReq', function(proxyReq, req, res, options) {
proxyReq.setHeader('X-Special-Proxy-Header', 'foobar');
});
Pomelo:
const pomelo = require('pomelo');
const app = pomelo.createApp();
app.configure('production', 'connector', function(){
app.set('connectorConfig', {
connector : pomelo.connectors.hybridconnector,
heartbeat : 3,
useDict : true,
useProtobuf : true
});
});
Summary
node-http-proxy is a lightweight, focused solution for HTTP/HTTPS proxying, making it easy to integrate into existing Node.js applications. However, it lacks the game server-specific features and scalability options that Pomelo offers. Pomelo is designed for building large-scale, distributed game servers with real-time communication, while node-http-proxy is better suited for simpler proxying needs in web applications.
Realtime application framework (Node.JS server)
Pros of Socket.IO
- Simpler setup and easier to get started for basic real-time applications
- Extensive documentation and large community support
- Built-in support for multiple transport methods (WebSocket, polling, etc.)
Cons of Socket.IO
- Less scalable for large-scale, high-performance game server applications
- Limited built-in support for complex distributed systems
Code Comparison
Socket.IO server setup:
const io = require('socket.io')(3000);
io.on('connection', (socket) => {
console.log('A user connected');
socket.on('chat message', (msg) => {
io.emit('chat message', msg);
});
});
Pomelo server setup:
const pomelo = require('pomelo');
const app = pomelo.createApp();
app.configure('production', 'connector', function(){
app.set('connectorConfig', {
connector : pomelo.connectors.hybridconnector,
heartbeat : 3,
useDict : true,
useProtobuf : true
});
});
app.start();
Summary
Socket.IO is more suitable for simpler real-time applications and offers easier setup, while Pomelo is designed for more complex, scalable game server architectures. Socket.IO has broader community support, but Pomelo provides better performance for large-scale multiplayer games.
Simple to use, blazing fast and thoroughly tested WebSocket client and server for Node.js
Pros of ws
- Lightweight and focused solely on WebSocket implementation
- High performance and low latency
- Extensive browser support
Cons of ws
- Limited to WebSocket protocol only
- Lacks built-in game-specific features
- Requires additional libraries for more complex applications
Code Comparison
ws:
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 8080 });
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
console.log('received: %s', message);
});
});
Pomelo:
var pomelo = require('pomelo');
var app = pomelo.createApp();
app.configure('production', 'connector', function(){
app.set('connectorConfig', {
connector : pomelo.connectors.hybridconnector,
heartbeat : 3,
useDict : true,
useProtobuf : true
});
});
app.start();
Summary
ws is a lightweight, high-performance WebSocket library focused on the WebSocket protocol, while Pomelo is a more comprehensive game server framework with additional features. ws is simpler to use for basic WebSocket communication, but Pomelo offers more built-in functionality for game development. The choice between them depends on the specific requirements of your project and the level of abstraction you need.
Simple, secure & standards compliant web server for the most demanding of applications
Pros of uWebSockets
- Extremely high performance and low latency
- Lightweight and efficient, with minimal resource usage
- Supports both WebSocket and HTTP protocols
Cons of uWebSockets
- Less comprehensive framework compared to Pomelo
- Primarily focused on WebSocket functionality, lacking game-specific features
- Steeper learning curve for complex applications
Code Comparison
uWebSockets:
uWS::App().ws<PerSocketData>("/*", {
.open = [](auto *ws, auto *req) {
// Handle new WebSocket connection
},
.message = [](auto *ws, std::string_view message, uWS::OpCode opCode) {
// Handle incoming WebSocket message
}
}).listen(9001, [](auto *listen_socket) {
if (listen_socket) {
std::cout << "Listening on port " << 9001 << std::endl;
}
});
Pomelo:
var pomelo = require('pomelo');
var app = pomelo.createApp();
app.configure('production', 'connector', function(){
app.set('connectorConfig', {
connector : pomelo.connectors.hybridconnector,
heartbeat : 3,
useDict : true,
useProtobuf : true
});
});
app.start();
Summary
uWebSockets excels in performance and efficiency, making it ideal for high-throughput, low-latency applications. Pomelo, on the other hand, offers a more comprehensive framework specifically designed for game development, with built-in features for scalability and distributed systems. The choice between the two depends on the specific requirements of the project, with uWebSockets being better suited for pure WebSocket applications and Pomelo for more complex game server architectures.
:zap: Primus, the creator god of the transformers & an abstraction layer for real-time to prevent module lock-in.
Pros of Primus
- More flexible and framework-agnostic, supporting multiple transport layers
- Simpler API and easier to get started with for basic real-time applications
- Active community and regular updates
Cons of Primus
- Less scalable for large-scale, distributed game server architectures
- Fewer built-in features for game-specific functionality
- May require additional plugins or libraries for complex game logic
Code Comparison
Primus (client-side connection):
var primus = new Primus('http://localhost:8080');
primus.on('data', function(data) {
console.log('Received data:', data);
});
Pomelo (client-side connection):
var pomelo = window.pomelo;
pomelo.init({
host: host,
port: port,
log: true
}, function() {
console.log('Pomelo client initialized');
});
Summary
Primus is a more general-purpose real-time communication framework, offering flexibility and ease of use for various applications. Pomelo, on the other hand, is specifically designed for game server development, providing built-in scalability and game-oriented features. While Primus may be simpler to set up and use for basic real-time functionality, Pomelo offers more robust support for complex, distributed game architectures out of the box.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Pomelo -- a fast, scalable game server framework for node.js
Pomelo is a fast, scalable game server framework for node.js. It provides the basic development framework and many related components, including libraries and tools. Pomelo is also suitable for real-time web applications; its distributed architecture makes pomelo scale better than other real-time web frameworks.
- Homepage: http://pomelo.netease.com/
- Mailing list: https://groups.google.com/group/pomelo
- Documentation: http://github.com/NetEase/pomelo
- Wiki: https://github.com/NetEase/pomelo/wiki/
- Issues: https://github.com/NetEase/pomelo/issues/
- Tags: game, nodejs
Features
Complete support of game server and realtime application server architecture
- Multiple-player game: mobile, social, web, MMO rpg(middle size)
- Realtime application: chat, message push, etc.
Fast, scalable
- Distributed (multi-process) architecture, can be easily scale up
- Flexible server extension
- Full performance optimization and test
Easy
- Simple API: request, response, broadcast, etc.
- Lightweight: high development efficiency based on node.js
- Convention over configuration: almost zero config
Powerful
- Many clients support, including javascript, flash, android, iOS, cocos2d-x, C
- Many libraries and tools, including command line tool, admin tool, performance test tool, AI, path finding etc.
- Good reference materials: full docs, many examples and an open-source MMO RPG demo
Extensible
- Support plugin architecture, easy to add new features through plugins. We also provide many plugins like online status, master high availability.
- Custom features, users can define their own network protocol, custom components very easy.
Why should I use pomelo?
Fast, scalable, real-time game server development is not an easy job, and a good container or framework can reduce its complexity. Unfortunately, unlike web, finding a game server framework solution is difficult, especially an open source solution. Pomelo fills this gap, providing a full solution for building game server frameworks. Pomelo has the following advantages:
- The architecture is scalable. It uses a multi-process, single thread runtime architecture, which has been proven in the industry and is especially suited to the node.js thread model.
- Easy to use, the development model is quite similar to web, using convention over configuration, with almost zero config. The API is also easy to use.
- The framework is extensible. Based on the node.js micro module principle, the core of pomelo is small. All of the components, libraries and tools are individual npm modules, and anyone can create their own module to extend the framework.
- The reference materials and documentation are quite complete. In addition to the documentation, we also provide an open-source MMO RPG demo (HTML5 client), which is a far better reference material than any book.
How can I develop with pomelo?
With the following references, you can quickly familiarize yourself with the pomelo development process:
Contributors
- NetEase, Inc. (@NetEase)
- Peter Johnson(@missinglink)
- Aaron Yoshitake
- @D-Deo
- Eduard Gotwig
- Eric Muyser(@stokegames)
- @GeforceLee
- Harold Jiang(@jzsues)
- @ETiV
- kaisatec
- roytan883
- wuxian
- zxc122333
- newebug
- jiangzhuo
- youxiachai
- qiankanglai
- xieren58
- prim
- Akaleth
- pipi32167
- ljhsai
- zhanghaojie
- airandfingers
License
(The MIT License)
Copyright (c) 2012-2017 NetEase, Inc. and other contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Top Related Projects
A full-featured http proxy for node.js
Realtime application framework (Node.JS server)
Simple to use, blazing fast and thoroughly tested WebSocket client and server for Node.js
Simple, secure & standards compliant web server for the most demanding of applications
:zap: Primus, the creator god of the transformers & an abstraction layer for real-time to prevent module lock-in.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot