Extension within Zones and Rooms

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

Extension within Zones and Rooms

Postby Sparticus » 13 Mar 2006, 20:06

I just want to make sure I am going about this the best way.

If I had a list of 10 games someone could play such as (all 1 player games):
-tetris
-solitare
-etc


and within those games they are further subdivided into :
-easy
-medium
-hard

what would be the best way to divide the games into zones and rooms?

Would it be best to have the zones defined as :
-tetris
-solitaire
-etc

and the rooms as easy, medium, and hard?

I only ask because I want the most efficient way of doing things. If someone choose to play easy solitaire, there could be another 400 users in that room.... is that a big deal? Or should it create a new room for each user to use... then destroy the room when they are done their game?

What is the most efficient way to go about this? thx
Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

Postby Sparticus » 14 Mar 2006, 05:58

anyone have any thoughts?

please and thanx :)
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 14 Mar 2006, 06:43

You could use 2 approaches:

1- A new Zone for each game. This means that for each game the user will have to login in a different Zone

2- A single Zone for all games. This way you login once then choose which game to play.

I only ask because I want the most efficient way of doing things. If someone choose to play easy solitaire, there could be another 400 users in that room


400 users playing in the same room?? :shock: :shock:

humm... are you sure? :?
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Virusescu
Posts: 260
Joined: 07 Sep 2005, 09:36
Location: [RO]Bucharest
Contact:

Postby Virusescu » 14 Mar 2006, 09:23

Maybe they are playing a multiplayer TAG game :D... You're it :P.

MMORPG in flash :)?
function onJoin(usr) {if (usr.getName() == "Lapo") trace ("All Hail Lapo");}
Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

Postby Sparticus » 14 Mar 2006, 15:11

Oh.... I thought when I read the docs it said the server could handle like 2500 people in the same room? I thought 400 people playing games would be a peice of cake for the server?

Ok, if that won't work, how about if I made the zones :

Zone 1 : Easy Tetris
Zone 2 : Medium Teris
Zone 3 : Hard Tetris
Zone 4 : Easy Solitarie
etc...

and after they loged into the zone, it automattically created a new room for them, them they joined that room. They will be the only user in that zone becuase it was made just for their game and will be destroyed right after the game is done.

Is that a better approach?
Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

Postby Sparticus » 14 Mar 2006, 15:16

I also thought I read somewhere that each room you make, creates another instance of the extension/code and thus slows the server down... especially if I had 400 people in that zone... so having 1 room for all 400 would only have 1 instance of the code running and would have been more efficient..
User avatar
Virusescu
Posts: 260
Joined: 07 Sep 2005, 09:36
Location: [RO]Bucharest
Contact:

Postby Virusescu » 14 Mar 2006, 15:20

It's not a matter of handling that many clients at the same time.

It's about that kind of people playing the same game. Together.

they will be the only user in that zone becuase it was made just for their game and will be destroyed right after the game is done.

You mean Rooms. :)

Define better what want to do and I'm sure you'll get some advice.

Genneraly it's a good ideea to create zones for each type of game (i'm not talking about dificulties also) so that users playing tetris will see each other but won't see user playing solitair :).
function onJoin(usr) {if (usr.getName() == "Lapo") trace ("All Hail Lapo");}
Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

Postby Sparticus » 14 Mar 2006, 15:51

Well, although SmartFoxServer makes it easy to have chatroom, I am not using one at all.

From a webpage a user chooses a "single" player game they wish to play. There may be 20-30 games to choose from.

Once they choose a game, it opens a new window with the flash game in it. The flash game connects to the SFS server and handles all the data traffic (ie. saving their score to a database when they are done, etc).

So, I won't be having 400 people playing the exact same game together... but I may have 400 people play the same type of game at the same time (ie. tetris)... each user should not be able to see any data from any of the other players... they can't send messages to each player... each game is totally independant.

I had originally thought of putting them all in the same room (for that type of game) just because that way I'd only start up one instance of the tetris game code for example.... whereas if I made each user have their own room, i'd have 400 tetris extensions running at the same time.

I dunno.... I don't care how I program it... I just need some advice on what is the most efficient...


Thanx for the help!
User avatar
Virusescu
Posts: 260
Joined: 07 Sep 2005, 09:36
Location: [RO]Bucharest
Contact:

Postby Virusescu » 14 Mar 2006, 15:57

Umm... why do you need SFS again :roll: ?
No multiplayer, no chat, only for data handling?

Anyway. I would build only one extension at Zone level and every single player game would send an extension message with the data and all. Then the Zone extension would handle the data saving.

But, again, why would you go by using such a technique :)? I'm very curious :).


Good luck
function onJoin(usr) {if (usr.getName() == "Lapo") trace ("All Hail Lapo");}
Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

Postby Sparticus » 14 Mar 2006, 16:05

I had originally programmed a game server in C using sockets and threads... it was coming along pretty good.... but SFS server did all the dirty work for me. It makes it easy for me to send messages to the connected users.

I know I said it saves scores in the previous post... but it does more than that. Most games will have fairly constant traffic... plus it will be checking for cheaters, etc.

there will be allot of traffic on the server side... so I needed something efficient that could handle it.
Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

Postby Sparticus » 14 Mar 2006, 16:44

I guess what I really need to know is this.....

When a user connects to SFS and joins a room.... and that room uses a zone extension... behind the scenes, does a new thread get started for that user? Or does only one thread get started for the zone no matter how many users are connected?

I only ask because each user that plays a game will be sending constant messages to the server... maybe 1 a second. If there is only 1 thread allocated for all 400 users playing I "think" that may be a problem.

Hmm... I'm typing to think of the most efficience way..... I know when i wrote this in C... I had each client start a new thread... and when their game was done... it closed the thread.... Maybe I should have each user create their own room and have a room level extension for them (I assume this is basically a new thread for them).... and when their game is done is closes the room/thread.

But then I guess I have 400 threads running at the same time... lol... sigh... so confusing!
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 14 Mar 2006, 17:44

When a user connects to SFS and joins a room.... and that room uses a zone extension... behind the scenes, does a new thread get started for that user? Or does only one thread get started for the zone no matter how many users are connected?


Of course not! :shock: :)
If the server would create a new thread for each game or client it would quickly degrade in terms of performance.
All those threads woud just add unwanted overhead.
We use a configurable "pool" of worker threads. This can be adjusted based on the number of processors in the server machine allowing high scalability.

I would also recommend to use Zone level extensions instead of Room level whenever possible. Each time a new game room is created its extension must be loaded and compiled dynamically into executable bytecode.
This is okay when you don't have much traffic but it can become a performance problem when thousands of clients are hitting the server

hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 67 guests