NodeJS and Scaling

Post your help queries and engine programming questions here

NodeJS and Scaling

Postby Smoozilla » Tue Aug 05, 2014 6:36 pm

I've exhausted two days of searching for this, so maybe someone here has some thoughts.

I'd like to run multiple instances of nodeJS, to split the load over multiple cores. But I'm confused and stuck!

I've considered using a Proxy server, but as far as I can tell, this would put them into the specific NodeJS instance they were supposed to be in, but they would't be able to move between NodeJS instances without disconnecting / reconnecting.

Also, I've looked into Redis, and that seems like an awesome solution, with Socket.io, since Socket.io has Redis support I think I could use this method to 'pass' the connections between NodeJS instances.

But I would prefer to use net.io :-)

If no one has any suggestions, I suppose I'll dive into socket.io and redis

To give an example, a player walking about the main world would be on the main world instances of Nodejs, but when that same player enters a dungeon, I'd like to move their connection (net.io) seemlessly to the NodeJs instance handling dungeons.

Thank you!
User avatar
Smoozilla
 
Posts: 10
Joined: Wed Jul 30, 2014 6:37 am

Re: NodeJS and Scaling

Postby robaldred » Fri Aug 08, 2014 11:09 am

Just out of interest why can't you disconnect and connect them to the dungeon node? This could happen in the background, the user need not experience anything different.
I don't work for Irrelon. All comments are my own.
I would strongly encourage anyone building production projects with Isogenic to buy a premium licence, it costs very little and will help towards continued development of the engine. Irrelon have spent thousands of hours developing this wonderful platform with many features found in AAA game engine.
User avatar
robaldred
 
Posts: 243
Joined: Wed Oct 23, 2013 8:09 pm
Location: Manchester, England

Re: NodeJS and Scaling

Postby Smoozilla » Fri Aug 08, 2014 8:13 pm

As I was wrapping my head around the concept, I started to realize that's the way to go :-)

I plan to use node-http-proxy as to only deal with one websocket URL, and have it distribute to nodes as appropriate.

Thanks for clarifying the direction of my thought process Rob! I would just start asking you questions directly, but it's good that others can learn from my mistakes ;-)
User avatar
Smoozilla
 
Posts: 10
Joined: Wed Jul 30, 2014 6:37 am

Re: NodeJS and Scaling

Postby robaldred » Fri Aug 08, 2014 8:22 pm

Glad you're making progress!
No worries, It's definitely best to post here.
I don't work for Irrelon, I'm just a contributor :)
I don't work for Irrelon. All comments are my own.
I would strongly encourage anyone building production projects with Isogenic to buy a premium licence, it costs very little and will help towards continued development of the engine. Irrelon have spent thousands of hours developing this wonderful platform with many features found in AAA game engine.
User avatar
robaldred
 
Posts: 243
Joined: Wed Oct 23, 2013 8:09 pm
Location: Manchester, England

Re: NodeJS and Scaling

Postby Smoozilla » Fri Aug 08, 2014 8:23 pm

Yes, I know it's confusing with Rob and Rob (Alrdred?) :-)
User avatar
Smoozilla
 
Posts: 10
Joined: Wed Jul 30, 2014 6:37 am

Re: NodeJS and Scaling

Postby Killersan » Tue Sep 16, 2014 11:40 am

Hello guys,

Since there is no out of the box solution for synchronizing information between node.js instances, and one node.js can use only one CPU core, then we are going in direction which RobAldred pointed to.
We are going to implement Redis solution, where we will keep user sessions to automatically reauthenticate user between separate node.js instances with different purpose (like different kind of dungeons for example).
But we have problem with chat functionalities. We can implement it into Redis, but we would like to keep it in IGE, but we don't know if we can connect user into dungeon node.js instance and in same time with chat node.js instance.

Please let me know what do You think about it or maybe You know some kind of solution which allows to synchronize node.js between themselves or with some kind of master instance that we could use to increase performance for our project.
User avatar
Killersan
 
Posts: 24
Joined: Sat Jun 21, 2014 1:45 pm

Re: NodeJS and Scaling

Postby robaldred » Tue Sep 16, 2014 1:23 pm

Interesting.
Ok here's something...

You implement the chat between the clients and the instance they're connected to in the normal way you'd expect as per the example 18.1-chat-netio or 18.2-chat-socketio.

Maybe you have two rooms
"instance" and "global"

Maybe you could have another Node which is your "Master node" which is a custom node server running some very basic code to track instance process and provide a global chat relay.

A node server can connect to another node server using various methods
Depending on whether the nodes are on the same box or not you could use a second direct websocket between the master node and the instance node.
Or you could use redis.

Let's draw something rough...

2014-09-16 13.05.50.jpg
2014-09-16 13.05.50.jpg (1.65 MiB) Viewed 15238 times


Here's what might happen if a client sends a chat message, that should be presented to all clients across all instances.

* Client 1 in Instance 1 posts a message in chat.
* The message is sent from Client 1 as an IGE network message to in the Instance the client is connected to (Instance 1)
* This message is then push up to the Master node via some method (websocket/redis/http)
* The master node then relays the received message back to all the instances connected to the master node.
* Each instance would then receive the message and push it out via another IGE network message to it's connected clients.

This is just a basic concept. I'm not saying this is what you should do.
The method would also be useful for relaying the state of a playing instance, such as player count, progress etc.

Hope this makes sense and offers up something useful.
I don't work for Irrelon. All comments are my own.
I would strongly encourage anyone building production projects with Isogenic to buy a premium licence, it costs very little and will help towards continued development of the engine. Irrelon have spent thousands of hours developing this wonderful platform with many features found in AAA game engine.
User avatar
robaldred
 
Posts: 243
Joined: Wed Oct 23, 2013 8:09 pm
Location: Manchester, England


Return to Help & Questions

Who is online

Users browsing this forum: No registered users and 1 guest
cron