Let's assume I'm developing a AJAX, PHP chess game. During the game, one movement of a player will be notified to the a开发者_Python百科nother 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?
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.
精彩评论