RPGDXThe center of Indie-RPG gaming
Not logged in. [log in] [register]
 
 
Post new topic Reply to topic Goto page Previous  1, 2, 3, 4  Next 
View previous topic - View next topic  
Author Message
janus
Mage


Joined: 29 Jun 2002
Posts: 464
Location: Issaquah, WA

PostPosted: Tue Mar 15, 2005 10:39 am    Post subject: [quote]

Hajo wrote:
Bjørn, I'm still not sure if I read the text correctly.

I think to understand that you plan to build a MMOG Server yourself? I'm interested in this topic, I'm pondering about expanding H-World with MOG functions.

How does usch a server core work? I mean the network stuff must handle conections to (possibly) a few thousand clients, yet handle all input in near-realtime.

How is this done? How is such a server core built usually?

I'm sorry for the imprecise answers, but I know so little about thsi that I can't even ask precisely.

My background (I hope this will help you to answer my questions on a useful level): I know how to use sockets. I have a little knowledge about networking basics, like datagrams vs. connection oriented protocols. But I don't have much practise with that stuff.
One of the main techniques I've seen used is dividing the game world up into sectors or zones and then running each one on a seperate server machine or in a seperate process. That way you can overcome the socket/memory/cpu power/etc limits, at least to a certain extent.

Running a big MMO is definitely not easy, though. Even the big boys like Sony and Blizzard run into trouble.
Back to top  
Hajo
Demon Hunter


Joined: 30 Sep 2003
Posts: 779
Location: Between chair and keyboard.

PostPosted: Tue Mar 15, 2005 11:01 am    Post subject: [quote]

I can imagine two approaches:

1) A main loop, polling all clients in round-robin fashion
2) A process or thread for each client

Solution (1) seems to be easier, but maybe can't keep the near-realtime requirements and I'm not sure if it scales well, if there are more than a few dozen players to keep track of?

Solution (2) will have all the problems of inter-process communictaion and/or thread synchronization.

So far my ideas. How is it done in real life :)

Edit: Currently I don't have serious plans. I'm just asking to learn. I have a slight idea of a building a multiplayer game world, but I'm not sure if it's better to expand H-World with networking or expand a existing open source MUD/MOG with the features that I put into H-World and don't want to miss.

Does/will ManaWorld allow users to expand the game world with new areas, like some MUDs do?
Back to top  
Ren
Wandering Minstrel


Joined: 07 Aug 2004
Posts: 130
Location: turn around...

PostPosted: Tue Mar 15, 2005 2:19 pm    Post subject: [quote]

janus wrote:
Running a big MMO is definitely not easy, though. Even the big boys like Sony and Blizzard run into trouble.


Good point, but big is the operant word here. The problem with World of Warcraft for example is proberbly that every man and his dog are trying to access the same event on the same server at the same time, and have been since launch date. The poor admins don't have any breathing space! I feel kinda sorry for Blizzard actually, I bet server maintenance is consuming a sizable portion of WoW profits right about now.

Now that I think about it, it might be worth finding out how the guys at Planeshift are doing things. Although I bet someone already thought of that, heh.
_________________
Previous nicks: MidnightDreamer, The_Anarchist, Shroomasta.

ren-tek.net : BGC games and more!
Back to top  
Verious
Mage


Joined: 06 Jan 2004
Posts: 409
Location: Online

PostPosted: Wed Mar 16, 2005 1:57 am    Post subject: [quote]

Quote:
1) A main loop, polling all clients in round-robin fashion
2) A process or thread for each client


I believe most of the larger MMORPG's use thread pooling and I/O completion ports. Thread pooling allows multiple users connections to exist on a single thread. If each user had their own thread you would bog the system down with context switching (the time it takes to switch between threads). I/O completion ports allow the threads and program to run in an asynchronous manner and is much more efficient than polling the inbound data buffers in a loop.

In most MMORPGs, the main game "loop" is usually a Finite State Machine, and is sometimes a Hierarchical Finite State Machine (which is really just multiple nested Finite State Machines).


Here a Microsoft article that explains thread pooling:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconThreadPooling.asp

And here's an article on I/O Completion Ports:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/i_o_completion_ports.asp

Here's an article that does an okay job of explaining Finite State Machines:
http://ai-depot.com/FiniteStateMachines/


By combining these techniques, with good code structure and other optimizations, you could easily support hundreds or thousands of users per server.

In reality, you will run out of system resources on the server long before you reach 32767 open sockets (the theoretical maximum for a single network interface).
Back to top  
LeoDraco
Demon Hunter


Joined: 24 Jun 2003
Posts: 584
Location: Riverside, South Cali

PostPosted: Wed Mar 16, 2005 4:04 am    Post subject: [quote]

Hajo wrote:
Solution (2) will have all the problems of inter-process communictaion and/or thread synchronization.


Along with Verious' explanation, most MMO's are probably using databases for storage of information; so, assuming that whatever underlying database architecture provides a mechanism to lock the database tables for writing, inter-process communication should hardly be a problem.
_________________
"...LeoDraco is a pompus git..." -- Mandrake
Back to top  
biggerUniverse
Mage


Joined: 18 Nov 2003
Posts: 326
Location: A small, b/g planet in the unfashionable arm of the galaxy

PostPosted: Wed Mar 16, 2005 4:24 am    Post subject: [quote]

http://jerome.biggeruniverse.com :)
_________________
We are on the outer reaches of someone else's universe.
Back to top  
Hajo
Demon Hunter


Joined: 30 Sep 2003
Posts: 779
Location: Between chair and keyboard.

PostPosted: Wed Mar 16, 2005 8:27 am    Post subject: [quote]

BiggerUniverse, thanks for the link, but unfortunately H-World is C++ (I wanted a change from my job to my private projects) and I don't think a C++/Java hybrid would be a good idea on the long run. Yet, seeing the Jerome project, I very much regret to have made my choice against Java :(

Verious, thank you for the links. The explanations are very good! I knew about thread pools in Java, but since I never used Threads in C++ so far, the solution didn't come to my mind.

I didn't know about IO Completion Ports. The article is specific for Windows. H-World is dual-platform, Linux and Windows. Is there a similar API available for Linux or are there ways to emulate IO Completion Ports with plain sockets?

Thanks for your help!
Back to top  
Bjorn
Demon Hunter


Joined: 29 May 2002
Posts: 1425
Location: Germany

PostPosted: Wed Mar 16, 2005 11:47 am    Post subject: [quote]

I will try to answer a few things quickly, because I'm in a bit of a hurry. At the moment we're putting down the overall server design and the main loop of the server, and we're only moderately worrying about how to handle 1000 connected clients at the same time. The design should be flexible enough to be changed as needed later.

Also, because we're a free project with no money for any big servers (we don't want to depend on donations either), we're aiming for about 1000 players per server (possibly even less) and servers with a 1 Mbps internet connection (so many people would be able to host a server).

For more information, you could look here:

http://themanaworld.sourceforge.net/wiki/?ServerDevelopment

Just note that we haven't actually started to write any code yet.
Back to top  
Hajo
Demon Hunter


Joined: 30 Sep 2003
Posts: 779
Location: Between chair and keyboard.

PostPosted: Wed Mar 16, 2005 12:43 pm    Post subject: [quote]

Actually the question where to host the game worries me most. Indeed it is the reason why I never tried to make a MOG so far.

Hosting is expensive and my own internet connection gets shut down every 24 hours and a new IP address is assigned after opening it again. (They do it just to prevent offering services this way, it's done on purpose).

I assume even 1000 users are a dream for my project, I rather think in magnitudes of a few dozen to a few hundred if I'm lucky.
Back to top  
biggerUniverse
Mage


Joined: 18 Nov 2003
Posts: 326
Location: A small, b/g planet in the unfashionable arm of the galaxy

PostPosted: Wed Mar 16, 2005 2:28 pm    Post subject: [quote]

If you aren't expecting many users, then a single-threaded round-robin approach can work. Look at any of the MUDs (Aber, Diku, etc.) and see how they are handling it. With either thread pools or single threaded, of utmost importance is how you implement your messaging subsystem. I.e., how you handle queuing, how different message types are handled, and how they are moved around.
_________________
We are on the outer reaches of someone else's universe.
Back to top  
Hajo
Demon Hunter


Joined: 30 Sep 2003
Posts: 779
Location: Between chair and keyboard.

PostPosted: Wed Mar 16, 2005 3:07 pm    Post subject: [quote]

A message queing system ... I don't know how to fit it to my current idea of the architecture.

ATM my client uses an RPC (remote procedure call) style communication. E.g. the client asks the server to send map data for a certain cell of the world and in response the client will receive this data.

Maybe this is a bad idea?

A message queuing system will detach the networking layer and the server code. The server reads the message from the clients socket, and put it into the queue. Later the message will be processed. How does the result find the path to the correct client?

Maybe I should move away from the RPC style to a messaging style communication? Use a free flow of messages in both directions? Looks like anarchy, and I'm afraid that it adds quite some complexity in handling the server responses on the client side?

You see, I'm the 100% newbie in this area. I appreciate all your input very much!
Back to top  
tcaudilllg
Dragonmaster


Joined: 20 Jun 2002
Posts: 1731
Location: Cedar Bluff, VA

PostPosted: Wed Mar 16, 2005 6:28 pm    Post subject: [quote]

I think the queue idea is the best of all possible solutions, given what we seem to know about them.

With a queue you can get info from everybody, and update the system at set intervals. It works out in "realtime" because everyone is working on the same set of information, so no one notices it's a "fragmented" timeline they are playing on.

I had an idea to use cookies to communicate with a CGI script, and to exchange data between clients that way. The cookie is written to an "action" file, so to speak, with the actions of each player loaded in their turn. Each player would update the action file with their action once an interval. (say, every 10th of a second) The CGI script would, at the beginning of each interval, load the action file and make the changes described in it happen on the client. In this way, all the clients do the work of running the game, and the CGI script is left with the work of managing the record of their respective actions, so that the clients can come to it to learn what the other clients have done.

To do this effectively, one would need to exacerbate the length of a CGI script. Most servers have a timeout period enforced over large script loops, and will cut them off. This tactic can be mediated by using the sleep statement to pause the script, but even this only works for a few minutes, after which the local internet backbone will clip the transmission. Reloading the CGI before then, say every two minutes or so, could work I think. I made some test programs to learn all of this, and put them on Tripod for testing, but I don't think even they function anymore, so maybe web administrators have become wise to the "sleeping loop" strategy I described. They don't really have a reason to stop it, because it's not a big bandwidth hog at all, really, and it would actually bring MORE traffic to their servers and more ad revenue with it, but go figure....
Back to top  
biggerUniverse
Mage


Joined: 18 Nov 2003
Posts: 326
Location: A small, b/g planet in the unfashionable arm of the galaxy

PostPosted: Wed Mar 16, 2005 11:48 pm    Post subject: [quote]

Hajo wrote:
A message queing system ... I don't know how to fit it to my current idea of the architecture.

ATM my client uses an RPC (remote procedure call) style communication. E.g. the client asks the server to send map data for a certain cell of the world and in response the client will receive this data.

Maybe this is a bad idea?

A message queuing system will detach the networking layer and the server code. The server reads the message from the clients socket, and put it into the queue. Later the message will be processed. How does the result find the path to the correct client?

Maybe I should move away from the RPC style to a messaging style communication? Use a free flow of messages in both directions? Looks like anarchy, and I'm afraid that it adds quite some complexity in handling the server responses on the client side?

You see, I'm the 100% newbie in this area. I appreciate all your input very much!


You're ok on RPC. When a request comes from the client, the server picks it up, and puts it in a message structure that includes the client's id. It is then placed in the queue and processed as the server can handle it. The client has to be able to survive even if it doesn't get a reply for every request it sends, and getting messages it didn't ask for. Which basically means the client can't block waiting for replies. If you expect so few replies, then process every message as it arrives without queues.
_________________
We are on the outer reaches of someone else's universe.
Back to top  
Hajo
Demon Hunter


Joined: 30 Sep 2003
Posts: 779
Location: Between chair and keyboard.

PostPosted: Thu Mar 17, 2005 8:33 am    Post subject: [quote]

@Biggeruniverse

Yesterday I discussed this problem with a colleague. We discussed pros and cons of RPC and message queuing implementations. The most flexible system seems to be message queuing, but it's also the most complex.

We brought up the idea of two queues:_ a queue client->server and a queue server->client

Messages contain a action to perform and parameters/data needed to peform this action. So a message from client to server which as RPC would be waiting for a result, causes the server to send back a message with an action that produces this result on the client.

At the moment I have no sound idea if this way of detached asynchroneous action handling works well, but I think since the sequence of messages is kept, it should.

Currently I feel seriously trapped because Java is much better in the networking support, but most of my selfmade code so far is C++. Either way I'll have to write a lot of code or port a lot of code. I don't know if I'll try it.

@LordGalbalan

I had a near-realtime system in mind. CGI and cookies don't fit well in this scenario, I think.
Back to top  
tcaudilllg
Dragonmaster


Joined: 20 Jun 2002
Posts: 1731
Location: Cedar Bluff, VA

PostPosted: Thu Mar 17, 2005 5:58 pm    Post subject: [quote]

Hajo:
Well if you take out the cookies and CGI and replace them with an array hosted by the server, then I think the same could work OK, don't you think?
Back to top  
Post new topic Reply to topic Page 2 of 4 All times are GMT
Goto page Previous  1, 2, 3, 4  Next 



Display posts from previous:   
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum