Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Syrillix

is multi threading needed for network games?

This topic is 5575 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

well im nearing completion on my last project and ive started thinking about what i want to do for my next project and i wanted to a multiplayer game but in one of my books it states that multi-threading is really the best way to deal with multiplayer code.. multi-threaded coding in win32 just sounds like im about to walk in front of a firing line at precisely the wrong time just wanted to hear what other people thought before i open up another can of worms.. Get busy livin'' or get busy dyin''... - Shawshank Redemption Altered Vision

Share this post


Link to post
Share on other sites
Advertisement
It depends what kind of game. If you don''t plan to have hordes of clints, then you do not need multi-threaded server. In fact it would over-complicate matters a fair bit. If you want to make something along the lines of a MMORPG, then yes, you''ll be using threads.

State your more specific needs.

Share this post


Link to post
Share on other sites
well im not planning an MMO game, thats just plain unrealistic
but i was really looking for a general answer, but the game idea is really just a shooter like quake or UT (just not as good )

Get busy livin'' or get busy dyin''... - Shawshank Redemption
Altered Vision

Share this post


Link to post
Share on other sites
quote:
If you want to make something along the lines of a MMORPG, then yes, you''ll be using threads.


Why on earth would you say that?

Share this post


Link to post
Share on other sites
quote:
Original post by fingh
quote:
If you want to make something along the lines of a MMORPG, then yes, you''ll be using threads.


Why on earth would you say that?


Well, you''d be using IOCP right? And that requires threads?

Share this post


Link to post
Share on other sites
quote:
Well, you''d be using IOCP right? And that requires threads?

No, likely you wouldn''t be using IOCP for a MMOG. For a huge system like an MMO you will likely run your servers on a "cheap" OS like Linux, which does not support IOCP. You don''t need IOCP on the client (which IS 99% likely to be Windows), as there''s no particular benefit over using other IO models when dealing with only one connection.

This isn''t a slam on Windows, but it''s an industry reality for all but a few studios that are contracted with Microsoft to use MS technologies (e.g. XBox Live).

IOCP is a viable server option if you plan on using later versions of Windows exclusively. It is not necessary to use IOCP, but it is one option.

Share this post


Link to post
Share on other sites
Hmm for our project, we use a thread that packs and unpacks RPC calls, while idling the remaining time waiting for packets. This is not exactly required, but I like having parallel stuff working at the same time (+ it might be a bit faster that way on hyperthreading CPUs and SMP machines, even if only by 1-2%). That''s for the client side, though.
For the server side, we use many threads, but that mainly because the servers have multiple CPUs (and again, cause I like the design that way)...
In a more general way, it depends of the kind of game and the number of clients you expect. I guess for maximum 8 players, a simple select() is much simpler than a thread per client. Above that, you might consider distributing clients on 2 or 3 separate threads. If you follow that route, one little hint though : creating a thread takes time, so create them when the server starts, and distribute clients over them, rather than creating a thread for each client connection.

Share this post


Link to post
Share on other sites
quote:
I guess for maximum 8 players, a simple select() is much simpler than a thread per client. Above that, you might consider distributing clients on 2 or 3 separate threads

As long as you are using TCP, this makes sense. Select() is extremely horrible performance-wise, but if you have enough connections to notice the performance hit, you are probably using the wrong protocol in the first place.

quote:
This is not exactly required, but I like having parallel stuff working at the same time

Yeah, like you, I appreciate having all my code running instead of sitting around waiting for CPU. If you are really into parallelism, try multiprocessing. It will allow you to scale your code across machines, thereby allowing you to purchase cheaper hardware. Your code will be easier to write, easier to debug, and easier to scale/loadbalance due to its somewhat location generic nature. You can still run all the processes on a single machine, or put some on different machine(s) as it becomes necessary. For the cost of one dual Xeon 2.4 GHz system, I can buy several (3-4) cheaper systems that are 2.0GHz single CPUs. Save the cash for paying off investors, or for hiring staff.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!