Application read-write separation management and control method and gateway

By analyzing request information and parameters in the gateway, dynamically creating read-write separation rules, the problem of database synchronization delay and read-write separation in the existing technology is solved, and flexible switching and dynamic configuration of application read-write separation is realized, which satisfies micro Multi-application requirements under the service architecture.

CN119202039AActive Publication Date: 2024-12-27FUJIAN TQ ONLINE INTERACTIVE INC
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411030231.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-30
Publication Date
2024-12-27
Estimated Expiration
2044-07-30

AI Technical Summary

Technical Problem

The existing technology cannot dynamically switch database master-slave nodes, resulting in database synchronization delay errors in high concurrency and high throughput scenarios, and it is impossible to distinguish read and write separation methods based on different requests, which cannot meet the flexible needs of multiple applications under the microservice architecture. .

Method used

By receiving external requests in the gateway, analyzing application identification information and request parameters, dynamically creating preferred read and write separation rules, and sending them to the application, allowing the application to process requests according to the rules, realizing flexible switching and dynamic configuration of application read and write separation.

Benefits of technology

It avoids the problem of delayed error reporting in database synchronization, meets the needs of different business scenarios, and realizes dynamic configuration of read and write separation operations based on each external request, reduces the application's dependence on default rules, and improves the flexibility and adaptability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119202039A_ABST
    Figure CN119202039A_ABST
Patent Text Reader

Abstract

The invention discloses an application read-write separation management and control method and a gateway, an external request is received, key information contained in the external request is analyzed, and the key information comprises application identification information; creating an optimal read-write separation rule corresponding to each piece of application identification information contained in the key information in combination with a request parameter of the external request, and sending the key information to an application corresponding to each piece of application identification information; and receiving a rule acquisition request sent by the application after acquiring the key information, and sending the optimal read-write separation rule to the corresponding application according to the rule acquisition request, so that the application processes an external request according to the received optimal read-write separation rule when the external request arrives. According to the method, read-write separation operation which should be performed by different applications is dynamically configured according to each external request, the situation that the applications only process the requests according to default read-write separation rules of the applications is avoided, and it is guaranteed that the error reporting problem of database synchronization delay does not occur.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data read-write separation, and in particular to a management and control method and a gateway for application read-write separation. Background Art

[0002] At present, in order to support high concurrency and high throughput scenarios, some systems use read-write separation at the database level to improve the overall efficiency of the database; the so-called read-write separation means that write operations enter the master database and read operations enter the slave database. In order to achieve this read-write separation, applications generally use annotation tags to hard limit it in the code. For example, in some DAO layer codes, SQL query statements are forced to point to the slave database, while write statements point to the master database.

[0003] However, this approach has some disadvantages: First, it is impossible to dynamically and freely control the switching of master and slave nodes. For example, if some business scenarios have high requirements and there is a certain delay in master-slave synchronization, it will cause the direct query of the slave database to fail. At this time, it is necessary to point to the master database, but the old solution cannot switch dynamically; second, in the microservice architecture, since there are multiple microservice application instances and multiple microservices will call each other, if the read-write separation method is hard-coded in the code, it will not be able to distinguish according to different external requests. For example, for the same microservice node, for the request from application A, because it has higher requirements, all nodes will go to the master database uniformly. For the request from application B, its requirements are not high and it can support the slave database. The old method cannot support this link requirement of microservices well. Summary of the invention

[0004] The technical problem to be solved by the present invention is to provide a management and control method and gateway for application read-write separation, which can flexibly switch the master and slave objects of the application for read-write separation, and ensure that there will be no error reporting problem due to database synchronization delay.

[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is:

[0006] A method for controlling application read-write separation is used for controlling the read-write separation of all applications attached to a gateway, and includes the following steps:

[0007] S1. Receive an external request and parse key information contained in the external request, where the key information includes application identification information;

[0008] S2. Creating a preferred read-write separation rule corresponding to each of the application identification information included in the key information in combination with the request parameters of the external request, and sending the key information to the application corresponding to each of the application identification information;

[0009] S3. Receive and send the preferred read-write separation rule to the corresponding application according to the rule acquisition request issued by the application after acquiring the key information, so that the application processes the external request according to the received preferred read-write separation rule when the external request arrives.

[0010] In order to solve the above technical problems, the present invention adopts another technical solution:

[0011] A management and control gateway for application read-write separation includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:

[0012] S1. Receive an external request and parse key information contained in the external request, where the key information includes application identification information;

[0013] S2. Creating a preferred read-write separation rule corresponding to each of the application identification information included in the key information in combination with the request parameters of the external request, and sending the key information to the application corresponding to each of the application identification information;

[0014] S3. Receive and send the preferred read-write separation rule to the corresponding application according to the rule acquisition request issued by the application after acquiring the key information, so that the application processes the external request according to the received preferred read-write separation rule when the external request arrives.

[0015] The beneficial effects of the present invention are: providing a management and control method and gateway for application read-write separation, which can, after receiving an external request, create a corresponding preferred read-write separation rule based on the request parameters of the external request and the application identification information pointed to by the external request, and then the application dynamically obtains the preferred read-write separation rule corresponding to itself. After the external request arrives, the application processes the external request according to the preferred read-write separation rule. In this way, it is possible to dynamically configure the read-write separation operations that should be performed by different applications according to each external request, avoid the application only processing the request according to the default read-write separation rule that it has, ensure that there will be no error reporting problem of database synchronization delay, and meet the needs of different business scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 A schematic diagram of the steps of a method for controlling application read-write separation of the present invention;

[0017] Figure 2 This is a system block diagram of a management and control gateway that applies read-write separation in the present invention.

[0018] Description of labels:

[0019] 1. A management and control gateway for application read-write separation; 2. Memory; 3. Processor. DETAILED DESCRIPTION

[0020] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.

[0021] Please refer to Figure 1 A method for controlling application read-write separation is used for controlling the read-write separation of all applications attached to a gateway, and includes the following steps:

[0022] S1. Receive an external request and parse key information contained in the external request, where the key information includes application identification information;

[0023] S2. Creating a preferred read-write separation rule corresponding to each of the application identification information included in the key information in combination with the request parameters of the external request, and sending the key information to the application corresponding to each of the application identification information;

[0024] S3. Receive and send the preferred read-write separation rule to the corresponding application according to the rule acquisition request issued by the application after acquiring the key information, so that the application processes the external request according to the received preferred read-write separation rule when the external request arrives.

[0025] From the above description, it can be seen that the beneficial effect of the present invention is that after receiving an external request, it is possible to create a corresponding preferred read-write separation rule based on the request parameters of the external request and the application identification information pointed to by the external request, and then the application dynamically obtains the preferred read-write separation rule corresponding to itself. After the external request arrives, the application processes the external request according to the preferred read-write separation rule. In this way, it is possible to dynamically configure the read-write separation operations that should be performed by different applications according to each external request, thereby avoiding the situation where the application only processes the request according to its own default read-write separation rule, ensuring that there will be no error report problem due to database synchronization delay, and meeting the needs of different business scenarios.

[0026] Furthermore, it also includes:

[0027] S0, creating a read-write separation SDK package and a preset read-write separation rule as a loading object of the read-write separation SDK package, and configuring the read-write separation SDK package to all the applications;

[0028] The step S3 further comprises:

[0029] If the preferred read-write separation rule sent to the corresponding application is none or no requirement, the application is controlled to process the external request according to the preset read-write separation rule.

[0030] From the above description, it can be seen that by integrating the read-write separation SDK package into each application, the read-write separation rules of the local application can be freely configured, that is, the preset read-write separation rules are adopted. In the subsequent processing of external requests, if there are no special requirements for the read and write operations of a certain application, the application can be processed according to the preset read-write separation rules, thereby reducing the processing burden of creating preferred read-write separation rules; at the same time, it also realizes the customization of the read-write separation rules of the local cache of the application. In some scenarios where it is determined that there is no need to adopt new read-write rules for a long time, the application can directly perform read-write separation by itself to reduce the processing pressure of the management and control gateway.

[0031] Furthermore, it also includes:

[0032] S4. When the preset read-write separation rule is updated, the application is notified to reload the new preset read-write separation rule.

[0033] From the above description, it can be seen that under the premise of establishing preset read-write separation rules, the real-time update function is introduced to strengthen the centralized management of the local read-write separation function of different applications, making the read-write separation function of the application more flexible and adaptable.

[0034] Furthermore, combining the request parameters of the external request to create a preferred read-write separation rule corresponding to each application identification information included in the key information includes:

[0035] An interface object is obtained from the request parameter, and a preferred read-write separation rule corresponding to each application identification information is created according to the importance level of the interface object.

[0036] From the above description, it can be seen that when setting the preferred read-write separation rules, you can start with the interface object and control the read-write separation action of the corresponding application according to the importance level of the interface object. The more important the interface is, the more it is necessary to ensure that there will be no error problems caused by database synchronization delays.

[0037] Furthermore, sending the key information to the application corresponding to each application identification information specifically includes:

[0038] The key information contained in the request header of the external request is sent to all the applications in a request header transparent transmission manner.

[0039] From the above description, it can be seen that the request header transparent transmission method ensures that key information can be efficiently and stably transmitted to each application.

[0040] Please refer to a management and control gateway for application read-write separation, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:

[0041] S1. Receive an external request and parse key information contained in the external request, where the key information includes application identification information;

[0042] S2. Creating a preferred read-write separation rule corresponding to each of the application identification information included in the key information in combination with the request parameters of the external request, and sending the key information to the application corresponding to each of the application identification information;

[0043] S3. Receive and send the preferred read-write separation rule to the corresponding application according to the rule acquisition request issued by the application after acquiring the key information, so that the application processes the external request according to the received preferred read-write separation rule when the external request arrives.

[0044] From the above description, it can be seen that the beneficial effect of the present invention is that after receiving an external request, it is possible to create a corresponding preferred read-write separation rule based on the request parameters of the external request and the application identification information pointed to by the external request, and then the application dynamically obtains the preferred read-write separation rule corresponding to itself. After the external request arrives, the application processes the external request according to the preferred read-write separation rule. In this way, it is possible to dynamically configure the read-write separation operations that should be performed by different applications according to each external request, thereby avoiding the situation where the application only processes the request according to its own default read-write separation rule, ensuring that there will be no error report problem due to database synchronization delay, and meeting the needs of different business scenarios.

[0045] Furthermore, it also includes:

[0046] S0, creating a read-write separation SDK package and a preset read-write separation rule as a loading object of the read-write separation SDK package, and configuring the read-write separation SDK package to all the applications;

[0047] The step S3 further comprises:

[0048] If the preferred read-write separation rule sent to the corresponding application is none or no requirement, the application is controlled to process the external request according to the preset read-write separation rule.

[0049] From the above description, it can be seen that by integrating the read-write separation SDK package into each application, the read-write separation rules of the local application can be freely configured, that is, the preset read-write separation rules are adopted. In the subsequent processing of external requests, if there are no special requirements for the read and write operations of a certain application, the application can be processed according to the preset read-write separation rules, thereby reducing the processing burden of creating preferred read-write separation rules; at the same time, it also realizes the customization of the read-write separation rules of the local cache of the application. In some scenarios where it is determined that there is no need to adopt new read-write rules for a long time, the application can directly perform read-write separation by itself to reduce the processing pressure of the management and control gateway.

[0050] Furthermore, it also includes:

[0051] S4. When the preset read-write separation rule is updated, the application is notified to reload the new preset read-write separation rule.

[0052] From the above description, it can be seen that under the premise of establishing preset read-write separation rules, the real-time update function is introduced to strengthen the centralized management of the local read-write separation function of different applications, making the read-write separation function of the application more flexible and adaptable.

[0053] Furthermore, combining the request parameters of the external request to create a preferred read-write separation rule corresponding to each application identification information included in the key information includes:

[0054] An interface object is obtained from the request parameter, and a preferred read-write separation rule corresponding to each application identification information is created according to the importance level of the interface object.

[0055] From the above description, it can be seen that when setting the preferred read-write separation rules, you can start with the interface object and control the read-write separation action of the corresponding application according to the importance level of the interface object. The more important the interface is, the more it is necessary to ensure that there will be no error problems caused by database synchronization delays.

[0056] Furthermore, sending the key information to the application corresponding to each application identification information specifically includes:

[0057] The key information contained in the request header of the external request is sent to all the applications in a request header transparent transmission manner.

[0058] From the above description, it can be seen that the request header transparent transmission method ensures that key information can be efficiently and stably transmitted to each application.

[0059] Please refer to Figure 1 , Embodiment 1 of the present invention is:

[0060] A method for controlling application read-write separation is used for controlling the read-write separation of all applications attached to a gateway, and includes the following steps:

[0061] S0. Create a read-write separation SDK package and a preset read-write separation rule as a loading object of the read-write separation SDK package, and configure the read-write separation SDK package to all applications;

[0062] In this embodiment, an independent read-write separation SDK package is provided, which includes the following main functions: providing an existing commonly used read-write separation annotation class, as well as aspects and other functions. The management and control gateway or system on the microservice architecture will create a preset read-write separation rule; each application needs to integrate this read-write separation SDK package. When the application is successfully started, the SDK package will automatically load the preset read-write separation rules from the rule management system to the local cache. After each application in the microservice integrates the SDK package, it is necessary to add read-write separation annotation tags to its key places, indicating that the SQL statements in this place can perform read-write separation operations. Not only that, for places where annotation tags have been added, the information that has been configured and registered can be collected and displayed in the background, including application name, class name, method name, etc., and this information can be configured in the background.

[0063] S1. Receive an external request and parse key information contained in the external request, where the key information includes application identification information;

[0064] In this embodiment, the key information generally includes application ID, etc., and the application ID can be used as application identification information.

[0065] S2. Create a preferred read-write separation rule corresponding to each application identification information included in the key information in combination with the request parameters of the external request, and send the key information to the application corresponding to each application identification information;

[0066] In this embodiment, when the client request reaches the microservice gateway, the outermost request header needs to be sent to all applications in a transparent manner, and the key information is included in the request header.

[0067] In this embodiment, the interface object is obtained from the request parameters, and a preferred read-write separation rule corresponding to each application identification information is created according to the importance level of the interface object. For example, the route of a certain external request has three nodes A, B, and C; because the interface pointed to by the external request is a key interface and needs to be guaranteed, all subsequent routing nodes of the request are set to go through the main library. The corresponding preferred read-write separation rule contains at least: interface unique identifier, A-main library, B-main library, C-main library; and the other interface is a secondary key interface or a non-important interface, that is, some functions can be downgraded or ignored, and certain errors can be allowed, then the corresponding preferred read-write separation rule contains at least: interface unique identifier, A-main library, B-main library, C-slave library; and similarly.

[0068] S3. Receive and obtain requests based on the rules issued by the application after obtaining key information, and send the preferred read-write separation rules to the corresponding application, so that the application processes the external request according to the received preferred read-write separation rules when the external request arrives. If the preferred read-write separation rule sent to the corresponding application is none or no requirement, the application is controlled to process the external request according to the preset read-write separation rules.

[0069] In the case where there is no need to optimize the read-write separation rules, assuming that there are four applications A, B, C, and D, and the read-write control of the interface within each application is controlled by the application itself, the application is controlled by the preset read-write separation rules.

[0070] S4. When the preset read-write separation rule is updated, the application is notified to reload the new preset read-write separation rule.

[0071] Please refer to Figure 2 , Embodiment 2 of the present invention is:

[0072] A management and control gateway 1 for application read-write separation includes a memory 2, a processor 3, and a computer program stored in the memory 2 and executable on the processor 3. When the processor 3 executes the computer program, a management and control method for application read-write separation in embodiment 1 is implemented.

[0073] In summary, the present invention provides a method and gateway for controlling application read-write separation. After receiving an external request, it can create a corresponding preferred read-write separation rule based on the request parameters of the external request and the application identification information pointed to by the external request, and then the application dynamically obtains the preferred read-write separation rule corresponding to itself. After the external request arrives, the application processes the external request according to the preferred read-write separation rule. In this way, it is possible to dynamically configure the read-write separation operations that should be performed by different applications according to each external request, so as to avoid the situation where the application only processes the request according to its own default read-write separation rule, and ensure that there will be no error report problem due to database synchronization delay. At the same time, a read-write separation SDK toolkit is integrated on each application, and the read-write separation SDK toolkit is used to preset the read-write separation rules in the local cache of each application, so as to facilitate calling under certain conditions to meet the needs of different business scenarios.

[0074] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for controlling application read-write separation, characterized in that: The read-write separation for all applications attached to the gateway management includes the following steps: S1. Receive an external request and parse key information contained in the external request, where the key information includes application identification information; S2. Creating a preferred read-write separation rule corresponding to each of the application identification information included in the key information in combination with the request parameters of the external request, and sending the key information to the application corresponding to each of the application identification information; S3. Receive and send the preferred read-write separation rule to the corresponding application according to the rule acquisition request issued by the application after acquiring the key information, so that the application processes the external request according to the received preferred read-write separation rule when the external request arrives.

2. According to the method for controlling application read-write separation according to claim 1, it is characterized in that: Also includes: S0, creating a read-write separation SDK package and a preset read-write separation rule as a loading object of the read-write separation SDK package, and configuring the read-write separation SDK package to all the applications; The step S3 further comprises: If the preferred read-write separation rule sent to the corresponding application is none or no requirement, the application is controlled to process the external request according to the preset read-write separation rule.

3. According to the method for controlling application read-write separation according to claim 2, it is characterized in that: Also includes: S4. When the preset read-write separation rule is updated, the application is notified to reload the new preset read-write separation rule.

4. According to the method for controlling application read-write separation according to claim 1, it is characterized in that: The creating a preferred read-write separation rule corresponding to each application identification information included in the key information in combination with the request parameters of the external request includes: An interface object is obtained from the request parameter, and a preferred read-write separation rule corresponding to each application identification information is created according to the importance level of the interface object.

5. The method for controlling application read-write separation according to claim 1, characterized in that: The sending of the key information to the application corresponding to each of the application identification information specifically includes: The key information contained in the request header of the external request is sent to all the applications in a request header transparent transmission manner.

6. A management and control gateway for application read-write separation, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the following steps are implemented: S1. Receive an external request and parse key information contained in the external request, where the key information includes application identification information; S2. Creating a preferred read-write separation rule corresponding to each of the application identification information included in the key information in combination with the request parameters of the external request, and sending the key information to the application corresponding to each of the application identification information; S3. Receive and send the preferred read-write separation rule to the corresponding application according to the rule acquisition request issued by the application after acquiring the key information, so that the application processes the external request according to the received preferred read-write separation rule when the external request arrives.

7. A management and control gateway for application read-write separation according to claim 6, characterized in that: Also includes: S0, creating a read-write separation SDK package and a preset read-write separation rule as a loading object of the read-write separation SDK package, and configuring the read-write separation SDK package to all the applications; The step S3 further comprises: If the preferred read-write separation rule sent to the corresponding application is none or no requirement, the application is controlled to process the external request according to the preset read-write separation rule.

8. A management and control gateway for application read-write separation according to claim 7, characterized in that: Also includes: S4. When the preset read-write separation rule is updated, the application is notified to reload the new preset read-write separation rule.

9. A management and control gateway for application read-write separation according to claim 6, characterized in that: The creating a preferred read-write separation rule corresponding to each application identification information included in the key information in combination with the request parameters of the external request includes: An interface object is obtained from the request parameter, and a preferred read-write separation rule corresponding to each application identification information is created according to the importance level of the interface object.

10. A management and control gateway for application read-write separation according to claim 6, characterized in that: The sending of the key information to the application corresponding to each of the application identification information specifically includes: The key information contained in the request header of the external request is sent to all the applications in a request header transparent transmission manner.

Citation Information

Patent Citations

  • Data read-write method and system

    CN111339131A

  • Database operation method and system based on SaaS system

    CN112905708A

  • System and method for dynamic read-write separation of database

    CN117251500A

  • System and method for automatically configuring application control rules

    EP2819346A1