-
|
Thanks for all of your hard work on this lib! Would appreciate advice on how I should use Jolt on a NodeJS server hosting multiple games/worlds. Take "Fall Guys" for example. 40 players in each game, thousands of simultaneous games with varying world physics.
Thanks so much! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
If you want to run many games on a single CPU, then it doesn't make sense to multithread within a single game. Multithreading comes with overhead as you need to synchronize memory access between threads. JS support for multitheading is very poor in comparison to other languages like C++. So, I would configure the simulation to run single threaded and run 1 or more games per CPU core. Since games are independent, they could never need to access memory that belongs to other games. Each game will have its own The next question is then: Do we run multiple NodeJS instances (1 per game) or do we run multiple WebWorkers within a single NodeJS instance (1 WebWorker per game). This is a question that I can't really answer as my JS experience is limited and I don't know how much overhead a NodeJS instance has. From what I've seen, it would not be very hard to spin up a WebWorker per game as the main difficulty comes from WebWorkers needing to communicate with the main thread/other WebWorkers. This should not be needed if each WebWorker hosts a fully independent game (and have its own |
Beta Was this translation helpful? Give feedback.
-
|
This is helpful information, thank you. It sounds like you're saying one new Jolt instance per game, is that correct? let jolt1 = new Jolt.JoltInterface(settings1);
let jolt2 = new Jolt.JoltInterface(settings2);
let physicsSystem1 = jolt1.GetPhysicsSystem();
let physicsSystem2 = jolt2.GetPhysicsSystem();
Yea it's a super tricky problem. Gave this a lot of thought over the past week. We have multiplayer rollback netcode. Each tick is synchronous, but WebWorkers run async. We'd have to run simulation data slightly in the past to get this to work.
|
Beta Was this translation helpful? Give feedback.
-
Yes. Although in your example you create 2 variables in the same global address space. If you use a WebWorker per game then each WebWorker would have it's own physics system and not share the
If 1 game happens in 1 WebWorker (including all comms) then there's nothing that needs to be communicated with other workers so you can see it as a synchronous process.
Yes. Disclaimer: I haven't tried running multiple instances of Jolt in multiple WebWorkers, so I don't know if it will actually work. |
Beta Was this translation helpful? Give feedback.
Yes. Although in your example you create 2 variables in the same global address space. If you use a WebWorker per game then each WebWorker would have it's own physics system and not share the
joltvariable with any other workers.If 1 game happens in 1 WebWorker (including all comms) then there's nothing that needs to be communicated with other workers so you can see it as a synchronous process.
Yes.
Disclaimer: I haven't tried running multiple instances of …