Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8479481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:02:16+00:00 2026-06-10T19:02:16+00:00

I am new to game server design,now assigned to a task to refactory our

  • 0

I am new to game server design,now assigned to a task to refactory our log server. I create a class Log for communication between Game server and Log server.

class Log
{
    public:
        void    encode(Encoder& encoder) const;
        int     decode(Decoder& decoder);
    private:
        std::string sql_cmd;
}

On the game server, there is a class for send log request to log server.

class LogHelper
{
public:
        static void LogItemChange(const GameShare::GameItem& item, const PackageChangeDetails& pcd);
        {
                Log log(get_item_change_sql(item,pcd);
                send_to_log_server();
        }


private:
        static std::string get_item_change_sql(const GameShare::GameItem& item, const PackageChangeDetails& pcd);
}

The question is:

  1. Should I generate sql text on game server? If generate sql text on game server, does it have bad effect for performance of game server?

  2. If not generate sql text on game server, then should genrate sql text on log server. I should send GameItem and PackageChangeDetails instance data to log server, it will complicated the log server, does anybody has good ided?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T19:02:17+00:00Added an answer on June 10, 2026 at 7:02 pm

    If the log’s SQL is generated by the Game Server, then there is almost no need for there to be any Log Server code as it becomes a passthru to the database manager piece, which the Game Server almost certainly already knows about (although I imagine they could potentially be different databases), or could easily interact with.

    The Log Server should be a separate component that logs in whatever format is most convenient for you (performance, verbosity, size, etc), and as long as the API is flexible enough, it could be written such that the underlying implementation could be replaced without the Game Server knowing.

    By coupling complete knowledge of the underlying implementation with the Game Server code, you not only prevent such a future undertaking, but you are also putting potentially a lot of work into the Game Server’s code that could be done by a separate thread on the Log Server. Not to mention, by opening up the API to SQL, you are putting potential bugs all over the Game Server code that would otherwise be centralized.

    The forward looking, replacement-driven approach is ideal when designing Object Oriented systems. If you can avoid coupling to anything except an API, then you can always replace whatever is beneath the API without effecting the outside code (ignoring bugs), but this demands thought being put into the API to ensure that it has enough flexibility for the future.

    On that note, I strongly suggest that you implement the Logging API as a pure virtual interface, and then write an implementation on top of it that talks to the database, possibly with a separate implementation that logs to a text file (for convenient, local testing without a database accessible, if that’s ever an issue) as well as a do-nothing implementation. With the first two in mind, it should help to guide you to a better design, and away from coupling.

    This also might lead to some basic interface that your other classes implement (e.g., public: std::string to_log_string() const;), which can then be used by the Logger to bring in any implementing object and quickly convert it into a logged message.

    All of this is to say, put the logging related SQL into the Log Server and not in the Game Server. The Game Server shouldn’t care what the Log Server does beyond generically “logging.”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A new game server just came out which our company would like to offer
I am going to start a new online trading simulation game. Server Page: A
I'm sort of new to c++ and i'm trying to create a game. I
im making a game server the login server is done, now im working on
I'm using Visual Studio 2010 to create a client/server game(C#). I find myself doing
I'm trying to create a small game server using Ruby on Rails, Mongo, with
I've written a simple multi-threaded game server in python that creates a new thread
These days I am trying to design architecture of a new MMORPG mobile game
I'm making a new game that generates a huge grid (lets say 1000x1000). The
I am so happy that my new game is almost done and close to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.