Room memory management

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Post Reply
User avatar
moccha
Posts: 114
Joined: 13 Feb 2014, 16:09

Room memory management

Post by moccha »

Hello,

I may reach 1000 fixed mmo rooms, all created with server boot. Each room has 1-3 Room variables in it.

I don't know if I should create them on startup. Does SmartFox do anything with rooms that don't have active users in them? There are many times where a good number of the rooms don't have any users, so I wonder if SmartFox optimizes memory use for those rooms when not in use.

Would it be better to create & destroy the rooms only when needed for users? For example, a user wants to join a certain room, the server creates it from settings and then joins them. I have a feeling that this approach may cause a lot of memory cleanup however because of constant create & destroy, so I am unsure if this would ever be a good approach.

Please advise if you have any general advice for this situation. I don't want to run into memory issues, but I don't know how much memory a average mmo room takes up in background.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Room memory management

Post by Lapo »

Hi,
Rooms in general use very little memory, especially if empty, but if you need to optimize memory as max as possibile it would be best to create them when they are needed.

MMORooms use more memory compared to regular ones as they rely on more complex data structures to keep track of every user and their AoI. So the advice above applies particularly to MMORooms.

The decision to create them all beforehand or when needed depends on how much RAM you've available. You can easily test the difference via the AdminTool Dashboard.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
moccha
Posts: 114
Joined: 13 Feb 2014, 16:09

Re: Room memory management

Post by moccha »

Hmm, I tested as you suggested and even when I create many MMORooms at startup, the memory usage doesn't seem to increase very much. I'd prefer to create them at startup so I can reference the roomIds for quick lookups, so this may still be viable.

Do you happen to know how much memory, very approximately, an MMORoom uses? Just a basic one with no users in it and no room vars? Even the MMORooms seem lightweight, which looks good.

I will also look into combining smaller MMORoom to reduce the number of areas as a bonus.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Room memory management

Post by Lapo »

Do you happen to know how much memory, very approximately, an MMORoom uses
No I don't I am sorry. The numbers are pretty low though, we're talking about in the range of KBytes.
If you have tested allocating a number of MMORooms and it doesn't affect memory usage that much then you're good to go, which is expected, in any case.

Typically you need to create 1000s of Rooms to see a significant difference.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply