Jump to content
  • Advertisement
Sign in to follow this  
hasore

Game practices

This topic is 2454 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

Hello,
I'm starting with multiplayer programming and have much questions to a good perfomance server.

First, the conditions of my game:
OS: Windows Server
Expected Players: 1000 for each game server.

1 - DB Connetion, i have do:

  • One db connection to each player.
  • One db connection in each server.
  • A DBServer interconnected to game/login server ( can post a example? );


    2 - Login<>Game Server, i have to do:

    • LoginServer save the session info and GameServer call login server to ask the session data via local sockets.
    • LoginServer save the session info and GameServer call login server to ask the session data via local messages.


      3 - General Socket questions.
      3.1. I need to create:

      • each thread for each packet received.
      • create a thread for each client connected and manipulate data.


        Obs:
        I'm pascal developer.
        I want solutions in any programming language.

        Thx.

Share this post


Link to post
Share on other sites
Advertisement
One database connection per player? That's not going to scale at all. You'll hose the database performance after a hundred connections or so.

Better is to have a single game server program which has one database connection and handles all the game logic, and synchronizes to the database via that single connection. Don't put game logic in your data layer if you can avoid it.

Also, one thread per connected client (much less one thread per packet?!) is never going to work out. You should have a thread pool with roughly twice as many software threads as hardware threads available on the machine, and use IOCP to handle the sockets. Pass this data into separate threads to do the game logic, i.e. don't do heavy duty logic in your network processing threads, or you will bottleneck your network traffic.


Please be advised that what you want is highly difficult even for domain experts. 1000 players on a single server will require a lot of care and discipline, and it's very easy to make mistakes or bad design decisions that will cause your scalability to plunge into the toilet. I recommend starting with something simpler to learn the basics of socket programming (say, 16 players or so) and then work your way up from there.

Share this post


Link to post
Share on other sites
Letting clients connect to database is a recipe for security problems (even if the performance can do it.) You always want an application/game/web/somekindof-server to be between the client's connection and the database, to enforce rules for example.
Using a thread per client (or, worse, per packet,) is a recipe for synchronization problems and lots of wasted machine resources. On clients, there's only one connection, so only the main thread is needed. On the server, there are thousands of connections, so thousands of threads will perform poorly. Instead use evented I/O (Linux) or overlapped I/O (Windows) on the sockets. Or use boost::asio for an easy wrapper.
I suggest you first read the content in the FAQ for this forum. If you then have questions, please come back and ask specific questions, like "I'm trying to do X using call Y, and expect to see Z but instead I see W," and we'll be much better able to answer your questions.
By the way: a single thread on a single server will handle 1,000 connections just fine, if the game is simple.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!