-
-
Notifications
You must be signed in to change notification settings - Fork 548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to limit the number of rooms a process can spawn #155
Comments
Hi Endel Any updates on this one ? |
Syntax suggestion by @oyed gameServer
.define('my-room', MyRoom)
.filterBy(['id'])
.maxInstances(1); |
Use-case for context:
Client A: |
Did this ever get addressed? |
Hi @LukeWood, It was not addressed yet. @MateusMendesSantana did propose a solution in the past that should work on single-process environments. I believe a modified version of that could suit environments with more processes as well. This hasn't been prioritized because when you use multiple processes, new rooms are created on the process with the least amount of rooms spawned. Adding more processes will make sure the load is distributed among them. The feature is still valuable if all available processes are "full", though. So the game doesn't become unplayable due to competing CPU usage. This won't land on 0.15 yet, but it's an interesting feature to land later! I'm expecting the server to throw a |
Thanks for the information @endel ! I'll see what I can do on my end, and then let you know how I solve the problem! |
So to move forward with the proposed solution n @endel do we need to use Redis? |
This is a very hard problem to solve. When you have multiple users hitting different servers at the same time, they both try to create the room at the exact same time. You'd need some form of interlocking, using REDIS to get a semaphore value for room creation. But, you can't keep that semaphore for very long, because room creation can take some time. Honestly, we really need single instance rooms, too. But we don't need colyseus to change to do it. One approach:
Easier approach:
|
In our project, we actually implement this using RedisPresence now in the room onCreate. Using |
To prevent the process from consuming too much CPU and slowing down all of its spawned rooms, it would be best to have a way to limit the number of rooms a process can spawn.
(https://discuss.colyseus.io/topic/11/about-setting-number-of-rooms-for-a-registered-room-on-the-server/4)
The text was updated successfully, but these errors were encountered: