Game Server Downtime Data recovery

Source: Internet
Author: User

0. Overview:

In general, in order to improve the game speed, the online player's data will be cached in memory. If there are data updates, only the cached data in memory is updated, rather than updating the database directly. The cached data is periodically written back to the database (for example, 5-minute writes). When the server goes down, all the data from the last database update to the outage will be lost, the so-called back file. This part of the data will never be returned, usually after the server restarts to give all players a certain amount of compensation. 1. Intro:When MySQL updates the contents of the data table, it does not directly update the data in the data table itself, but writes the log first and then updates the data in the data table itself. The log file is fast because it is appended to the order of the files. But MySQL's data update because it is random access to the file, the speed will naturally be slower. This mechanism ensures that MySQL can recover data from the log after the outage. 2. Game server Downtime Recovery:Game Server cache player data is typically written to the database every few minutes. If this can be used in MySQL design, the player data is updated each time the update log is written, and then update the cached data, all successful after the reply to the client message. In this case, the player data loss contains only the part of the log that has not been written, which greatly reduces the loss of the game. At present, I think of two ways to achieve, are listed as follows: A. Each time the data is updated, the operation to update the data is converted to SQL directly to the log, and a global log number is accumulated. Each time the cached data is synchronized to the database, the most recent log number is synchronously written to the player database.    When the outage occurs, all of the logs are larger than the log number in the database after the update, re-executed again, the data is restored. B. Write a message that changes the state of the data as the log content and set the global log number. Each time the player data is synced to the database, the global log number is also synchronized to the database (each player saves his or her own global log number). When the outage restarts, each player logs on to detect if there is data loss, if there is data loss to read from the log before the outage failed to save the execution of the message (note: The execution of these messages can not send a message to the client). However, this is a way to log in after a reboot and the user may be stuck, as many downtime users need to recover data. The advantage is that you can quickly restart and accept client requests after you have crashed. Another way is to re-execute the message that the outage failed to save after the server restarts, restore the data to the latest, and then accept the client request.

Game Server Downtime Data recovery

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.