tags:

views:

35

answers:

1

Hi, Let's assume I'm developing a AJAX, PHP chess game. During the game, one movement of a player will be notified to the another but we are not saving that information. Normally, we used to store in MySQL every time a player makes movement and show update position to another player. What I want is to reduce MySQL load as much as possible and server is not interested in movements between two players. Server will only save final result like who wins. So what should I do?

+7  A: 

I assume you are going to need some sort of persistent storage to save the moves, so the alternative would be a memcache, or storing the data in files. The former is lightning fast but requires to be set up on the server. The latter has no real advantage over using a database IMO.

Any form of storage that takes place only on the users' computers (e.g. storing info in cookies or some other kind of persistent storage, see for example here or here) I would find too shaky: The playing session would be destroyed if both clients would have to restart their computers, which is not totally out of the question to happen.

Without any hard data that the mySQL server is overloaded with this kind of traffic, I would stick with the database. Otherwise, look into memcache.

Pekka
+1 for memcache; it's the perfect solution.
Matt
Thanks for the adivce Pekka. Sorry for my low level knowledge. What I understand for memcache is for caching. How could I use for my app? I just want to pass the position of a player to another player without storing in web server. I'm confused here! :D
Devyn
@Devyn Memcache is a fast system for storing and fetching data. With it, you would still be storing the moves on "server side" but in a faster environment than a database - and one that will not leave permanent records. Directly passing the position from player to player is hardly possible, and even if done, awfully unstable as I wrote above. If it's the amount of data you're worried about, you can always delete recent moves from the database after they have been transmitted to both clients. But I don't really know whether all this is justified. Is there really a performance problem?
Pekka