English 中文(简体)
NOde.js 群集模块
原标题:Node.js cluster module

请帮助。我使用Nodejs群集模块:http://nodejs.org/docs/v0.6.18/api/ croup.html

运行js

var cluster = require( cluster );

if (cluster.isMaster) {
    require( os ).cpus().forEach(function () {
        cluster.fork();
    });
} else {
    require( ./工 工 工 工 工 工 工 工 工 工 工 工 工 工 工 工 工 );
}

工 工 工 工 工 工 工 工 工 工 工 工 工 工 工 工 工

var http = require( http ),
    connect = require( connect ),
    sio = require( socket.io ),
    // create server
    app = connect(),
    server = http.createServer(app);

server.listenPort(80);

var io = sio.listen(server);
// io.sockets.on ....

所有工人都听80个端口。 每一个连接都为随机工人服务(? ) 。 我能转换工人吗? 用户在哪里连接?

对不起,我不好的英语 < /em>

问题回答

如果您真的需要切换, 您可以使用套接/ 套接字 / socket. io 在您的组群之间进行通讯, 并发送您的工作 。

否则,你不能,但只是好奇...

您应该查看 WebRTC, 它能让对等对等连接, 这对于多玩家游戏来说是巨大的 。

我的两分钱





相关问题
Assets Management in a clustered environment

I have a content management system running on a web server, that among others allows the user to upload assets like images, files, etc to the server. The problem i have is that there will be 2 ...

Condor, Sun Grid Engine, or something else?

I m trying to work out whether we should try out Condor or Sun Grid Engine at work (or possibly something else). We often have lots of unused WinXp workstations. The hope is that we could use wake-...

Caching in a clustered environment

Caching your data in your application code is generally a good idea for many reasons. We have being doing this for quiet some time in our shared environment which includes ColdFusion, .NET, and PHP. ...

Programmatically detect Windows cluster configuration?

Does anyone know how to programatically detect that a Windows server is part of a cluster? Further, is it possible to detect that the server is the active or passive node? [Edit] And detect it from ...

热门标签