Service request processing method, application server and database node
By replicating business requests to the backup node for cache preheating in the database disaster recovery network, the problem of long cache preheating time after database master-slave switch is solved, enabling rapid recovery of business request volume and latency, and reducing system load and downtime risk.
Patent Information
- Application Number
- CN202410565169.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-06
- Publication Date
- 2025-11-07
AI Technical Summary
During the database master-slave switchover process, the long warm-up time of the standby node cache leads to slower response to database business requests, increased IO and CPU load, and is particularly prone to causing downtime risks during peak periods.
By replicating business requests from the application server to the backup node in the database disaster recovery network, cache loading and retention are performed in advance to ensure that the backup node cache is consistent with the primary node, thus shortening the cache warm-up time.
After the database master-slave switch, the business request volume and request latency quickly recovered to the level before the switch, avoiding the problem of increased IO and load during the long cache warm-up process and reducing the risk of downtime.
Smart Images

Figure CN120909835A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of database, and particularly relate to a business request processing method, an application server and a database node. BACKGROUND
[0002] In order to guarantee the availability of services, a database usually establishes a disaster recovery backup. The disaster recovery mode generally includes local dual-host backup, city dual-live backup and / or multi-live backup, etc. However, no matter what disaster recovery mode is, it can be simplified as a "master-slave mode". The "master" represents a node currently providing services, and the "slave" represents a node that can become a master and continuously provide services after the master fails. The master and the slave synchronize data through related synchronization technologies. At the same time, only one master node can perform read and write operations, and other slave nodes perform data synchronization. The disaster recovery switching process is the process of master-slave switching, that is, the master node fails to provide services, and the slave node switches to a new master node to provide services.
[0003] As is known to all, in order to improve system access latency, a computer system usually uses memory to cache data instead of directly accessing a disk. Similarly, in the database master-slave mode, the current master node caches hot data frequently accessed by the current business in the memory due to continuous request access. However, the slave node does not have connections and application requests from application clients, and the memory of the slave node is in an idle state and does not cache any data. When the slave node becomes a master, the cache held by the original master node will be lost. When the business request is sent to the new master node (i.e. the original slave node), the new master node will access the disk to load data and perform cache filling. The amount of cached data needs to be restored to the level before switching, which usually takes a long time (usually 60-300 seconds). Moreover, during this process, the input and output (IO) of the database reading data will increase sharply. Especially when the failure occurs during the application peak period, the request response will be slow due to cache warming, and the front-end request will be in a queuing state, further increasing the load of the database IO and central processing unit (CPU), thereby increasing the risk of database downtime. SUMMARY
[0004] Embodiments of the present application provide a business request processing method, an application server and a database node to implement copying business requests to the slave node in the database disaster recovery networking, and to perform cache loading and maintenance of the slave node in advance, so as to shorten the warming process of the cache corresponding to the slave node after the master-slave switching of the database, and to quickly restore the business request amount and request latency of the database to the level before switching.
[0005] In a first aspect, an embodiment of the present application provides a method for processing a service request, comprising: obtaining, by an application server, a first service request of a service process; when the first service request is a query request, sending the first service request to a first database node, so that the first database node obtains data corresponding to the first service request; and replicating the first service request, and sending the replicated first service request to a second database node, so that the second database node obtains the data corresponding to the first service request from a disk, and saves the data corresponding to the first service request into a cache corresponding to the second database node; wherein the first database node and the second database node are nodes in a database disaster recovery network; and receiving the data corresponding to the first service request sent by the first database node.
[0006] In the method for processing a service request, when the first service request is a query request, the application server sends the first service request to the first database node, so that the first database node obtains data corresponding to the first service request; and the application server replicates the first service request, and sends the replicated first service request to the second database node, so that the second database node obtains the data corresponding to the first service request, and saves the data corresponding to the first service request into a cache corresponding to the second database node. Thus, the application can replicate the service request to a standby node in a database disaster recovery network, and pre-load and maintain the cache corresponding to the standby node. After a master-standby switchover of the database, the preheating process of the cache corresponding to the standby node can be shortened, so that the service request volume and request delay of the database can quickly return to the level before the switchover.
[0007] In one possible implementation, after receiving the data corresponding to the first service request sent by the first database node, if a master-standby switchover is performed due to a database failure, after the application server obtains a second service request of the service process, when the second service request is a query request, the application server sends the second service request to the second database node, so that the second database node obtains data corresponding to the second service request from the cache corresponding to the second database node; and the application server receives the data corresponding to the second service request sent by the second database node.
[0008] In one possible implementation, before the application server obtains the first service request of the service process, the service process in the application server can also send a connection obtaining request to a logical connection pool in the application server; the logical connection pool obtains a connection of the first database node from a first database node connection pool in the application server; and the logical connection pool returns the connection of the first database node to the service process.
[0009] In one possible implementation, the application server obtaining the first service request of the service process includes: a logical connection pool in the application server obtaining the first service request of the service process, and the first service request including the connection of the first database node; and sending the first service request to the first database node includes: the logical connection pool sending the first service request to the first database node according to the connection of the first database node.
[0010] In one possible implementation, copying the first service request and sending the copied first service request to the second database node includes: the logical connection pool copying the first service request and sending the copied first service request to the second database node.
[0011] In one possible implementation, before the application server obtains the second service request of the service process, if a database fails and a master-standby switchover is performed, the service process in the application server can further send a connection obtaining request to the logical connection pool in the application server; the logical connection pool obtains the connection of the second database node from the second database node connection pool in the application server; and the logical connection pool returns the connection of the second database node to the service process.
[0012] In one possible implementation, the application server obtaining the second service request of the service process includes: the logical connection pool in the application server obtaining the second service request of the service process, and the second service request including the connection of the second database node; and sending the second service request to the second database node includes: the logical connection pool sending the second service request to the second database node according to the connection of the second database node.
[0013] In a possible implementation, before the service process in the application server sends a connection obtaining request to the logical connection pool in the application server, the application server further includes: the application server obtains a virtual IP address of a database instance passed in by the service process, and starts a monitor thread; the monitor thread queries a node list of the database disaster recovery network from the database instance according to the virtual IP address; the monitor thread receives the node list of the database disaster recovery network sent by the database instance; the node list includes an IP address of a first database node, a role of the first database node in the database disaster recovery network, an IP address of a second database node, and a role of the second database node in the database disaster recovery network; the monitor thread creates a logical connection pool according to the virtual IP address of the database instance, and creates a first database node connection pool and a second database node connection pool according to the node list; the first database node connection pool includes a connection of the first database node, and the second database node connection pool includes a connection of the second database node; the connection of the first database node is created according to the IP address of the first database node, and the connection of the second database node is created according to the IP address of the second database node.
[0014] In a possible implementation, after the node list of the database disaster recovery network is queried from the database instance, if the IP address of a node in the database disaster recovery network and / or the role of the node in the database disaster recovery network changes, the monitor thread can further receive an updated node list of the database disaster recovery network sent by the database instance, and then update the first database node connection pool and / or the second database node connection pool according to the updated node list.
[0015] In a second aspect, an embodiment of the present application provides a method for processing a service request, including: a database node receiving a first service request sent by an application server; the database node is a standby node in a database disaster recovery network, and the first service request is a query request; when the database node corresponding cache does not exist the first service request corresponding data, from the disk to obtain the first service request corresponding data; the first service request corresponding data is saved to the database node corresponding cache; if the database fails, the database node is switched to a master node in the database disaster recovery network, then after receiving a second service request sent by the application server, the second service request corresponding data is obtained from the database node corresponding cache; the second service request corresponding data is sent to the application server.
[0016] In the method for processing the service request, after the database node receives the first service request sent by the application server, when the data corresponding to the first service request does not exist in the cache corresponding to the database node, the database node acquires the data corresponding to the first service request from the disk, and saves the data corresponding to the first service request into the cache corresponding to the database node. Since the database node is currently a standby node in the database disaster recovery network, that is, the application server also sends the first service request to the standby node in the database disaster recovery network, the standby node maintains the same processing logic as the master node, and the data in the cache corresponding to the standby node is consistent with the data in the cache corresponding to the master node. In this way, if the database fails and the database node is switched to the master node in the database disaster recovery network, after receiving the second service request sent by the application server, since the data has been saved in advance in the cache corresponding to the database node, the database node can directly obtain the data corresponding to the second service request from the cache corresponding to the database node, without acquiring the data corresponding to the second service request from the disk, so that the service request amount and the request time delay of the database can quickly recover to the level before the switching.
[0017] In a third aspect, an embodiment of the present application provides an application server, comprising: one or more processors; a memory; a plurality of application programs; and one or more computer programs, wherein the one or more computer programs are stored in the memory, and the one or more computer programs comprise instructions, which, when executed by the application server, cause the application server to perform the method provided in the first aspect.
[0018] In a fourth aspect, an embodiment of the present application provides a database node, comprising: one or more processors; a memory; a plurality of application programs; and one or more computer programs, wherein the one or more computer programs are stored in the memory, and the one or more computer programs comprise instructions, which, when executed by the database node, cause the database node to perform the method provided in the second aspect.
[0019] It should be understood that the third aspect of the embodiments of the present application is consistent with the technical solutions of the first aspect of the embodiments of the present application, and the beneficial effects obtained by each aspect and the corresponding feasible implementation manners are similar, which will not be described herein again.
[0020] It should be understood that the fourth aspect of the embodiments of the present application is consistent with the technical solutions of the second aspect of the embodiments of the present application, and the beneficial effects obtained by each aspect and the corresponding feasible implementation manners are similar, which will not be described herein again.
[0021] In a fifth aspect, an embodiment of the present application provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and when the computer program runs on a computer, the computer program causes the computer to execute the method provided in the first aspect.
[0022] In a sixth aspect, an embodiment of the present application provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and when the computer program is executed on a computer, the computer program enables the computer to perform the method provided in the second aspect.
[0023] In a seventh aspect, an embodiment of the present application provides a computer program, when the computer program is executed on a computer, the computer program is used to perform the method provided in the first aspect.
[0024] In an eighth aspect, an embodiment of the present application provides a computer program, when the computer program is executed on a computer, the computer program is used to perform the method provided in the second aspect.
[0025] In a possible design, the programs in the seventh aspect and the eighth aspect can be stored in a storage medium packaged together with the processor in whole or in part, or stored in a storage medium not packaged together with the processor in whole or in part. BRIEF DESCRIPTION OF DRAWINGS
[0026] Figure 1 A schematic diagram of the service request quantity before and after the master-slave switchover of the database in the prior art;
[0027] Figure 2 An implementation schematic diagram of application query data in a solution provided by the prior art;
[0028] Figure 3 A flowchart of application query data in a solution provided by the prior art;
[0029] Figure 4 A synchronization principle diagram of the buffer cache provided by the prior art;
[0030] Figure 5 A structural schematic diagram of an application server provided by an embodiment of the present application;
[0031] Figure 6 A structural schematic diagram of a database node provided by an embodiment of the present application;
[0032] Figure 7 An implementation architecture diagram of a service request processing method provided by an embodiment of the present application;
[0033] Figure 8 An application scenario schematic diagram of a service request processing method provided by an embodiment of the present application;
[0034] Figure 9 A flowchart of a service request processing method provided by an embodiment of the present application;
[0035] Figure 10 A flow chart of a method for processing a service request according to another embodiment of the present application;
[0036] Figure 11 A flow chart of a method for processing a service request according to another embodiment of the present application;
[0037] Figure 12 A flow chart of a method for processing a service request according to another embodiment of the present application;
[0038] Figure 13 A flow chart of a method for processing a service request according to another embodiment of the present application;
[0039] Figure 14 A flow chart of a method for processing a service request according to another embodiment of the present application;
[0040] Figure 15 A flow chart of a method for processing a service request according to another embodiment of the present application;
[0041] Figure 16 A flow chart of a method for processing a service request according to another embodiment of the present application;
[0042] Figure 17 A flow chart of a method for processing a service request according to another embodiment of the present application;
[0043] Figure 18 A flow chart of a method for processing a service request according to another embodiment of the present application;
[0044] Figure 19 A flow chart of a method for processing a service request according to another embodiment of the present application;
[0045] Figure 20 A flow chart of a method for processing a service request according to another embodiment of the present application;
[0046] Figure 21 A flow chart of a method for processing a service request according to another embodiment of the present application;
[0047] Figure 22 A flow chart of a method for processing a service request according to another embodiment of the present application; DETAILED DESCRIPTION
[0048] The terms used in the embodiments section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.
[0049] In the prior art, in the database master-slave mode, the hot data frequently accessed by the current business is cached in the memory of the master node, and no data is cached in the memory of the standby node. When the standby node becomes the master, the cache held by the original master node will be lost, and when the business request is sent to the new master node (i.e. the original standby node), the new master node will access the disk to load data and perform cache filling. The amount of cached data needs to be restored to the level before the switchover, which usually takes a long time (for example: 60-300s), such as Figure 1 The time period of T2-T3 is shown in the figure, and during this process, the IO of the database reading data will increase sharply. Especially when the fault occurs during the application peak period, the request response will be slow due to the cache preheating, and the front-end request will be in a queuing state, further increasing the database IO and CPU load, thereby increasing the risk of database downtime. Figure 1 A schematic diagram of the business request amount before and after the master-slave switchover of the database in the prior art is shown in FIG. 1.
[0050] Figure 1 Before T1, the business request amount of the database is at a steady state, at T1, the master node fails, triggering the database to perform master-slave switchover, so during the time period of T1-T2, the database is unavailable, and the business request amount decreases to 0; at T2, the standby node becomes the master and completes the switchover, the business reconnects, and the business request amount of the database starts to recover, and at T3, the business request amount recovers to the original master node level. The time period of T2-T3 is the cache preheating time period of the standby node, and the length of this time period is usually 60-300s.
[0051] To solve this problem, a solution provided by the prior art is to deploy an independent cache cluster on the application side, such as Redis and / or Memcached technology. As shown in FIG. 2 and FIG. 3, each time data is queried, the application first queries the data in the cache. If the data to be queried exists in the cache (i.e. cache hit), the queried data is directly returned without accessing the database. If the data to be queried does not exist in the cache (i.e. cache miss), the database is queried again, and the query result is written into the cache for subsequent queries without querying the database. Figure 2 Figure 3 An implementation schematic diagram of the application querying data in a solution provided by the prior art is shown in FIG. 4. Figure 2 A flowchart of the application querying data in a solution provided by the prior art is shown in FIG. 5. Figure 3
[0052] The scheme can greatly reduce the direct access of the application to the database, even if the master node of the database fails, triggering the master-slave switching, most of the commonly used data can still be queried in the cache cluster deployed in the front end, so as to avoid the influence of the database failure on the application request throughput and time delay. However, the scheme needs to deploy and maintain a special cache cluster, and at the same time, due to the increase of components, the reliability risk of the system is increased, a special cache management module needs to be deployed in the application code, and when the data in the database changes (for example: the data in the database is increased, modified or deleted), the data in the cache cluster needs to be updated synchronously.
[0053] Another solution provided by the prior art related technology is the cluster cache management (CCM) of Amazon web services (AWS). The scheme automatically synchronizes the hot data in the buffer cache of the database master node to the standby node, ensures that the standby node also has hot data in the buffer cache. After the master-slave switching of the database failure, the buffer cache corresponding to the standby node of the database already has hot data, and there is no need to load data from the disk, which can quickly process the query request of the application, thereby greatly avoiding the influence of the database failure on the application request throughput and time delay.
[0054] Figure 4 The synchronization principle diagram of the buffer cache provided by the prior art related technology is shown in Figure 4 , the database standby node (such as AZ3 in Figure 4 ) sends the buffer address set of its own buffer cache to the database master node (such as AZ2 in Figure 4 ) as a bloom filter, which is to ensure that the standby node will not send the same buffer address to the master node. When the master node receives the bloom filter sent by the standby node, the master node will compare the blocks in the buffer cache, and send the frequently used buffer (the default number of uses is greater than 3) to the standby node.
[0055] However, the scheme is only applicable to the Aurora PostgreSQL service of AWS, and when the standby node of the database is at least two, only one standby node can be specified for cache synchronization, and if the standby node fails, the other standby node needs to be manually specified; as shown in Figure 4 , AZ1 and AZ3 in Figure 4 are standby nodes, but only AZ3 can be specified for cache synchronization, and if AZ3 fails, AZ1 needs to be manually specified for cache synchronization, which is very inconvenient to use.
[0056] Based on the above problems, the embodiment of the present application provides a service request processing method, which can be applied to the scenario of quickly recovering service performance after the database performs master-slave switchover. As described above, in the prior art, after the database performs master-slave switchover, the standby node needs to read data from the disk and load it into the cache, which will last for a period of time and cause great time delay and performance problems for the service.
[0057] To solve the problem that after the database performs master-slave switchover, the service request of the database needs 60 seconds to 300 seconds to recover to the level before the switchover due to the cache warm-up of the standby node, the embodiment of the present application provides a service request processing method, which eliminates the problem of large IO and increased database load caused by the cache warm-up process after the switchover, ensures that the execution time of the service request does not increase after the database performs master-slave switchover, and thus the service request volume can quickly recover to the level before the switchover. In addition, in the embodiment of the present application, the application server does not need to separately build a cache service or construct a component similar to cache synchronization, and the application server only needs to integrate a general software development kit (SDK), which is convenient to implement, does not increase the deployment and / or maintenance cost, and does not change the access logic of the database, and thus has high universal applicability.
[0058] The SDK is a collection of some development tools, which can be used to create application software for specific software packages, software frameworks, hardware platforms and / or operating systems, and the like. For example, the SDK can be the SDK used for developing application programs on the Windows platform. The SDK can include some files that provide application programming interfaces (APIs) for a certain programming language, and can also include complex hardware that can communicate with a certain embedded system.
[0059] The service request processing method provided by the embodiment of the present application can be applied to an application server, Figure 5 The application server provided by one embodiment of the present application has the structure as shown in the schematic structural diagram of the application server. Figure 5 As shown in the schematic structural diagram of the application server, the application server can include one or more processors, a memory, a plurality of application programs, and one or more computer programs, wherein the one or more computer programs are stored in the memory, and the one or more computer programs include instructions, which, when executed by the application server, cause the application server to execute the service request processing method provided by the embodiment of the present application.
[0060] The application server can be deployed in the cloud, and the form of the application server is not limited in the embodiment.
[0061] Figure 5 A block diagram of an exemplary application server suitable for use in implementing the present embodiments is shown. Figure 5 The application server shown is merely one example. It should be understood that any functionality described herein in relation to the application server can be performed by any other type of suitable system, and is not limited to the functionality of the specific application server described.
[0062] As Figure 5 shown, the application server is in the form of a general-purpose computing device. Components of the application server can include, but are not limited to, one or more processors 510, a communication interface 520, a memory 530, and a communication bus 540 that connects the different components (including the memory 530, the communication interface 520, and the processor 510).
[0063] The communication bus 540 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration bus, or a local bus using any of a variety of bus architectures. By way of example, and not limitation, the communication bus 540 can include an industry standard architecture (ISA) bus, a micro channel architecture (MCA) bus, an enhanced ISA bus, a video electronics standards association (VESA) local bus, and a peripheral component interconnect (PCI) bus.
[0064] The application server can typically include a number of computer system readable media. These media can be any available media that is accessible by the application server and includes both volatile and non-volatile media, removable and non-removable media.
[0065] The memory 530 can include computer system readable media in the form of volatile memory, such as random access memory (RAM) and / or cache memory. The memory 530 can include, without limitation, at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the methods of processing a service request provided by the present embodiments.
[0066] The program / utility, having a set of program modules, can be stored in the memory 530, for execution by the processor 510, including the operating system, one or more application programs, other program modules, and program data, each or any combination thereof, can include implementation of the network environment. The program modules typically carry out the functions of the business request processing method provided by the embodiments of the present application.
[0067] The processor 510 performs various function applications and data processing by running the program stored in the memory 530, such as implementing the business request processing method provided by the embodiments of the present application.
[0068] In addition, the implementation of the business request processing method provided by the embodiments of the present application not only involves the application server side, but also involves the database node side. The above-mentioned database node can be a node in the database disaster recovery networking.
[0069] An exemplary implementation of the business request processing method provided by the embodiments of the present application is shown in the following. Figure 6 The structure diagram of the database node provided by an embodiment of the present application is shown in the following. Figure 6 As shown in the figure, the database node 600 includes a processor 610 and a communication interface 620. Optionally, the database node 600 can also include a memory 630. The processor 610, the communication interface 620 and the memory 630 can communicate with each other through internal connection paths to transfer control and / or data signals. The memory 630 is used to store computer programs, and the processor 610 is used to call and run the computer programs from the memory 630.
[0070] The above-mentioned processor 610 and the memory 630 can be combined into one processing device, and more commonly, they are independent components. The processor 610 is used to execute the program code stored in the memory 630. In specific implementation, the memory 630 can also be integrated in the processor 610, or independent of the processor 610.
[0071] Optionally, the above-mentioned database node 600 can also include a power supply 650, which is used to provide power supply for various devices or circuits in the database node 600.
[0072] It should be understood that, Figure 6 The processor 610 in the database node 600 shown in the figure can be a system on chip (SOC), and the processor 610 can include a central processing unit (CPU), and can further include other types of processors, such as a graphics processing unit (GPU).
[0073] For the convenience of understanding, the following embodiments of the present application will be described with a database node having a processor and a memory. Figure 5The application server 500 shown in the structure has Figure 6 The database node shown in the structure is taken as an example, and the processing method of the service request provided by the embodiment of the application is described in detail in combination with the drawings and application scenarios.
[0074] The embodiment of the application provides a processing method of a service request, in which the standby node memory preheating capability is constructed based on an SDK, a query request sent to a master node is copied and sent to a standby node, and the standby node continuously performs the same reading operation as the master node in the normal read-only state, so that the cache corresponding to the standby node is consistent with the data stored in the cache corresponding to the master node.
[0075] Figure 7 The implementation architecture diagram of the processing method of the service request provided by one embodiment of the application is shown in the figure. Figure 7 As shown in the figure, the application server 500 includes an SDK 701, a logical connection pool 702, a physical connection pool 703, a database driver 704 and a service process 709; in addition, Figure 7 The architecture shown in the figure can further include a first database node 705, a second database node 706, a cache 707 corresponding to the first database node and a cache 708 corresponding to the second database node. Figure 7 The solid arrow in the figure indicates the flow direction of the service request sent to the database, and the dashed arrow indicates the data flow direction returned by the database. It should be noted that in the embodiment, the first database node 705 and the second database node 706 can be devices with the structure shown in the figure. Figure 6
[0076] The SDK 701 is integrated in the application server 500, and the service process 709 can send a service request to the database through the SDK 701. In addition, the service process 709 can query the node list of the database disaster recovery network from the database instance through the database driver 704 according to the virtual IP (virtual IP, VIP) address of the database instance. After obtaining the node list from the database instance, the SDK 701 can determine whether the master-standby switchover occurs according to the above node list, if the master-standby switchover occurs, the SDK 701 modifies the logical connection pool 702, and when the service process 709 acquires a connection, the logical connection pool 702 returns a logical connection encapsulating the connection of the second database node 706 to the service process 709; if the master-standby switchover does not occur, but the IP address of the first database node 705 changes, at this time, the SDK 701 can modify the physical connection pool 703, and modify the IP address corresponding to the physical connection pool 703 to the changed IP address.
[0077] The SDK 701 includes the logical connection pool 702 and the physical connection pool 703.
[0078] The logical connection pool 702 is a connection pool for connecting the database instance generated by the SDK 701 according to the VIP, and is directly provided to the business process 709. When the business process 709 acquires a connection, the logical connection pool 702 returns a logical connection encapsulating an actual physical connection in the back end.
[0079] The physical connection pool 703 can include a connection pool corresponding to each node (here, a physical node) in the database disaster recovery network, and is automatically initialized when the business process 709 is started. In this embodiment, the physical connection pool 703 can include a first database node connection pool and a second database node connection pool.
[0080] The VIP address mentioned above is an IP address that is not assigned to a real host, that is, the host providing the database service has a virtual IP address in addition to a real IP address. The link between the business process and the database is generally configured with the virtual IP address. When the master node in the database disaster recovery network fails and cannot provide services externally, the virtual IP address can be dynamically switched to the host where the standby node is located.
[0081] The database instance runs an instance of the database, and provides the VIP to the business process 709, so that the business process 709 connects the database instance according to the VIP. In this embodiment, the database instance can provide a node list of the database disaster recovery network to the SDK 701, and grant all users a data read (select) permission by default. The select permission is a data read (or data access) permission, and a user granted the select permission can perform a query operation on the database, that is, read the data saved in the database.
[0082] The node list of the database disaster recovery network records the IP address of the node in the database disaster recovery network and the role of the node in the database disaster recovery network. The node list of the database disaster recovery network is maintained by the database high-availability component, and is updated in real time after the master-standby switchover. The node list of the database disaster recovery network can include two fields: an IP address and a role. The IP address represents the IP address of the physical node corresponding to the database instance, and the role is the role (for example, a master node or a standby node) of the physical node corresponding to the database instance.
[0083] The master node (master) mentioned above can be a master node in the database disaster recovery network. When the master node is working normally, the database instance directs the VIP to the master node, and the master node provides the database service. Figure 7 In this embodiment, the first database node 705 is a master node.
[0084] The slave node can be a slave node in a database disaster recovery network, and normally exists as a backup in the database disaster recovery network. When the master node is working normally, the slave node does not provide database services. After the master node fails, the database instance redirects the VIP to the slave node, and the slave node provides database services.
[0085] The main role of the cache is to temporarily save the data processing results of the database in the memory, and wait for the next access. In many daily development scenarios, due to the performance limitation of the hard disk IO or the data processing and acquisition of the business system itself, which can be very time-consuming, when the data request volume of the system is large, frequent IO and frequent logical processing can cause the bottleneck of hard disk and CPU resources. The role of the cache is to save these hard-earned data in the memory. When other threads or clients need to query the same data resources, the data is directly returned from the cache memory block, which not only improves the system response time, but also saves the resource consumption of the data processing process. Overall, the system performance will be greatly improved. In the embodiment, each database node has its own corresponding cache. As shown in FIG. 7, the cache corresponding to the first database node is 707, and the cache corresponding to the second database node is 708. Figure 7
[0086] In the embodiment, the SDK 701 agent business process 709 sends a business request to the database through the connection returned by the logical connection pool 702 to the business process 709. The business process 709 uses the logical connection pool 702 as a normal database connection pool. The logical connection pool 702 encapsulates the connection object of the physical connection pool 703. In the case that the first database node 705 is working normally, the logical connection pool 702 returns a logical connection encapsulating the connection of the first database node 705 to the business process 709.
[0087] The business process 709 sends a normal business request to the logical connection pool 702. The SDK parses the structured query language (SQL) statement corresponding to the above business request, judges that the above business request is a query request, and then the logical connection pool 702 copies a copy of the same business request and sends it to the second database node 706, so that the second database node 706 loads data from the disk to the corresponding cache 708 in advance, and performs cache preheating and maintenance.
[0088] After the master-slave switching of the database occurs, the database selects the second database node 706 as the new master node, and the master-slave roles change. Because of the above steps, the data has been loaded in advance to the cache 708 corresponding to the second database node 706. Therefore, after the master-slave switching of the database, the business request volume of the database can quickly recover to normal.
[0089] During the whole process, the application server 500 only needs to integrate the SDK 701 realizing the above functions, without changing the code, realizing convenience, and the business process 709 can use the database in the normal way using the database connection pool, without changing the access logic of the database, and having high universal applicability.
[0090] The business request processing method provided by the embodiment of the application can realize the cache preheating and keeping of the database based on the SDK, can be applied to the database master-slave switching scene, and can ensure that the execution time of the business request does not increase after the master-slave switching, so that the business request volume can be restored to the normal level in seconds.
[0091] Figure 8 The application scene diagram of the business request processing method provided by one embodiment of the application is shown in FIG. 8. Figure 8 As shown in FIG. 8, the logical connection pool 702 distributes the business request to the first database node 705 and the second database node 706. The first database node connection pool 7031 and the second database node connection pool 7032 are different physical connection pools, the first database node connection pool 7031 executes the business request, and the second database node connection pool 7032 executes the mirrored business request, so as to realize the cache preheating of the second database node 706.
[0092] Specifically, after the logical connection pool 702 receives the business request of the business process, if the business request is a data reading (select) request, the logical connection pool 702 mirrors the business request after sending the business request to the first database node connection pool 7031, and sends the mirrored business request to the second database node connection pool 7032, but the logical connection pool 702 ignores the execution result of the business request returned by the second database node.
[0093] After the second database node 706 receives the business request, it is checked whether the data corresponding to the business request exists in the cache 708 corresponding to the second database node 706. If not, the second database node 706 initiates an IO request to load the data from the storage to the cache 708.
[0094] The business request processing method provided by the embodiment of the application is described in detail below. Figure 9 The flowchart of the business request processing method provided by one embodiment of the application is shown in FIG. 9. Figure 9 As shown in FIG. 9, the business request processing method can include the following steps.
[0095] In step 901, the application server 500 obtains the first business request of the business process.
[0096] At step 902, when the first service request is a query request, the application server 500 sends the first service request to the first database node for the first database node to obtain data corresponding to the first service request, and replicates the first service request and sends the replicated first service request to the second database node for the second database node to obtain the data corresponding to the first service request from a disk and save the data corresponding to the first service request into a cache corresponding to the second database node.
[0097] Specifically, referring to Figure 7 , the first database node and the second database node are nodes in a database disaster recovery network, where the first database node is currently a master node in the database disaster recovery network and the second database node is currently a standby node in the database disaster recovery network.
[0098] The first database node obtaining the data corresponding to the first service request can be that the first database node judges whether the data corresponding to the first service request exists in a cache corresponding to the first database node, if the data corresponding to the first service request exists in the cache corresponding to the first database node, the first database node obtains the data corresponding to the first service request from the cache corresponding to the first database node, and if the data corresponding to the first service request does not exist in the cache corresponding to the first database node, the first database node obtains the data corresponding to the first service request from a disk.
[0099] In this step, the application server 500 not only sends the first service request to the first database node, but also replicates the first service request and sends the replicated first service request to the second database node, so that the second database node can obtain the data corresponding to the first service request from the disk in advance and save the data corresponding to the first service request into a cache corresponding to the second database node, that is, the cache corresponding to the second database node is preheated in advance, so that the data in the cache corresponding to the second database node is consistent with the data in the cache corresponding to the first database node.
[0100] At step 903, the application server 500 receives the data corresponding to the first service request sent by the first database node.
[0101] In the method for processing the service request, the application server 500 obtains a first service request of a service process, when the first service request is a query request, the application server 500 sends the first service request to the first database node, so that the first database node obtains data corresponding to the first service request; and the first service request is copied, and the copied first service request is sent to the second database node, so that the second database node obtains data corresponding to the first service request, and the data corresponding to the first service request is saved in the cache corresponding to the second database node. Thus, the service request can be copied to the backup node in the database disaster recovery group network, the cache corresponding to the backup node is loaded and maintained in advance, and thus after the master-standby switching of the database, the preheating process of the cache corresponding to the backup node can be shortened, and the service request amount and request delay of the database can quickly return to the level before the switching.
[0102] Figure 10 The flowchart of the method for processing the service request provided by another embodiment of the application is shown in FIG. 10, and after step 903, the method can further include: Figure 10
[0103] In step 1001, if the database fails and the master-standby switching is performed, after the application server 500 obtains a second service request of the service process, when the second service request is a query request, the second service request is sent to the second database node, so that the second database node obtains data corresponding to the second service request from the cache corresponding to the second database.
[0104] In step 1002, the application server 500 receives the data corresponding to the second service request sent by the second database node.
[0105] In the embodiment, because in step 902, the data is loaded into the cache corresponding to the second database node in advance, the data saved in the cache corresponding to the first database node is consistent with the data saved in the cache corresponding to the second database node, thus after the master-standby switching of the database and the second database node becomes the master node in the database disaster recovery group network, the second database node can directly obtain the data corresponding to the second service request from the cache, without obtaining the data corresponding to the second service request from the disk, and thus the service request amount and request delay of the database can quickly return to the level before the switching.
[0106] Figure 11 The flowchart of the method for processing the service request provided by another embodiment of the application is shown in FIG. 10, and after step 903, the method can further include: Figure 11
[0107] In step 1101, the logical connection pool in the application server 500 sends a request for initializing the logical connection pool to the physical connection pool.
[0108] Step 1102, the application server 500 interacts with the first database node in the database disaster recovery networking, and creates a physical connection pool corresponding to the first database node; wherein the physical connection pool corresponding to the first database node is the first database node connection pool.
[0109] Step 1103, the application server 500 interacts with the second database node in the database disaster recovery networking, and creates a physical connection pool corresponding to the second database node; wherein the physical connection pool corresponding to the second database node is the second database node connection pool.
[0110] Wherein, the first database node is currently the master node in the database disaster recovery networking, and the second database node is currently the standby node in the database disaster recovery networking.
[0111] Step 1104, the physical connection pool returns an initialization success response to the logical connection pool.
[0112] Step 1105, the business process in the application server 500 sends a connection acquisition request to the logical connection pool in the application server 500.
[0113] Specifically, the business process can send a connection acquisition request to the logical connection pool through an SDK connection interface.
[0114] Step 1106, the logical connection pool acquires the connection of the first database node from the first database node connection pool in the application server 500.
[0115] Step 1107, the logical connection pool returns the connection of the first database node to the business process.
[0116] Step 1108, the logical connection pool in the application server 500 acquires the first service request of the business process, and the first service request includes the connection of the first database node.
[0117] Specifically, the business process in the application server 500 can send the first service request to the logical connection pool through an SDK connection interface, and the logical connection pool acquires the first service request.
[0118] In this embodiment, the first service request is a query request.
[0119] Step 1109, the logical connection pool sends the first service request to the first database node according to the connection of the first database node.
[0120] Step 1110, the first database node obtains the data corresponding to the first service request, and returns the data corresponding to the first service request to the business process.
[0121] Specifically, the first database node obtaining the data corresponding to the first service request can be: the first database node can first query whether the data corresponding to the first service request exists in the cache corresponding to the first database node, if the data corresponding to the first service request exists, the first database node obtains the data corresponding to the first service request from the cache corresponding to the first database node; if the data corresponding to the first service request does not exist in the cache corresponding to the first database node, the first database node obtains the data corresponding to the first service request from the disk, and saves the data corresponding to the first service request to the cache corresponding to the first database node.
[0122] Step 1111, the logical connection pool replicates the first service request, and sends the replicated first service request to the second database node.
[0123] Step 1112, when the data corresponding to the first service request does not exist in the cache corresponding to the second database node, the second database node obtains the data corresponding to the first service request from the disk, and saves the data corresponding to the first service request to the cache corresponding to the second database node.
[0124] In this embodiment, after the second database node obtains the data corresponding to the first service request, the second database node only saves the data corresponding to the first service request to the cache corresponding to the second database node, and does not return the data corresponding to the first service request to the service process.
[0125] In addition, it should be noted that after the second database node receives the replicated first service request, if the data corresponding to the first service request exists in the cache corresponding to the second database node, the second database node does not need to perform the operation of obtaining the data corresponding to the first service request from the disk.
[0126] In specific implementation, steps 1109-1110 and steps 1111-1112 can be executed in parallel, or can be executed in sequence, and the execution order of steps 1109-1110 and steps 1111-1112 is not limited in this embodiment.
[0127] Step 1113, if the database fails and the master-standby switching is performed, the service process in the application server 500 sends a second service request to the logical connection pool in the application server 500.
[0128] In this step, after the database fails, the first database node cannot work normally, so after the database performs the master-standby switching, the second database node becomes the master node in the database disaster recovery group network.
[0129] When the second service request is sent to the logical connection pool, the service process can also send the second service request to the logical connection pool through the SDK connection interface.
[0130] The second business request mentioned above is a query request.
[0131] Step 1114: The logical connection pool sends the second business request to the second database node.
[0132] Step 1115: The second database node obtains the data corresponding to the second business request from the cache corresponding to the second database.
[0133] In this embodiment, since the second database node has already performed cache preheating in step 1112, that is, the second database node has preloaded the data into the cache corresponding to the second database node, and the data stored in the cache corresponding to the first database node is consistent with the data stored in the cache corresponding to the second database node, after the database performs master-slave switch and the second database node becomes the master node in the database disaster recovery network, the second database node can directly obtain the data corresponding to the second business request from the cache corresponding to the second database node, without having to obtain the data corresponding to the second business request from the disk. Therefore, the business request volume and request latency of the database can be quickly restored to the level before the switch.
[0134] Step 1116: The business process in application server 500 receives the data corresponding to the second business request sent by the second database node.
[0135] In existing related technologies, such as Figure 12 As shown, the database driver 1201 in the application server is directly connected to the VIP and accesses the database using a physical connection pool. When the primary node 1202 of the database fails and a primary-standby switch is performed, the new primary node 1203 (i.e., the original standby node) needs to restore the cache from scratch. This results in a relatively long recovery time for business request volume in existing related technologies (e.g., ...). Figure 1 As shown, the time period from T2 to T3 is relatively long, and concentrating cache preheating during this period will increase database load, increase processing latency for business requests, and reduce business throughput. Figure 13 As shown, at time T2, the database performs a master-slave switch. After the original standby node becomes the master node, the execution time of business requests increases significantly, and it is not until time T3 that it returns to a steady-state execution time. Figure 13 In this context, the average SQL execution time is the execution time of the business request. Figure 13 This diagram illustrates the execution time of business requests before and after a primary / standby database switchover in existing related technologies. Figure 12 A schematic diagram illustrating the processing flow of business requests provided by existing related technologies.
[0136] In this embodiment, after the application server 500 integrates the SDK, the data in the cache corresponding to the standby node can be continuously kept consistent with the data in the cache corresponding to the master node. After the master-standby switchover of the database, the new master node (the original standby node) does not need to perform long-time cache preheating, so that the business request volume of the database can be quickly recovered, and the database load is not increased. Figure 14 At T2, the database performs the master-standby switchover, and after the standby node becomes the new master node, the business request volume can be quickly recovered, compared with Figure 1 The recovery time length of the business request volume from T2 to T3 is saved. Figure 14 The recovery of the business request volume of the database before and after the master-standby switchover is shown in an embodiment of the present application. Referring to Figure 15 At T2, the database performs the master-standby switchover, and after the standby node becomes the new master node, the execution time of the business request can also be quickly recovered to the steady-state execution time, compared with Figure 13 The recovery time length of the business request execution time from T2 to T3 is saved. Figure 15 The execution time of the business request of the database before and after the master-standby switchover is shown in an embodiment of the present application.
[0137] Figure 16 The flowchart of the processing method of the business request is provided in another embodiment of the present application. The execution process of steps 1101-1107 in the embodiment shown in Figure 11 The execution process of steps 1101-1107 in the embodiment shown in
[0138] As shown in Figure 16 The processing method of the business request can include the following steps.
[0139] In step 1601, the user starts a business process, and the business process triggers the initialization of the logical connection pool.
[0140] Specifically, after the SDK is integrated in the application server 500, the initialization operation of the logical connection pool is triggered by calling the SDK connection interface during the process of starting the business process.
[0141] In step 1602, the business process sends the VIP address of the database instance to the SDK connection interface.
[0142] In this embodiment, for example, the VIP address of the database instance can be 172.168.1.1.
[0143] In step 1603, the SDK starts a monitor thread.
[0144] In step 1604, the monitor thread queries the node list of the database disaster recovery network from the database instance according to the VIP address.
[0145] Step 1605, the monitor thread receives the node list of the database disaster recovery network sent by the database instance.
[0146] The node list includes the IP address of the first database node, the role of the first database node in the database disaster recovery network, the IP address of the second database node, and the role of the second database node in the database disaster recovery network.
[0147] For example, the node list can be:
[0148] The IP address of the first database node is 192.168.1.2, and the role is master.
[0149] The IP address of the second database node is 192.168.1.3, and the role is slave.
[0150] The master indicates that the current role of the first database node in the database disaster recovery network is master, which has the ability to execute business requests of business processes; the slave indicates that the current role of the second database node in the database disaster recovery network is slave, which does not have the ability to execute business requests.
[0151] Step 1606, the monitor thread creates a logical connection pool according to the VIP address of the database instance.
[0152] The logical connection pool is visible to the business process, and the business process sees a logical connection pool established according to the VIP address. When the business process obtains a connection, the logical connection pool returns a logical connection encapsulating the connection of the first database node to the business process.
[0153] Step 1607, the monitor thread creates a first database node connection pool and a second database node connection pool according to the node list.
[0154] The first database node connection pool and the second database node connection pool are different physical connection pools, the first database node connection pool includes the connection of the first database node, and the second database node connection pool includes the connection of the second database node. The connection of the first database node is created according to the IP address of the first database node, and the connection of the second database node is created according to the IP address of the second database node.
[0155] Specifically, the monitor thread can establish connections to the first database node with an IP address of 192.168.1.2 and the second database node with an IP address of 192.168.1.3 according to the node list.
[0156] In this embodiment, steps 1604-1607 are executed in a loop, so that in each loop execution process, the monitor thread queries the database instance for the node list of the database disaster recovery network, and if the IP address of the node in the database disaster recovery network and / or the role of the node in the database disaster recovery network changes, the monitor thread receives the updated node list of the database disaster recovery network sent by the database instance; then, the monitor thread can update the physical connection pool according to the updated node list, but will not modify the logical connection pool visible to the business process.
[0157] In step 1608, the physical connection pool returns a response of successful initialization of the logical connection pool to the business process.
[0158] In step 1609, the business process sends a connection acquisition request to the SDK connection interface.
[0159] In step 1610, the SDK connection interface sends the connection acquisition request to the logical connection pool.
[0160] In step 1611, the logical connection pool acquires the connection of the first database node from the physical connection pool.
[0161] In step 1612, the logical connection pool returns the connection of the first database node to the business process.
[0162] Specifically, referring to Figure 17 , after the SDK receives the connection acquisition request, the SDK acquires the connection of the first database node (192.168.1.2) whose current role is the master node from the first database node connection pool according to the master-slave role relationship of the database nodes, and then encapsulates the connection of the first database node into a logical connection and returns it to the business process. Figure 17 The schematic diagram of the logical connection pool provided by an embodiment of the present application.
[0163] Steps 1613-1615 are synchronous with steps 1108-1110.
[0164] In this embodiment, the SDK completes the initialization of the logical connection pool visible to the business process and the physical connection pool invisible to the business process, establishes the connection of the first database node and the connection of the second database node, and prepares for the cache warm-up after the database master-slave switchover.
[0165] Figure 18 The flowchart of the processing method of the business request provided by another embodiment of the present application, and the embodiment details the execution process of steps 1108-1116 of the embodiment shown in Figure 11 As shown in Figure 18 , the processing method of the business request can include:
[0166] Step 1801, the service process in the application server 500 sends a first service request to the SDK connection interface, wherein the first service request includes a connection of the first database node.
[0167] Step 1802, the SDK connection interface sends the first service request to the logical connection pool.
[0168] Step 1803, the logical connection pool sends the first service request to the first database node according to the connection of the first database node.
[0169] Step 1804, the first database node obtains data corresponding to the first service request.
[0170] Specifically, the first database node obtaining the data corresponding to the first service request can be: the first database node can first query whether the data corresponding to the first service request exists in the cache corresponding to the first database node, if the data corresponding to the first service request exists, the first database node obtains the data corresponding to the first service request from the cache corresponding to the first database node; if the data corresponding to the first service request does not exist in the cache corresponding to the first database node, the first database node obtains the data corresponding to the first service request from the disk, and saves the data corresponding to the first service request to the cache corresponding to the first database node.
[0171] Step 1805, the first database node returns the data corresponding to the first service request to the SDK connection interface.
[0172] Step 1806, the SDK connection interface returns the data corresponding to the first service request to the service process.
[0173] Step 1807, the logical connection pool copies the first service request, and sends the copied first service request to the second database node.
[0174] Step 1808, when the data corresponding to the first service request does not exist in the cache corresponding to the second database node, the second database node obtains the data corresponding to the first service request from the disk, and saves the data corresponding to the first service request to the cache corresponding to the second database node.
[0175] In this embodiment, after the second database node obtains the data corresponding to the first service request, only the data corresponding to the first service request is saved to the cache corresponding to the second database node, and the data corresponding to the first service request will not be returned to the service process.
[0176] In addition, it should be noted that after the second database node receives the first service request obtained by replication, if the data corresponding to the first service request exists in the cache corresponding to the second database node, the second database node does not need to perform the operation of obtaining the data corresponding to the first service request from the disk.
[0177] In a specific implementation, steps 1803 to 1806 and steps 1807 to 1808 can be executed in parallel or sequentially, and the embodiment does not limit the execution order of steps 1803 to 1806 and steps 1807 to 1808.
[0178] Step 1809, if the database fails and the master-slave switchover is performed, the service process in the application server 500 sends a connection obtaining request to the logical connection pool in the application server 500.
[0179] Specifically, the service process can send the connection obtaining request to the SDK connection interface, and the SDK connection interface sends the connection obtaining request to the logical connection pool.
[0180] Step 1810, the logical connection pool obtains the connection of the second database node from the second database connection pool in the application server 500.
[0181] As shown in FIG. 18B, after the database performs the master-slave switchover, the connection of the logical connection pool with the first database node is unbound, and the connection of the logical connection pool with the second database node (192.168.1.3) is bound, Figure 19 FIG. 18C is a schematic diagram of the logical connection pool provided by another embodiment of the application. Figure 19
[0182] Step 1811, the logical connection pool returns the connection of the second database node to the service process.
[0183] Step 1812, the logical connection pool in the application server 500 obtains the second service request of the service process, and the second service request includes the connection of the second database node.
[0184] Specifically, the service process can send the second service request to the SDK connection interface, and the SDK connection interface sends the second service request to the logical connection pool, and the logical connection pool obtains the second service request of the service process.
[0185] Step 1813, the logical connection pool sends the second service request to the second database node according to the connection of the second database node.
[0186] Step 1814, the second database node obtains the data corresponding to the second service request from the cache corresponding to the second database.
[0187] In this embodiment, since the second database node has performed cache preheating in step 1808, that is, the second database node has loaded data into the cache corresponding to the second database node in advance, the cache corresponding to the first database node stores the same data as the cache corresponding to the second database node, and thus after the database performs master-slave switching and the second database node becomes the master node in the database disaster recovery network, the second database node can directly obtain the data corresponding to the second service request from the cache corresponding to the second database node, without obtaining the data corresponding to the second service request from the disk, thereby reducing the time for loading data from the disk, and thus the service request amount and request delay of the database can quickly recover to the level before the switching.
[0188] In step 1815, the second database node sends the data corresponding to the second service request to the SDK connection interface.
[0189] In step 1816, the SDK connection interface sends the data corresponding to the second service request to the service process in the application server 500.
[0190] This embodiment can enable the second database node to maintain the same query logic and cache as the first database node, so that after the database performs master-slave switching, the cache preheating can be used on the new master node to quickly recover the service request amount of the database, and the impact on the service request caused by the database master-slave switching is minimized.
[0191] The method provided by this embodiment can quickly recover the service request amount, request delay, and / or throughput of the database to the level before the switching, while reducing the surge request of IO and / or CPU of the database caused by the master-slave switching, and reducing the load of the database.
[0192] Figure 20 The flowchart of the method for processing a service request provided by another embodiment of the present application is shown in FIG. 20. Figure 20 The method for processing a service request can include the following steps.
[0193] In step 2001, the database node 600 receives a first service request sent by the application server 500.
[0194] The database node 600 can be a standby node in the database disaster recovery network, for example, the database node 600 can be the second database node 706 in the database disaster recovery network 700. Figure 7 The first service request is a query request.
[0195] In step 2002, when the data corresponding to the first service request does not exist in the cache corresponding to the database node 600, the database node 600 obtains the data corresponding to the first service request from the disk.
[0196] At step 2003, the database node 600 saves the data corresponding to the first service request into the cache corresponding to the database node 600.
[0197] At step 2004, if the database fails, the database node 600 is switched to the master node in the database disaster recovery network, and after receiving the second service request sent by the application server 500, the database node 600 obtains the data corresponding to the second service request from the cache corresponding to the database node 600.
[0198] At step 2005, the database node 600 sends the data corresponding to the second service request to the application server 500.
[0199] In the above method for processing service requests, after the database node 600 receives the first service request sent by the application server 500, when the data corresponding to the first service request does not exist in the cache corresponding to the database node 600, the database node 600 obtains the data corresponding to the first service request from the disk and saves the data corresponding to the first service request into the cache corresponding to the database node 600. Since the database node 600 is currently the standby node in the database disaster recovery network, that is, the application server 500 also sends the first service request to the standby node in the database disaster recovery network, the standby node maintains the same processing logic as the master node, and the data in the cache corresponding to the standby node is consistent with the data in the cache corresponding to the master node. In this way, if the database fails and the database node 600 is switched to the master node in the above database disaster recovery network, after receiving the second service request sent by the application server 500, since the data has been saved in advance in the cache corresponding to the database node 600, the database node 600 can directly obtain the data corresponding to the second service request from the cache corresponding to the database node 600, without obtaining the data corresponding to the second service request from the disk, so that the service request amount and the request time delay of the database can quickly recover to the level before switching.
[0200] It can be understood that part or all of the steps or operations in the above embodiments are only examples, and the embodiments of the present application can also perform other operations or various modifications of the operations. In addition, each step can be executed in a different order from the order presented in the above embodiments, and it is possible that not all the operations in the above embodiments are executed.
[0201] It can be understood that, in order to implement the above functions, the application server comprises hardware and / or software modules corresponding to the respective functions. The algorithm steps of each example described in combination with the embodiments disclosed in the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is implemented in hardware or computer software driven hardware depends on the specific application of the technical solution and the design constraints. Those skilled in the art can use different methods to implement the described functions for each specific application in combination with the embodiments, but such implementation should not be considered beyond the scope of the present application.
[0202] The application server can be divided into functional modules according to the above method embodiments, for example, each functional module can be divided according to each function, or two or more functions can be integrated into one module. The integrated module can be implemented in the form of hardware. It should be noted that the division of the modules in the present embodiment is illustrative, and is only a logical functional division. Actual implementation can have another division method.
[0203] Figure 21 The structure diagram of the application server provided by another embodiment of the present application is shown in the case of dividing each functional module corresponding to each function, Figure 21 A possible composition diagram of the application server 2100 involved in the above embodiments is shown, as shown in the figure, Figure 21 The application server 2100 can include a receiving unit 2101, a processing unit 2102 and a sending unit 2103;
[0204] The receiving unit 2101 can be used to support the application server 2100 to execute steps 901, 903, 1001 and 1002, etc., and / or other processes of the technical solutions described in the embodiments of the present application;
[0205] The processing unit 2102 can be used to support the application server 2100 to execute step 902, etc., and / or other processes of the technical solutions described in the embodiments of the present application;
[0206] The sending unit 2103 can be used to support the application server 2100 to execute steps 902 and 1001, etc., and / or other processes of the technical solutions described in the embodiments of the present application.
[0207] It should be noted that all related contents of each step involved in the method embodiments of the present application can be cited to the function description of the corresponding functional module, which will not be repeated here.
[0208] The application server 2100 provided by the present embodiment is used to execute the present application Figure 9-10The service request processing method provided in the illustrated embodiment can achieve the same effect as the method described above.
[0209] It should be understood that application server 2100 can correspond to Figure 5 The application server 500 shown. The functions of the receiving unit 2101 and the sending unit 2103 can be determined by... Figure 5 The processor 510 and communication interface 520 in the application server 500 shown are used to implement the functionality of the processing unit 2102. Figure 5 The processor 510 in the application server 500 shown is implemented.
[0210] When using integrated units, the application server 2100 may include a processing module, a storage module, and a communication module.
[0211] The processing module can be used to control and manage the actions of the application server 2100. For example, it can support the application server 2100 in executing the steps performed by the receiving unit 2101, processing unit 2102, and sending unit 2103. The storage module can support the application server 2100 in storing program code and data. The communication module can support communication between the application server 2100 and other devices.
[0212] The processing module can be a processor or controller, which can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor can also be a combination of functions that implement computing capabilities, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc. The storage module can be a memory. The communication module can specifically be a device that interacts with other electronic devices, such as radio frequency circuitry, a Bluetooth chip, and / or a Wi-Fi chip.
[0213] In one embodiment, when the processing module is a processor and the storage module is a memory, the application server 2100 involved in this embodiment can be a device having... Figure 5 The device with the structure shown.
[0214] Similarly, it is understood that, in order to implement the above functions, database nodes include hardware and / or software modules corresponding to the execution of each function. Based on the algorithm steps of the various examples described in conjunction with the embodiments disclosed in this application, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementation should not be considered beyond the scope of this application.
[0215] The embodiment can divide the function modules of the database node according to the method embodiments described above. For example, each function module can be divided according to each function, or two or more functions can be integrated in one module. The integrated module can be implemented in the form of hardware. It should be noted that the division of the modules in the embodiment is illustrative, and is only a logical function division. In actual implementation, another division manner can be used.
[0216] Figure 22 The structure diagram of the database node provided for another embodiment of the application is shown in the case where each function module is divided according to each function, Figure 22 A possible composition diagram of the database node 2200 involved in the above embodiment is shown. As shown in the figure, the database node 2200 can include a receiving unit 2201, a processing unit 2202, and a sending unit 2203. Figure 22
[0217] The receiving unit 2201 can be used to support the database node 2200 to perform steps 2001 and 2004, and / or other processes of the technical solutions described in the embodiments of the application.
[0218] The processing unit 2202 can be used to support the database node 2200 to perform steps 2002, 2003, and 2004, and / or other processes of the technical solutions described in the embodiments of the application.
[0219] The sending unit 2203 can be used to support the database node 2200 to perform step 2005, and / or other processes of the technical solutions described in the embodiments of the application.
[0220] It should be noted that the embodiments of the application Figure 20 The functions of each step involved in the method embodiments described above can be referred to the function description of the corresponding function module, which will not be repeated here.
[0221] The database node 2200 provided by the embodiment can be used to perform the method for processing a service request provided by the embodiment described above, so as to achieve the same effect as the above method. Figure 20
[0222] It should be understood that the database node 2200 can correspond to the database node 600 shown in the figure. The functions of the receiving unit 2201 and the sending unit 2203 can be implemented by the processor 610 and the communication interface 620 in the database node 600 shown in the figure; the function of the processing unit 2202 can be implemented by the processor 610 in the database node 600 shown in the figure. Figure 6 Figure 6 Figure 6 The processor 610 in the illustrated database node 600 implements.
[0223] In the case of an integrated unit, the database node 2200 can include a processing module, a storage module, and a communication module.
[0224] The processing module can be configured to control and manage the actions of the database node 2200, for example, to support the database node 2200 to perform the steps performed by the receiving unit 2201, the processing unit 2202, and the sending unit 2203 described above. The storage module can be configured to support the database node 2200 to store program codes and data, etc. The communication module can be configured to support the database node 2200 to communicate with other devices.
[0225] The processing module can be a processor or a controller, which can implement or execute various exemplary logical blocks, modules, and circuits described in combination with the disclosure of the present application. The processor can also be a combination of computing functions, such as a combination of one or more microprocessors, a combination of a digital signal processing (DSP) and a microprocessor, etc. The storage module can be a memory. The communication module can be a device for interacting with other electronic devices, such as a radio frequency circuit, a Bluetooth chip, and / or a Wi-Fi chip, etc.
[0226] In one embodiment, when the processing module is a processor and the storage module is a memory, the database node 2200 involved in the embodiment can be a device with the structure shown in the embodiment. Figure 6
[0227] The embodiment of the present application also provides a computer readable storage medium, which stores a computer program, and when the computer program is run on a computer, the computer is caused to execute the method provided by the embodiment shown in the present application. Figure 9-10
[0228] The embodiment of the present application also provides a computer readable storage medium, which stores a computer program, and when the computer program is run on a computer, the computer is caused to execute the method provided by the embodiment shown in the present application. Figure 20
[0229] The embodiment of the present application also provides a computer program product, which includes a computer program, and when the computer program is run on a computer, the computer is caused to execute the method provided by the embodiment shown in the present application. Figure 9-10
[0230] The embodiment of the present application also provides a computer program product, which includes a computer program, and when the computer program is run on a computer, the computer is caused to execute the method provided by the embodiment shown in the present application. Figure 20 The method provided by the embodiment shown.
[0231] In the embodiments of the present application, "at least one" refers to one or more, and "multiple" refers to two or more. The association relationship of the associated objects is described by "and / or", which means that there can be three kinds of relationships, for example, A and / or B can represent the cases of A alone, A and B together, and B alone. Wherein A and B can be singular or plural. The character " / " generally represents an "or" relationship between the front and rear associated objects. "At least one of the following" and the like means any combination of these items, including any combination of single or multiple items. For example, at least one of a, b and c can represent: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, and c can be single or multiple.
[0232] Those of ordinary skill in the art can realize that the units and algorithm steps described in the embodiments disclosed herein can be realized by electronic hardware, computer software and a combination of electronic hardware and computer software. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0233] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described system, device and unit can refer to the corresponding processes in the foregoing method embodiments, which will not be described here.
[0234] In several embodiments provided by the present application, any function realized in the form of a software function unit and sold or used as an independent product can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the parts that make contributions to the prior art or parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.
[0235] The above description is only the specific implementation of the present application. Any person skilled in the art can easily think of changes or replacements within the technical range disclosed in the present application, which should be covered in the protection range of the present application. The protection range of the present application should be subject to the protection range of the claims.
Claims
1. A method of processing a service request, characterized by, The application comprises: an application server acquires a first service request of a service process; when the first service request is a query request, the first service request is sent to a first database node, so that the first database node obtains data corresponding to the first service request; the first service request is copied, and the copied first service request is sent to a second database node, so that the second database node obtains data corresponding to the first service request from a disk, and the data corresponding to the first service request is saved into a cache corresponding to the second database node; wherein the first database node and the second database node are nodes in a database disaster recovery network; data corresponding to the first service request sent by the first database node is received.
2. The method of claim 1, wherein, After the data corresponding to the first service request sent by the first database node is received, the application further comprises: if a database fails and a master-standby switchover is performed, after the application server acquires a second service request of the service process, when the second service request is a query request, the second service request is sent to the second database node, so that the second database node obtains data corresponding to the second service request from a cache corresponding to the second database; data corresponding to the second service request sent by the second database node is received.
3. The method of claim 1, wherein, Before the application server acquires the first service request of the service process, the application further comprises: a service process in the application server sends a connection acquisition request to a logical connection pool in the application server; the logical connection pool acquires a connection of the first database node from a first database node connection pool in the application server; the logical connection pool returns the connection of the first database node to the service process.
4. The method of claim 3, wherein, The application server acquires the first service request of the service process comprises: a logical connection pool in the application server acquires the first service request of the service process, and the first service request comprises the connection of the first database node; the first service request is sent to the first database node, comprising: the logical connection pool sends the first service request to the first database node according to the connection of the first database node.
5. The method of claim 3, wherein, The first service request is copied, and the copied first service request is sent to a second database node, comprising: the logical connection pool copies the first service request, and sends the copied first service request to the second database node.
6. The method of claim 2, wherein, Before the application server acquires the second service request of the service process, the application further comprises: if a database fails and a master-standby switchover is performed, a service process in the application server sends a connection acquisition request to a logical connection pool in the application server; the logical connection pool acquires a connection of the second database node from a second database node connection pool in the application server; the logical connection pool returns the connection of the second database node to the service process.
7. The method of claim 6, wherein, The application server acquires the second service request of the service process comprises: The logical connection pool in the application server acquires a second service request of the service process, and the second service request includes a connection of the second database node; The sending of the second service request to the second database node includes: The logical connection pool sends the second service request to the second database node according to the connection of the second database node.
8. The method according to any one of claims 3 to 7, characterized in that, Before the service process in the application server sends a connection acquisition request to the logical connection pool in the application server, the method further includes: The application server acquires a virtual IP address of a database instance transmitted by the service process, and starts a monitor thread; The monitor thread queries a node list of the database disaster recovery network from the database instance according to the virtual IP address; The monitor thread receives the node list of the database disaster recovery network transmitted by the database instance; wherein the node list includes an IP address of a first database node, a role of the first database node in the database disaster recovery network, an IP address of a second database node, and a role of the second database node in the database disaster recovery network; The monitor thread creates a logical connection pool according to the virtual IP address of the database instance, and creates a first database node connection pool and a second database node connection pool according to the node list; wherein the first database node connection pool includes a connection of the first database node, the second database node connection pool includes a connection of the second database node, the connection of the first database node is created according to the IP address of the first database node, and the connection of the second database node is created according to the IP address of the second database node.
9. The method of claim 8, wherein, After the querying of the node list of the database disaster recovery network from the database instance, the method further includes: If the IP address of a node in the database disaster recovery network and / or the role of the node in the database disaster recovery network changes, the monitor thread receives an updated node list of the database disaster recovery network transmitted by the database instance; The first database node connection pool and / or the second database node connection pool are updated according to the updated node list.
10. A method of processing a service request, characterized by, The method includes: A database node receives a first service request transmitted by an application server; wherein the database node is a standby node in a database disaster recovery network, and the first service request is a query request; When the database node does not exist in the cache corresponding to the database node, the data corresponding to the first service request is acquired from a disk; The data corresponding to the first service request is saved to the cache corresponding to the database node; If the database fails, the database node is switched to a master node in the database disaster recovery network, and after receiving a second service request transmitted by the application server, the data corresponding to the second service request is obtained from the cache corresponding to the database node; The data corresponding to the second service request is transmitted to the application server.
11. An application server, characterized by The method includes: One or more processors; Memory; A plurality of application programs; and one or more computer programs, wherein the one or more computer programs are stored in the memory, the one or more computer programs comprising instructions, which when executed by the application server, cause the application server to perform the method of any of claims 1-9.
12. A database node, characterized by comprising: one or more processors; a memory; a plurality of application programs; and one or more computer programs, wherein the one or more computer programs are stored in the memory, the one or more computer programs comprising instructions, which when executed by the database node, cause the database node to perform the method of claim 10.
13. A computer-readable storage medium, characterized in that, The computer readable storage medium has stored therein a computer program, which, when run on a computer, causes the computer to perform the method of any of claims 1-9.
14. A computer-readable storage medium, characterized in that, The computer readable storage medium has stored therein a computer program, which, when run on a computer, causes the computer to perform the method of claim 10.