Service request processing system and service request processing method
By introducing load balancer and dual server architecture into the computer service architecture, it realizes automatic switching to the slave server when the master server fails, solving the service interruption problem and improving service stability and user experience.
Patent Information
- Application Number
- CN202411796599.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-03-21
AI Technical Summary
The existing computer service architecture can easily lead to service interruption in the event of server failure and affect the user experience.
Design a service request processing system, including client, master, slave and load balancer. The service request instruction is sent to the master server or slave server through the load balancer. The data is synchronized in real time between the master server and the slave server, and the fault status is monitored through the heartbeat mechanism, and the target server is automatically switched.
In the event of a master server failure, the system can automatically switch to the slave server to avoid service interruption and improve service stability and user experience.
Smart Images

Figure CN119676244A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer networks, and in particular to a fault handling system and a service request handling method. Background Art
[0002] With the rapid development of Internet technology, users have higher and higher requirements for the availability of online services. However, when facing server failure, the existing computer service architecture will experience service interruption, thus affecting the user experience. This is because the fault handling system under the existing service architecture usually only includes a single server and database, and the server connects to the client to provide services to the client; when the server fails, the server cannot provide services to the client, and the service is interrupted. Therefore, maintaining stable service to the client is an urgent problem to be solved. Summary of the invention
[0003] The embodiments of the present invention provide a service request processing system and a service request processing method, which can solve the problem of interruption of service to a client when a single server fails in the prior art by adding a slave server, thereby improving the stability of service provision and further improving user experience.
[0004] An embodiment of the present invention provides a service request processing system, including: a client, a master server, a slave server and a load balancer;
[0005] The client is used to send a service request instruction to the load balancing server;
[0006] The load balancer is used to obtain the service request instruction of the client, and send the service request instruction to the target server, so that the target server obtains the target service according to the service request instruction, and feeds back the target service to the client through the load balancer;
[0007] Wherein, when the master server is not faulty, the master server is the target server; when the master server is faulty, the slave server is the target server.
[0008] Furthermore, the master server is used to send a first data synchronization instruction to the slave server in real time, so that the slave server synchronizes the data of the slave server to the master server when receiving the first data synchronization instruction.
[0009] Furthermore, the slave server is used to send a second data synchronization instruction to the master server in real time, so that the master server synchronizes the data of the master server to the slave server when receiving the second data synchronization instruction.
[0010] Further, the main server is deployed with a first high-availability service;
[0011] The first high-availability service monitors the failure status of the main server in real time through a heartbeat mechanism, and sends a main server failure instruction to the load balancer when the main server fails, so that the load balancer uses the slave server as the target server when receiving the main server failure instruction.
[0012] Further, after sending the main server failure instruction to the load balancer, it also includes:
[0013] The heartbeat mechanism is used to monitor the fault recovery status of the main server in real time, and when the main server fails to recover, a main server fault recovery instruction is sent to the load balancer, so that the load balancer uses the main server as the target server when receiving the main server fault recovery instruction.
[0014] Further, the slave server is deployed with a second high availability service;
[0015] When the slave server is used as the target server, the second high-availability service monitors the failure status of the slave server in real time through a heartbeat mechanism, and sends a slave server failure instruction to the load balancer when the slave server fails, so that the load balancer uses the master server as the target server when receiving the slave server failure instruction.
[0016] Further, the master server includes a first database, and the slave server includes a second database;
[0017] The first database is used to store data of the main server;
[0018] The second database is used to store data from the server.
[0019] Based on the above system embodiment, the present invention provides a method embodiment;
[0020] An embodiment of the present invention provides a service request processing method, which is applied to a load balancer of a service request processing system;
[0021] The service request processing method comprises:
[0022] Get the client's service request instruction;
[0023] Sending the service request instruction to the target server so that the target server obtains the target service according to the service request instruction and feeds back the target service to the client via the load balancer;
[0024] Wherein, when the master server is not faulty, the master server is the target server; when the master server is faulty, the slave server is the target server.
[0025] The following beneficial effects are achieved by implementing the present invention:
[0026] The present invention provides a service request processing system and a service request processing method, wherein the system includes a client, a main server, a slave server and a load balancer; when the client sends a service request instruction to the load balancing server, the load balancing server obtains the service request instruction and sends the service request instruction to the target server. When the target server is selected, the main server in the system is preferentially selected as the target server to provide services to the client. When the main server fails, the slave server is used as the target server to provide services to the client. By using the slave server as a backup server to provide services to the client when the main server fails, the service to the client will not be interrupted when the main server fails. The addition of the slave server solves the problem of interruption of service to the client when a single server fails in the prior art, thereby improving the stability of service provision and thus improving user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 It is a structural diagram of a service request processing system provided by an embodiment of the present invention.
[0028] Figure 2 It is a flowchart of a service request processing method provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0029] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0030] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0031] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by technicians in the technical field to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" in the specification and claims of this application and the above-mentioned figure descriptions and any variations thereof are intended to cover non-exclusive inclusions.
[0032] In the description of the embodiments of the present application, the technical terms "first", "second", etc. are only used to distinguish different objects, and cannot be understood as indicating or implying relative importance or implicitly indicating the number, specific order or primary and secondary relationship of the indicated technical features. In the description of the embodiments of the present application, the meaning of "multiple" is more than two, unless otherwise clearly and specifically defined.
[0033] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0034] In the description of the embodiments of the present application, the term "and / or" is only a description of the association relationship of the associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0035] In the description of the embodiments of the present application, the term "multiple" refers to more than two (including two). Similarly, "multiple groups" refers to more than two groups (including two groups), and "multiple pieces" refers to more than two pieces (including two pieces).
[0036] In the description of the embodiments of the present application, unless otherwise clearly specified and limited, technical terms such as "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, and it can be the internal connection of two elements or the interaction relationship between two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the embodiments of the present application can be understood according to the specific circumstances.
[0037] like Figure 1 As shown, a service request processing system provided by an embodiment of the present invention includes: a client, a master server, a slave server and a load balancer;
[0038] The client is used to send a service request instruction to the load balancing server;
[0039] The load balancer is used to obtain the service request instruction of the client, and send the service request instruction to the target server, so that the target server obtains the target service according to the service request instruction, and feeds back the target service to the client through the load balancer;
[0040] Wherein, when the master server is not faulty, the master server is the target server; when the master server is faulty, the slave server is the target server.
[0041] Specifically, the client communicates with the load balancer through an HTTP request, the load balancer establishes a communication connection with the master server, and the load balancer establishes a communication connection with the slave server. Preferably, the load balancer also establishes a communication connection with a base station in the system. In the present invention, the load balancer uses Nginx, which is an open source high-performance HTTP and reverse proxy server.
[0042] The user sends a service request instruction to the load balancing server through the client to request the service that the user needs to access. The load balancer is the request distribution part of the service request processing system, which acts as a reverse proxy and is responsible for distributing the service request instructions sent by the client to the target server. When distributing the service request instruction, if the main server has not failed, the main server is used as the target server and the service request instruction is distributed to the main server; preferably, when there are multiple main servers that have not failed, the main server with the least operating pressure among all the main servers is selected as the target server. If the main server fails, the slave server is used as the target server and the service request instruction is distributed to the slave server; preferably, when there are multiple slave servers that have not failed, the slave server with the least operating pressure among all the slave servers is selected as the target server.
[0043] In a preferred embodiment, the master server includes a first database, and the slave server includes a second database; the first database is used to store data of the master server; and the second database is used to store data of the slave server.
[0044] Specifically, the master server includes a first database for storing the data of the master server; preferably, the master server also includes a first cache database for storing the cache data of the master server; the master server also includes a first file server for storing and managing the files of the master server; the master server also includes a first forwarding server for providing data forwarding function for the master server. The slave server includes a second database for storing the data of the slave server; preferably, the slave server also includes a second cache database for storing the cache data of the slave server; the slave server also includes a second file server for storing and managing the files of the slave server; the slave server also includes a second forwarding server for providing data forwarding function for the slave server.
[0045] It should be noted that the first database and the second database are both MySQL databases.
[0046] In a preferred embodiment, the master server is used to send a first data synchronization instruction to the slave server in real time, so that the slave server synchronizes the data of the slave server to the master server when receiving the first data synchronization instruction.
[0047] In a preferred embodiment, the slave server is used to send a second data synchronization instruction to the master server in real time, so that the master server synchronizes the data of the master server to the slave server when receiving the second data synchronization instruction.
[0048] Specifically, the master server and the slave server maintain data consistency between the master server and the slave server through a data synchronization mechanism. For the master server, the data synchronization mechanism sends a first data synchronization instruction to the slave server in real time through the master server, so that the slave server synchronizes the data of the slave server to the master server when receiving the first data synchronization instruction. For the slave server, the data synchronization mechanism sends a second data synchronization instruction to the master server in real time through the slave server, so that the master server synchronizes the data of the master server to the slave server when receiving the second data synchronization instruction.
[0049] In a preferred embodiment, the main server is deployed with a first high-availability service; the first high-availability service monitors the fault status of the main server in real time through a heartbeat mechanism, and when the main server fails, sends a main server fault instruction to the load balancer, so that the load balancer will use the slave server as the target server when receiving the main server fault instruction.
[0050] Specifically, a first high-availability service is deployed in the main server. In the present invention, the first high-availability service is Keepalived, and Keepalived can be used to monitor the fault status of the main service. Keepalived uses a heartbeat mechanism to send a heartbeat detection signal to the main server at preset intervals. If the main server responds to the heartbeat detection signal, it is considered that the main server is running normally and has not failed. A heartbeat detection signal is still sent to the main server at the next time interval. If the main service times out and does not respond to the heartbeat detection signal, it is considered that the main server has failed, and a main server failure instruction is sent to the load balancer. When the load balancer receives the main server failure instruction, it redirects the route to change the routing rules originally directed to the main server to the routing rules at the slave server, thereby realizing that the slave server is used as the target server when the main server fails.
[0051] In a preferred embodiment, after sending the main server fault instruction to the load balancer, it also includes: monitoring the fault recovery status of the main server in real time through a heartbeat mechanism, and sending the main server fault recovery instruction to the load balancer when the main server fault recovers, so that the load balancer uses the main server as the target server when receiving the main server fault recovery instruction.
[0052] Specifically, after sending the master server failure instruction to the load balancer, Keepalived of the master server still sends a heartbeat detection signal to the master server at a preset interval through the heartbeat mechanism, until the master server responds to the heartbeat detection signal, it is considered that the master server has recovered from the failure and is in a failure recovery state, and then sends the master server failure recovery instruction to the load balancer. After receiving the failure recovery instruction, the load balancer changes the routing rules originally directed to the slave server to the routing rules at the master server through routing redirection, so that the master server is used as the target server when the master server fails and recovers.
[0053] In a preferred embodiment, the slave server is deployed with a second high-availability service; when the slave server is used as the target server, the second high-availability service monitors the failure status of the slave server in real time through a heartbeat mechanism, and when the slave server fails, sends a slave server failure instruction to the load balancer, so that the load balancer uses the master server as the target server when receiving the slave server failure instruction.
[0054] Specifically, a second highly available service is deployed in the slave server, and the second highly available service is Keepalived, which is the same as the first highly available service in the master server; when the slave server is used as the target server, Keepalived sends a heartbeat detection signal to the slave server at a preset interval through a heartbeat mechanism in the slave server. If the slave server responds to the heartbeat detection signal, it is considered that the slave server is running normally and has not failed, and a heartbeat detection signal is still sent to the slave server at the next time interval. If the slave service times out and does not respond to the heartbeat detection signal, it is considered that the slave server is faulty, and a slave server fault instruction is sent to the load balancer. When the load balancer receives the slave server fault instruction, it changes the routing rules originally directed to the slave server processing to the routing rules at the master server through routing redirection. Preferably, if the master server is still in a faulty state when the slave server fails, if there are multiple master servers or multiple slave servers at this time, a master server or slave server with the smallest operating pressure and in normal operating state is selected as the target server, and the data of the slave server is synchronized to the target server to avoid interruption of requests caused by serverless processing of client requests, so as to ensure that the user experience is not affected.
[0055] Based on the above system embodiment, the present invention provides a method embodiment, which is applied to a load balancer of the above service request processing system. The server request processing method includes:
[0056] Step S1: Obtain the service request instruction of the client;
[0057] Step S2: sending the service request instruction to the target server, so that the target server obtains the target service according to the service request instruction, and feeds back the target service to the client via the load balancer;
[0058] Wherein, when the master server is not faulty, the master server is the target server; when the master server is faulty, the slave server is the target server.
[0059] It should be noted that the system embodiment described above is merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the system embodiment provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art may understand and implement it without paying any creative effort.
[0060] Those skilled in the art can clearly understand that for the sake of convenience and brevity, the specific working process of the system described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0061] The terminal device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The terminal device may include, but is not limited to, a processor and a memory.
[0062] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the terminal device, and uses various interfaces and lines to connect various parts of the entire terminal device.
[0063] The memory can be used to store the computer program, and the processor realizes various functions of the terminal device by running or executing the computer program stored in the memory and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function, etc.; the data storage area can store data created according to the use of the mobile phone, etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0064] The storage medium is a computer-readable storage medium, and the computer program is stored in the computer-readable storage medium. When the computer program is executed by the processor, the steps of each of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium.
[0065] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A service request processing system, characterized in that: include: Client, master, slave, and load balancer; The client is used to send a service request instruction to the load balancing server; The load balancer is used to obtain the service request instruction of the client, and send the service request instruction to the target server, so that the target server obtains the target service according to the service request instruction, and feeds back the target service to the client through the load balancer; Wherein, when the master server is not faulty, the master server is the target server; when the master server is faulty, the slave server is the target server.
2. A service request processing system as claimed in claim 1, characterized in that: The master server is used to send a first data synchronization instruction to the slave server in real time, so that the slave server synchronizes the data of the slave server to the master server when receiving the first data synchronization instruction.
3. A service request processing system as claimed in claim 2, characterized in that: The slave server is used to send a second data synchronization instruction to the master server in real time, so that the master server synchronizes the data of the master server to the slave server when receiving the second data synchronization instruction.
4. A service request processing system as claimed in claim 3, characterized in that: The main server is deployed with a first high-availability service; The first high-availability service monitors the failure status of the main server in real time through a heartbeat mechanism, and sends a main server failure instruction to the load balancer when the main server fails, so that the load balancer uses the slave server as the target server when receiving the main server failure instruction.
5. A service request processing system as claimed in claim 4, characterized in that: After sending the primary server failure instruction to the load balancer, it also includes: The heartbeat mechanism is used to monitor the fault recovery status of the main server in real time, and when the main server fails to recover, a main server fault recovery instruction is sent to the load balancer, so that the load balancer uses the main server as the target server when receiving the main server fault recovery instruction.
6. A service request processing system as claimed in claim 5, characterized in that: The slave server is deployed with a second high availability service; When the slave server is used as the target server, the second high-availability service monitors the failure status of the slave server in real time through a heartbeat mechanism, and sends a slave server failure instruction to the load balancer when the slave server fails, so that the load balancer uses the master server as the target server when receiving the slave server failure instruction.
7. A service request processing system as claimed in claim 6, characterized in that: The master server includes a first database, and the slave server includes a second database; The first database is used to store data of the main server; The second database is used to store data from the server.
8. A service request processing method, characterized in that: A load balancer applied to a service request processing system as claimed in any one of claims 1 to 7; The service request processing method comprises: Get the client's service request instruction; Sending the service request instruction to the target server so that the target server obtains the target service according to the service request instruction and feeds back the target service to the client via the load balancer; Wherein, when the master server is not faulty, the master server is the target server; when the master server is faulty, the slave server is the target server.
Citation Information
Patent Citations
Disaster allowable system and method based on cluster backup
CN101309167A
A method and a device for service load balancing for a distributed system
CN102984184A
Service management method and device
CN106060088A
Load balancing method and load balancing system
CN106686129A
Method for achieving high availability of load balance servers based on distributed system
CN106993037A