1

I'm trying to modify a game engine so it records events (like key presses), and store these in a MySQL database on a remote server. The game engine is written in C++, and I currently have the following straightforward architecture, using mysql++ to directly INSERTrecords into appropriate databases:

Direct game to MySQL architecture

Unfortunately, there's a very large overhead when connecting to the MySQL server, and the game stops for a significant amount of time. Pushing a batch of Xs worth of events to the server causes a significant delay in gameplay (60s worth of events can take 12s to synchronise). There are also apparently security concerns with leaving the MySQL port accessible publicly.

I was considering an alternative option, instead sending commands to the server, which can interact with the database in its own time:

Indirect game to server architecture

Here the game would only send the necessary information (e.g. the table to update and the data to insert). I'm not sure whether the speed increase would be sufficient, or what system would be appropriate for managing the commands sent from the game.

Someone else suggested Log4j, but obviously I need a C++ solution. Is there an appropriate existing framework for accomplishing what I want?

Community
  • 1
  • 1
Druckles
  • 3,161
  • 2
  • 41
  • 65

1 Answers1

3

Most applications gathering user-interface interaction data (in your case keystrokes) put it into a local file of some sort.

Then at an appropriate time (for example at the end of the game, or the beginning of another game), they POST that file, often in compressed form, to a publicly accessible web server. The software on the web server decompresses the data and loads it into the analytics system (the MySQL server in your case) for processing.

So, I suggest the following.

  1. stop making your MySQL server's port available to people you don't know and trust.
  2. get your game to gather keystrokes locally somehow.
  3. get it to upload that data in big bunches when your game is not in realtime mode.
  4. write a web service to receive and interpret these files.

That way you'll build a more secure analytics system and a more responsive game.

O. Jones
  • 103,626
  • 17
  • 118
  • 172
  • i second that. Also, if the game has a client-server architecture already, the server should be verifying user commands anyway and thus it can also log them in the process. Unless the goal is to log local input rather than the commands generated from input. In that case only log *changes* in input state with timestamp to keep the logging to a minimum. – CodeSmile Jan 05 '15 at 20:23