Master-Slave Server Switching via Real-Time State Synchronization
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
In distributed storage systems, the time-consuming process of reading operation records from memory or hard disks can prevent backup servers from maintaining the same state as the primary server after a failure, leading to service interruptions.
Innovation Solution
Implementing a primary memory database that saves state information in real time and a backup memory database configured to read and save this information, allowing for immediate switching to the backup server as the new primary server upon failure, using Redis memory databases for efficient key-value storage.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Quantity of substance
If operation records are stored in memory or hard disk using LRU algorithm, then memory capacity is optimized, but reading operation records becomes time-consuming
Solution Approach 1:
The patent applies preliminary action by pre-loading operation records into memory before they are needed for backup synchronization. The system proactively manages memory allocation and pre-positions frequently accessed operation records in memory, so that when the backup server needs to read these records after a failure, they are already available without time-consuming disk I/O operations.
2Loss of information
If operation records are read from memory or hard disk, then data is retrieved, but the process is time-consuming and prevents timely state synchronization
Solution Approach 1:
The patent implements continuity of useful action by establishing a continuous operation record capture and transmission mechanism. The primary server continuously captures operation records and maintains them in memory, while the backup server continuously synchronizes with these records. This continuous operation ensures that when a failure occurs, the backup server can immediately access the latest operation records without interruption or delay.
3Reliability
If backup server performs same operations in real time, then state consistency is maintained, but memory capacity limitations prevent complete operation record storage
Solution Approach 1:
The patent applies the taking out principle by extracting the operation record storage function from the backup server's memory and relocating it to the primary server's memory. The primary server, which has access to the operation records as they are generated, maintains them in its memory using the LRU algorithm. The backup server then receives these pre-stored operation records through a transmission mechanism, eliminating the need for the backup server to store and manage operation records locally.
Data Source
Figure 1~3
Figure 4~5
Figure 6
AI summary
The present disclosure relates to a master-slave server switching method and apparatus, an electronic device and a storage medium. Said method comprises: monitoring whether a fault occurs in a master server, the master server being provided with a master memory database, the master memory database being used to save in real time state information of the master server each time after an operation is executed, and the state information being read and saved in real time by a slave memory database in a slave server; and if a fault occurs in the master server, sending a master-slave switching command to the slave server, the master-slave switching command being used to instruct the slave server to upgrade itself to become a new master server according to the state information saved in the slave memory database. As the state information of the master server is written into the master memory database in real time, and the slave memory database in the slave server reads the state information from the master memory database in real time, when a fault occurs in the master server, it is possible to keep the state of the slave server consistent with the state of the master server before failure.