Page 1 of 1

Advice needed about room level extensions.

Posted: 15 Dec 2011, 14:51
by yuvallahav
Hello.

So, been working for a while now on a new game, and until now, we always handles the communication on the zone level, while the games were handled by the client (timing, switching turns and so on), but in the new game, which will be 8 players game, and not 1 vs 1, we are thinking about using a room level extension, since so much can go wrong trying to control a game for 8 users at the same time (we're talking about game information, synchronization of animations and so on), but I do know the a lot of room level extensions can be stressful to the server.
Before I start changing the code for this game, which I've been working on for the better part of the year, I need to know that it would be worth it, when we're expecting about 6k players at peak time, divided into about 1k rooms, where each room would have to have a counter (for time and action tracking) and messages from and to the server from and to the clients.
Where are our limits? I mean, I know it all comes down how many actions, and actual rooms are active at a given time, but can't we make some assumptions with the given information, machine CPU, RAM and such?
Would you be able to say 1k rooms with 1k counters beeping away, sending and receiving messages from an average of 6 users per room, too much?
500? 100? 50? 10?
Right now we have a few games running on our server, with about 4k users at peak, with about 1000-1300 game rooms active, but again, using only the zone extension so far, and we don't see too much of a stress on our machine.

I would appreciate any advice on the matter.

Yuval.

Posted: 19 Dec 2011, 16:15
by Lapo
Even with a high quality crystal ball it would be hard to make predictions. Performance depends on so many variables: hardware, your code, network lag...

One side effect of Room level extensions is that they will fill up the PermGen area of the JVM.
See here for more:
http://docs2x.smartfoxserver.com/Advanc ... assLoading

This is not a bad thing, you just need to know it and setup the JVM with extra memory for classes (as explained in the first article that I linked)
Would you be able to say 1k rooms with 1k counters beeping away, sending and receiving messages from an average of 6 users per room, too much?
500? 100? 50? 10?
I don't understand... here we are talking about a certain amount of messages. How does this relate to the way you plug Extensions in the server? We're talking about apples and oranges.

The only difference between Zone Level and Room Level is how memory is managed.
Right now we have a few games running on our server, with about 4k users at peak, with about 1000-1300 game rooms active, but again, using only the zone extension so far, and we don't see too much of a stress on our machine.

Again... no crystal ball :) It depends on your hardware, and the complexity of your game, message rate etc... The one and only way to tell is building a prototype and measuring in a test environment.

Cheers

Re: Advice needed about room level extensions.

Posted: 17 Feb 2012, 09:09
by yuvallahav
Hey there Lapo!
So.. We've started testing the new game online, on our normal server, instead of a general timer per room ticking away the seconds, I have a set of setIntervals for the timed actions I need, and that way I don't need to have something that ticks off continuously.
I have tested this game, just the one room, on our server, at peak hour, when we had about 3500 users connected to our other games, and it was a little bit sluggish, probably because of messages out queue.
We will start, maybe today, probably Monday, a test run open to our testers community, limiting the game to about 100 users, which will make about 15-20 rooms, depending on users stress, but I do have the feeling, and we've talked about it already, that this is going to be our top game, and we expect it to have at least as much users as the rest of our games combined, so we're talking about 3000-5000 users playing this game alone, at peak hour, and we think we will need to have a dedicated server just for this game, since our sql traffic is heavy as it is right now at peak.
We'll see how it goes and we'll contact you guys about buying a new license for the dedicated server we'll set up if we deem it necessary.

Yuval.

Re: Advice needed about room level extensions.

Posted: 13 Mar 2012, 10:11
by Lapo
If you create one setInterval per Room you are still creating one thread per Room. Once you have 500+ rooms you running alot of threads, probably too many. Today's quad/eight core machine can handle thousands of threads without too much problems but resources will go down quickly and the ability to scale is limited.
Make sure to look into the Scheduler class, we provide examples and docs about it.
Even better alternative is to use directly the Java ScheduledThreadPoolExecutor under java.util.concurrent
http://docs.oracle.com/javase/1.5.0/doc ... cutor.html

Re: Advice needed about room level extensions.

Posted: 13 Mar 2012, 14:30
by yuvallahav
do you really think this is the best solution? I mean, I'm using the set interval inside the rooms to count down turn times and delay events, from what I've read about the schedule process, it was pretty complicated, with quite a few variables for each event, and it seemed a little too complicated for me when in the end all I needed was a 5 seconds delay before I switch a turn from one player to the other... Although I was a little shocked to hear about the thread count this will generate.
Of course I would look into it and see how I can simplify my work with this mechanism, and see how it will work for me on the room level.

Yuval.

Re: Advice needed about room level extensions.

Posted: 15 Mar 2012, 09:30
by yuvallahav
Hello there again, Lapo, I have, if you please, a few simple questions about the scheduler that I didn't find an explanation about.

Code: Select all

var _scheduler = Packages.it.gotoandplay.smartfoxserver.util.scheduling
Should this be initiated in every room I have where I need to use the scheduler, or should this be done only once on the zone level (but if so, would I need to use the extension's "zone.getExtension" type of call to add a new task??).

Code: Select all

scheduler.destroy(null)
Should this be used when I kill a room to kill all room schedules, or would this kill the whole of the scheduler, and for the room level I should destroy only the specific tasks I have running in that room?

Code: Select all

* specifiying the delay interval (2nd param) in seconds
can this parameter have decimal points, or how can I have is execute a task after 1.5 seconds, and not 1 or 2??


Well, I guess this is all the information I need to get me started on converting my application.

Thanks again for the help!

Yuval Lahav.

Re: Advice needed about room level extensions.

Posted: 11 Apr 2012, 07:57
by Lapo
Should this be initiated in every room I have where I need to use the scheduler, or should this be done only once on the zone level (but if so, would I need to use the extension's "zone.getExtension" type of call to add a new task??).
A scheduler is not much more than a pool of threads. Ok? With this in mind it should go without saying that if running one thread-per-room is not the best solution, running one scheduler-per-room can be even worst.
Of course the scheduler is meant to work as a centralized pool of processes that serve a wide number of tasks.
In particular I would highly recommend to use directly the ScheduledThreadPoolExecutor coming with Java5 and higher, because of its greater flexibility. We created our own scheduler before Java5 but after that release we encourage to use this "new" tool coming with the JDK: http://docs.oracle.com/javase/1.5.0/doc ... cutor.html

Re: Advice needed about room level extensions.

Posted: 11 Apr 2012, 08:00
by yuvallahav
Hey Lapo, we've already solved this on another thread, but thanks!!

Yuval.