BlackMouse
BlackMouse

Reputation: 4552

mysql query queue?

I have a multiplayer game which have started to generate some strange errors as more and more players have singed up.

There's about 1.5 million queries to the database/hour, and I think the problem is that some queries getting executed before some other queries have completed, since I didn't have any problems before, and I getting more and more as more people sign up.

I have two main classes: "sendTurn.php", and "removePlayer.php". If a player have taken to long to respond, he's kicked out. But I guess that problem is what happens if a player make his turn, just as he's being kicked out?

I read somewhere that the queries are put in a queue, but since it require several querys in each class to complete it, is it possible that when, for example, "sendTurn.php" is halfway done (done the first 1-2 queries) that the other class "removePlayer.php" will start to execute its queries?

In this case, what can I do?

Edit:

I use apace2 on a debian VPS server, with phpmyadmin

Upvotes: 5

Views: 1654

Answers (1)

Yaniv Peer
Yaniv Peer

Reputation: 161

It looks like a real solution would be a full architecture review, since this is more of an architecture question rather than a technical one. It's possible you can avoid this issue altogether but there is not enough information for me to use. However you could lock the sensitive tables whenever they are accessed for the full extent of their sensitive process. There will be a performance hit when a lot of players try to reach the same functions, but at least it will work.

For example for such a function

*LOCK TABLE*
Do queries
Do queries
Do queries
Do queries
*UNLOCK TABLE*

MYSQL example: http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html

Upvotes: 3

Related Questions