开发者

Nodejs: many clients requests through one socket

Scenario: I have many clients (web pages, via Socket.io) that connect to a Node.js server (call it A). The server acts as an application "proxy" to another service (Node.js too) for those clients, let's call the service B. In practice, pages talk to service B using the proxy. I'm trying to understand if I could take ONE only open socket from the server A to the service B, just to gain performance and resources (on the first client connection on server A, the server will open the socket to B and maintain it open for message to flow bidirectionally). Of course the problem is that without some kind of intervention, messages could be scrambled one over the other, resulting in a mess that开发者_如何学运维 service B can't understand. I'm quite a newbie in socket programming, and I'm wondering if this is yet a "solved" problem, or just the wrong answer to the problem :) Thank you


From your comments, it looks like you'd benefit from something like Redis' PubSub.

See http://redis.io/ and specifically, http://redis.io/commands#pubsub

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜