A database middleware switching method and device

By building a dynamic adaptation layer to automatically identify and switch database middleware, the problems of low switching efficiency and system instability in the existing technology are solved, an efficient and stable middleware switching process is achieved, and the flexibility and reliability of the system are improved.

CN119576662BActive Publication Date: 2025-10-14GREE ELECTRIC APPLIANCE INC OF ZHUHAI +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411916125.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2025-10-14
Estimated Expiration
2044-12-24

AI Technical Summary

Technical Problem

In the prior art, database middleware switching is inefficient and may cause system instability. In particular, there is a risk of complex configuration and data loss when switching between different service providers.

Method used

Build a dynamic adaptation layer to obtain the database operation requests and middleware configuration information of the target proxy service, automatically identify and switch to the target middleware, and monitor performance data in real time to handle potential problems, including fault recovery mechanisms and asynchronous processing mechanisms.

Benefits of technology

It realizes automatic identification and adaptation of database middleware of different service providers, improves service deployment efficiency, enhances system flexibility and reliability, and timely discovers and handles performance bottlenecks or security risks, thereby improving system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119576662B_ABST
    Figure CN119576662B_ABST
Patent Text Reader

Abstract

The application provides a database middleware switching method and device, the method comprises the following steps: constructing a dynamic adaptation layer, and using the dynamic adaptation layer to perform the following steps: obtaining a database operation request of a target proxy service and configuration information of a plurality of database middlewares; determining a target middleware from the plurality of database middlewares according to a request type and attribute information corresponding to the database operation request; obtaining target connection information corresponding to the target middleware from a plurality of connection information; switching to the target middleware according to the target connection information to realize connection between the target proxy service and the target middleware; monitoring performance data corresponding to the dynamic adaptation layer in real time during the execution of the above steps by the dynamic adaptation layer; analyzing the performance of the dynamic adaptation layer according to the performance data to determine a performance problem existing in the dynamic adaptation layer; determining a corresponding processing strategy according to the performance problem, and processing the performance problem according to the processing strategy.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of Internet, and particularly relates to a database middleware switching method and device. BACKGROUND

[0002] With the rapid development of Internet of Things technology, MQTT (Message Queuing Telemetry Transport) as a lightweight and efficient publish / subscribe message protocol is widely used in various Internet of Things scenarios. In these scenarios, MQTT broker service as the core component of message transmission needs to interact with database middleware to store and retrieve message data.

[0003] In the application, due to the complexity of Internet of Things systems, database middleware may be provided by different service providers, and there may be differences in technical standards and implementation methods between these service providers. When the MQTT broker service needs to switch between database middleware of different service providers, it often faces risks such as complex configuration, service interruption, and data loss. Traditional solutions usually rely on manual configuration modification or service redeployment.

[0004] However, this way of manually modifying the configuration or redeploying the service is not only inefficient, but also may cause system instability. SUMMARY

[0005] The present application provides a database middleware switching method and device to solve the problem that the existing technology through manual configuration modification or service redeployment is not only inefficient, but also may cause system instability.

[0006] In a first aspect, the present application provides a database middleware switching method, comprising:

[0007] building a dynamic adaptation layer, and using the dynamic adaptation layer to perform the following steps:

[0008] obtaining a database operation request of a target broker service and configuration information of a plurality of database middleware, wherein the configuration information includes attribute information of each of the database middleware and connection information for connecting each of the database middleware;

[0009] determining a target middleware from the plurality of database middleware according to a request type corresponding to the database operation request and the attribute information;

[0010] obtaining target connection information corresponding to the target middleware from the plurality of connection information;

[0011] switching to the target middleware according to the target connection information, so as to realize connection between the target agent service and the target middleware;

[0012] monitoring performance data corresponding to the dynamic adaptation layer in real time during execution of the above steps by the dynamic adaptation layer, wherein the performance data is used to represent data affecting performance of the dynamic adaptation layer;

[0013] analyzing performance of the dynamic adaptation layer according to the performance data, and determining a performance problem existing in the dynamic adaptation layer;

[0014] determining a corresponding processing strategy according to the performance problem, and processing the performance problem according to the processing strategy.

[0015] In one possible implementation, the determining of the target middleware from the plurality of database middlewares according to the request type corresponding to the database operation request and the attribute information comprises:

[0016] determining a target performance according to the request type corresponding to the database operation request, wherein the target performance refers to performance required for processing a request of the request type;

[0017] determining a priority of each database middleware according to the target performance and the attribute information of each database middleware;

[0018] determining the database middleware with the highest priority as the target middleware.

[0019] In one possible implementation, the method further comprises:

[0020] in a case where there are at least two database middlewares with the highest priority, determining each database middleware with the highest priority as a candidate middleware;

[0021] determining a load condition corresponding to each candidate middleware;

[0022] determining the candidate middleware with the lowest load as the target middleware.

[0023] In one possible implementation, the method further comprises:

[0024] monitoring a fault of the target middleware during connection between the target agent service and the target middleware;

[0025] in a case where the target middleware has a fault, triggering a fault recovery mechanism, wherein the fault recovery mechanism comprises reconnection of the target middleware or switching to a standby database middleware.

[0026] In a possible implementation, the method further includes, before the step of obtaining the database operation request of the target proxy service and the configuration information of the plurality of database middlewares:

[0027] building a dynamic adaptation layer, and using the dynamic adaptation layer to perform the step of obtaining the database operation request of the target proxy service and the configuration information of the plurality of database middlewares, wherein the configuration information includes attribute information of each of the database middlewares and connection information for connecting each of the database middlewares, according to a request type corresponding to the database operation request and the attribute information, determining a target middleware from the plurality of database middlewares, obtaining target connection information corresponding to the target middleware from the plurality of connection information, and switching to the target middleware according to the target connection information, so as to realize connection between the target proxy service and the target middleware.

[0028] In a possible implementation, the method further includes:

[0029] creating a connection pool in the dynamic adaptation layer, and using the connection pool to manage connection between the proxy service and the database middleware.

[0030] In a possible implementation, the method further includes:

[0031] determining operation content corresponding to the database operation request, wherein the operation content is used to represent an operation requested to be performed by the database operation request;

[0032] determining whether the database operation request is a time-consuming request according to the operation content;

[0033] in a case where the database operation request is a time-consuming request, using the dynamic adaptation layer to perform asynchronous processing on the database operation request.

[0034] In a possible implementation, the method further includes:

[0035] obtaining a query frequency of each data of a database by the target proxy service and a change frequency of each data;

[0036] determining, as target data, data corresponding to a query frequency greater than a first threshold value and a change frequency less than a second threshold value;

[0037] using the dynamic adaptation layer to cache the target data, so as to use the cached target data to respond in a case where the target proxy service queries the target data next time.

[0038] In a second aspect, the present application provides a database middleware switching device, comprising:

[0039] a constructing module, configured to construct a dynamic adaptation layer, and perform the following steps by using the dynamic adaptation layer:

[0040] a request receiving module, configured to acquire a database operation request of a target proxy service and configuration information of a plurality of database middlewares, wherein the configuration information comprises attribute information of each of the database middlewares and connection information for connecting each of the database middlewares;

[0041] a middleware determining module, configured to determine a target middleware from the plurality of database middlewares according to a request type corresponding to the database operation request and the attribute information;

[0042] an information acquiring module, configured to acquire target connection information corresponding to the target middleware from the plurality of connection information;

[0043] a middleware switching module, configured to switch to the target middleware according to the target connection information, so as to realize connection between the target proxy service and the target middleware;

[0044] a monitoring module, configured to monitor performance data corresponding to the dynamic adaptation layer in real time during execution of the above steps by the dynamic adaptation layer, wherein the performance data is used to represent data affecting performance of the dynamic adaptation layer;

[0045] an analyzing module, configured to analyze the performance of the dynamic adaptation layer according to the performance data, and determine a performance problem existing in the dynamic adaptation layer;

[0046] a processing module, configured to determine a corresponding processing strategy according to the performance problem, and process the performance problem according to the processing strategy.

[0047] In one possible implementation, the middleware determining module is specifically configured to:

[0048] determine a target performance according to a request type corresponding to the database operation request, wherein the target performance refers to a performance required for processing a request of the request type;

[0049] determine a priority of each of the database middlewares according to the target performance and the attribute information of each of the database middlewares;

[0050] determine the database middleware corresponding to the highest priority as the target middleware.

[0051] In one possible implementation, the middleware determining module is further configured to:

[0052] in a case where there are at least two database middlewares corresponding to the highest priority, take each of the database middlewares corresponding to the highest priority as a candidate middleware.

[0053] determining a load condition corresponding to each candidate middleware;

[0054] determining the candidate middleware corresponding to the lowest load as the target middleware.

[0055] In one possible implementation, the apparatus further comprises a fault monitoring module configured to:

[0056] monitoring the target middleware for faults during the process of connecting the target agent service to the target middleware;

[0057] triggering a fault recovery mechanism in the case of a fault in the target middleware, wherein the fault recovery mechanism comprises reconnecting the target middleware or switching to a backup database middleware.

[0058] In one possible implementation, the apparatus further comprises a construction module configured to:

[0059] constructing a dynamic adaptation layer and using the dynamic adaptation layer to perform the steps of obtaining a database operation request of a target agent service and configuration information of a plurality of database middlewares, wherein the configuration information comprises attribute information of each of the database middlewares and connection information for connecting each of the database middlewares, determining a target middleware from the plurality of database middlewares according to a request type corresponding to the database operation request and the attribute information, obtaining target connection information corresponding to the target middleware from the plurality of connection information, and switching to the target middleware according to the target connection information to implement the connection of the target agent service to the target middleware.

[0060] In one possible implementation, the apparatus further comprises a creation module configured to:

[0061] creating a connection pool in the dynamic adaptation layer and using the connection pool to manage the connection between the agent service and the database middleware.

[0062] In one possible implementation, the apparatus further comprises an asynchronous processing module configured to:

[0063] determining an operation content corresponding to the database operation request, wherein the operation content is used to represent an operation requested to be performed by the database operation request;

[0064] determining whether the database operation request is a time-consuming request according to the operation content;

[0065] performing asynchronous processing on the database operation request using the dynamic adaptation layer in the case of the database operation request being a time-consuming request.

[0066] In a possible implementation, the apparatus further includes a caching module configured to:

[0067] acquire a query frequency of each data in the database by the target proxy service and a change frequency of each data;

[0068] determine the data corresponding to the query frequency greater than a first threshold value and the change frequency less than a second threshold value as the target data;

[0069] cache the target data by the dynamic adaptation layer, so as to respond by the cached target data in the case that the target proxy service queries the target data next time.

[0070] In a third aspect, the present application provides an apparatus, comprising: a processor and a memory, the processor is configured to execute a database middleware switching program stored in the memory, so as to implement the database middleware switching method in any one of the first aspect.

[0071] In a fourth aspect, the present application provides a storage medium, the storage medium stores one or more programs, the one or more programs can be executed by one or more processors to implement the database middleware switching method in any one of the first aspect.

[0072] Compared with the prior art, the technical scheme provided by the embodiments of the present application has the following advantages: the method provided by the embodiments of the present application first constructs a dynamic adaptation layer, and uses the dynamic adaptation layer to perform the following steps: obtaining a database operation request of a target proxy service and configuration information of a plurality of database middleware, wherein the configuration information includes attribute information of each of the database middleware and connection information for connecting each of the database middleware, then determining a target middleware in the plurality of database middleware according to a request type corresponding to the database operation request and the attribute information, further obtaining target connection information corresponding to the target middleware in the plurality of connection information, and finally switching to the target middleware according to the target connection information to realize the connection between the target proxy service and the target middleware. Moreover, during the execution of the above steps by the dynamic adaptation layer, the performance data corresponding to the dynamic adaptation layer is monitored in real time, wherein the performance data is used to represent data affecting the performance of the dynamic adaptation layer; the performance of the dynamic adaptation layer is analyzed according to the performance data to determine a performance problem existing in the dynamic adaptation layer; a corresponding processing strategy is determined according to the performance problem, and the performance problem is processed according to the processing strategy. Through the present scheme, automatic identification and adaptation of different service provider database middleware can be realized, and then automatic switching of the database middleware can be realized, so that the efficiency of service deployment can be improved, and the flexibility and reliability of the system can be improved. Moreover, by monitoring the dynamic adaptation layer in real time, potential performance bottlenecks or security risks can be found and processed in time, so that the stability of the system can be improved. BRIEF DESCRIPTION OF DRAWINGS

[0073] The accompanying drawings, which are incorporated into and form a part of the specification, illustrate preferred embodiments of the present application and, together with the description, serve to explain the principles of the application.

[0074] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced as follows, and obviously, other drawings can also be obtained by those skilled in the art without any creative labor under the premise of the drawings.

[0075] One or more embodiments are exemplarily illustrated by pictures in the corresponding drawings, and these exemplary illustrations do not constitute a limitation on the embodiments, and elements with the same reference numerals in the drawings represent similar elements, unless otherwise specified, and the drawings in the drawings do not constitute a proportional limitation.

[0076] Figure 1 An embodiment flowchart of a database middleware switching method provided by the embodiments of the present application is shown in the following table:

[0077] Figure 2 An embodiment flow chart for providing a database middleware switching method according to the application is shown in FIG. 1. As shown in the figure, the method comprises the following steps:

[0078] Figure 3 An embodiment flow chart for providing another database middleware switching method according to the application is shown in FIG. 2. As shown in the figure, the method comprises the following steps:

[0079] Figure 4 An embodiment flow chart for providing another database middleware switching method according to the application is shown in FIG. 3. As shown in the figure, the method comprises the following steps:

[0080] Figure 5 An embodiment block diagram for providing a database middleware switching device according to the application is shown in FIG. 4. As shown in the figure, the device comprises the following modules:

[0081] Figure 6 An embodiment block diagram for providing a database middleware switching device according to the application is shown in FIG. 4. As shown in the figure, the device comprises the following modules: DETAILED DESCRIPTION

[0082] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described below in connection with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.

[0083] The following disclosure provides many different embodiments, or examples, for implementing different structures of the present application. For the purpose of simplicity, the description of a particular example will not necessarily be repeated in the description of each example. Of course, they are merely examples and are not intended to limit the present application. In addition, reference numerals and / or letters can be repeated in different examples. Such repetition is for the purpose of simplicity and clarity, and does not indicate a relationship between the various embodiments and / or arrangements being discussed.

[0084] To solve the technical problem that the way of manually modifying the configuration or redeploying the service in the prior art is not only inefficient, but also can cause the system to be unstable, the present application provides a database middleware switching method, which can realize automatic identification and adaptation of different service provider database middleware, and then realize automatic switching of the database middleware, so as to improve the efficiency of service deployment and improve the flexibility and reliability of the system.

[0085] Figure 1 An embodiment flow chart for providing a database middleware switching method according to the application is shown in FIG. 1. As shown in the figure, the method comprises the following steps: Figure 1 ​

[0086] Step 101, constructing a dynamic adaptation layer, through which a database operation request of a target proxy service and configuration information of a plurality of database middleware are obtained, wherein the configuration information includes attribute information of each of the database middleware and connection information for connecting each of the database middleware.

[0087] Step 102, determining a target middleware from the plurality of database middleware according to a request type corresponding to the database operation request and the attribute information.

[0088] Step 103, obtaining target connection information corresponding to the target middleware from the plurality of connection information.

[0089] Step 104, switching to the target middleware according to the target connection information to realize connection between the target proxy service and the target middleware.

[0090] For ease of understanding, steps 101 to 104 are uniformly described as follows:

[0091] Request type, used to represent the type of database operation request, for example, query request, insertion request, update request, deletion request, batch operation request, etc.

[0092] Configuration information, including attribute information of each database middleware and connection information for connecting each database middleware. Wherein, the attribute information, for example, performance information such as read performance, write performance, load condition, etc.; the connection information, for example, connection address, port number, authentication information, database name and other configuration parameters for connecting the database middleware.

[0093] In application, a programming language such as Java or C++ can be used to construct the dynamic adaptation layer, and intelligent switching logic is integrated in the dynamic adaptation layer, so that the dynamic adaptation layer can be used as a bridge between the MQTT (Message Queuing Telemetry Transport) proxy service and the database middleware.

[0094] Specifically, the dynamic adaptation layer is responsible for receiving the database operation request of the MQTT proxy service, then through the intelligent switching logic, the appropriate target middleware is matched from the plurality of database middleware according to the request type and the attribute information in the current configuration information, finally, the target connection information is used to switch to the target middleware, thereby realizing the interaction between the target proxy service and the target middleware.

[0095] In actual application, during the switching process, transaction management can be used to ensure the consistency and integrity of data, that is, all operations are either successful or failed; or the double-write mechanism can be used to ensure the consistency of data, that is, data is written to two databases simultaneously during the switching process, and read-write separation is adopted during the switching process to ensure the consistency of data.

[0096] Step 105: During the execution of the above steps in the dynamic adaptation layer, the performance data corresponding to the dynamic adaptation layer is monitored in real time, wherein the performance data is used to represent the data affecting the performance of the dynamic adaptation layer.

[0097] Step 106: The performance of the dynamic adaptation layer is analyzed according to the performance data, and the performance problem existing in the dynamic adaptation layer is determined.

[0098] Step 107: The corresponding processing strategy is determined according to the performance problem, and the performance problem is processed according to the processing strategy.

[0099] For the convenience of understanding, the steps 105 to 107 are uniformly described as follows:

[0100] The performance data is used to represent the data affecting the performance of the dynamic adaptation layer, for example, the response time: the response time of each database operation; the throughput: the number of processed requests per unit time; the connection pool state: the number of active connections, the number of idle connections, the number of waiting connections, etc.; the cache hit rate: the number of cache hits and the total access times; the SQL injection attack: detection of malicious SQL injection attempts; unauthorized access: record of unauthorized access attempts; exception log: record of all exceptions and error information; and the like.

[0101] In the embodiment of the application, the performance of the dynamic adaptation layer can be analyzed according to the performance data, so as to determine the possible performance problem of the dynamic adaptation layer, and then the performance problem is processed according to the corresponding processing strategy.

[0102] For example, for the response time: if the response time of a certain operation is significantly higher than that of other operations, there may be a performance bottleneck; for the throughput: if the throughput of the system suddenly decreases, it may be due to insufficient resources or code problems; for the connection pool state: if the number of active connections in the connection pool is long-term high, it may be due to connection leakage or improper setting of the connection pool size; for the SQL injection attack: through log analysis, it is found whether there is a malicious SQL injection attempt; for unauthorized access: record all unauthorized access attempts and analyze the source and frequency; for the exception log: periodically check the exception log to find potential security vulnerabilities.

[0103] Through the above scheme, the adaptive layer can be monitored in real time, and potential performance bottlenecks or security risks can be found and handled in time, thereby improving the stability of the system.

[0104] In another embodiment of the present application, the method can further include the step of creating a connection pool in the dynamic adaptive layer, and using the connection pool to manage the connection between the proxy service and the database middleware. In this scheme, the dynamic adaptive layer can use the connection pool to manage the database connection. Since the connection pool can reuse existing connections, it can avoid frequent connection and disconnection operations, and reduce the overhead of creating and destroying connections.

[0105] In addition, in another embodiment of the present application, the method can further include the steps of: monitoring the target middleware for faults during the connection of the target proxy service and the target middleware; and triggering a fault recovery mechanism in the case of a fault in the target middleware, wherein the fault recovery mechanism includes reconnecting the target middleware or switching to a backup database middleware.

[0106] The fault monitoring can include connection timeout monitoring, SQL execution monitoring, heartbeat detection, and network connection monitoring. Specifically, the connection timeout monitoring process is as follows: when attempting to connect to the database, a timeout period is set. If the connection is not successful within the specified time, it is considered a connection failure, i.e., a fault. The SQL execution monitoring process is as follows: when executing a SQL statement, an exception is captured. If the SQL execution fails, it is considered that the database is unavailable, i.e., a fault. The heartbeat monitoring process is as follows: a heartbeat request is sent periodically to check the health status of the database. If multiple heartbeat requests fail, it is considered that the database is unavailable, i.e., a fault. The network connection monitoring process is as follows: the network connection is checked to ensure that the database middleware can be accessed. If the network connection is abnormal, it is considered that a fault has occurred.

[0107] In applications, the fault recovery mechanism can further include logging the fault and alerting the fault. In this way, the user can handle the fault in time.

[0108] Through the above scheme, when the target middleware fails, the fault recovery process can be performed in time, thereby ensuring the stability of the system.

[0109] The technical scheme provided by the embodiment of the application first constructs a dynamic adaptation layer, and uses the dynamic adaptation layer to perform the following steps: obtaining a database operation request of a target proxy service and configuration information of a plurality of database middleware, wherein the configuration information comprises attribute information of each of the database middleware and connection information for connecting each of the database middleware, then determining a target middleware from the plurality of database middleware according to a request type corresponding to the database operation request and the attribute information, further obtaining target connection information corresponding to the target middleware from the plurality of connection information, and finally switching to the target middleware according to the target connection information to realize connection between the target proxy service and the target middleware. Moreover, during execution of the above steps by the dynamic adaptation layer, performance data corresponding to the dynamic adaptation layer is monitored in real time, wherein the performance data is used to represent data affecting performance of the dynamic adaptation layer, the performance of the dynamic adaptation layer is analyzed according to the performance data to determine a performance problem existing in the dynamic adaptation layer, a corresponding processing strategy is determined according to the performance problem, and the performance problem is processed according to the processing strategy. Through the scheme, automatic identification and adaptation of database middleware of different service providers can be realized, and then automatic switching of the database middleware can be realized, so that the efficiency of service deployment can be improved, and the flexibility and reliability of the system can be improved. Moreover, by monitoring the dynamic adaptation layer in real time, potential performance bottlenecks or security risks can be found and processed in time, so that the stability of the system can be improved.

[0110] Figure 2 An embodiment flowchart for determining a target middleware from a plurality of database middleware according to a request type corresponding to a database operation request and attribute information is provided by the embodiment of the application. Figure 2 The flowchart shown in Figure 1 The flowchart shown in

[0111] Step 201: determining a target performance according to a request type corresponding to the database operation request, wherein the target performance refers to a performance required for processing a request of the request type;

[0112] Step 202: determining a priority of each database middleware according to the target performance and attribute information of each database middleware;

[0113] Step 203: determining a database middleware corresponding to the highest priority as the target middleware.

[0114] For the convenience of understanding, the steps 201 to 203 are uniformly described as follows:

[0115] In an application, different types of requests have different performance requirements, for example, for a read request, the performance focused on is read performance, for a write request, the performance focused on is write performance, and for a request containing both read and write operations, the performance and stability are generally considered comprehensively.

[0116] Based on this, in the embodiments of the present application, first, the target performance focused on is determined according to the request type corresponding to the database operation request, and then, for each database middleware, the database middleware with the best target performance or the highest performance matching degree is determined as the target middleware according to the description of the target performance in the attribute information (i.e., the priority of the database middleware in all database middlewares based on the target performance, wherein the higher the priority, the better the target performance or the higher the performance matching degree).

[0117] For example, for a read request, a middleware with better read performance can be selected preferentially; for a write request, a middleware with better write performance and stability can be selected preferentially; and for a request containing both read and write operations, a middleware with a high comprehensive score of performance and stability can be selected preferentially.

[0118] In addition, in an application, there can be a case where there are multiple database middlewares with the highest priority, and therefore, in another embodiment of the present application, the method can further include the following steps: in the case where there are at least two database middlewares with the highest priority, each database middleware with the highest priority is taken as a candidate middleware, the load condition corresponding to each candidate middleware is determined, and the candidate middleware with the lowest load is determined as the target middleware.

[0119] The load can include CPU usage, memory usage, network bandwidth, number of requests, response time, and the like.

[0120] As described above, in the scheme, in the case where there are multiple database middlewares with the highest priority, the database middleware with the lowest load among them can be determined as the target middleware. In this way, the load balancing of the system can be ensured, and the stability of the system can be improved.

[0121] Through the flow shown in Figure 2 , the database middleware with the best target performance can be determined as the target middleware from multiple database middlewares according to the target performance focused on by the database operation request, so that efficient processing of the database operation request can be ensured.

[0122] Figure 3 An embodiment flowchart of another database middleware switching method provided by the embodiments of the present application. Figure 3 The flow shown in Figure 1Based on the process shown, the following steps are included:

[0123] Step 301: Determine the operation content corresponding to the database operation request, wherein the operation content is used to represent the operation requested to be performed by the database operation request;

[0124] Step 302: Determine whether the database operation request is a time-consuming request based on the operation content;

[0125] Step 303: When the database operation request is a time-consuming request, use the dynamic adaptation layer to asynchronously process the database operation request.

[0126] For ease of understanding, steps 301 to 303 are described in a unified manner below:

[0127] Operation content is used to represent the operation requested by the database operation request. Some database operation requests in the application are more complex and take a long time, so they are considered time-consuming requests.

[0128] In actual applications, there are the following time-consuming requests: 1. Complex SQL queries, especially SQL queries involving large amounts of data or join operations on multiple tables; 2. Calling external APIs or services, which usually require network communication and may have large delays; 3. File operations: reading and writing large files or processing a large number of files; 4. Computation-intensive operations: such as image processing, data analysis, and other operations that require a lot of computing; 5. I / O operations: such as disk I / O operations and network I / O operations.

[0129] In the embodiment of the present application, first, time-consuming requests are identified based on the operation content. Then, the dynamic adaptation layer can design the time-consuming requests into asynchronous tasks through asynchronous programming models (for example, callback functions, coroutines, etc.), and submit the asynchronous tasks to the task queue or event loop for task scheduling. These asynchronous tasks are then processed by dedicated threads or processes. After the asynchronous task is completed, the result is returned to the main thread through a callback function or other mechanism, and the main thread can continue to process other tasks.

[0130] pass Figure 3 As shown in the process, for time-consuming database operation requests, an asynchronous processing mechanism can be used to perform asynchronous processing, thereby avoiding blocking the main thread and improving the overall efficiency of the system.

[0131] Figure 4 A flowchart of another embodiment of a database middleware switching method provided in an embodiment of the present application. Figure 4 The process shown in Figure 1 Based on the process shown, the following steps are included:

[0132] Step 401, obtaining a query frequency of each data in a database by the target proxy service and a change frequency of each data;

[0133] Step 402, determining the data as target data if the corresponding query frequency is greater than a first threshold value and the corresponding change frequency is less than a second threshold value;

[0134] Step 403, caching the target data by the dynamic adaptation layer, so as to respond by the cached target data if the target proxy service queries the target data next time.

[0135] For the convenience of understanding, the steps 401 to 403 are uniformly described as follows:

[0136] The first threshold value is used to determine whether the data is frequently queried, that is, the data is considered to be frequently queried if the query frequency of the data is greater than the first threshold value.

[0137] The second threshold value is used to determine whether the data is frequently changed, that is, the data is considered to be not frequently changed if the change frequency of the data is less than the second threshold value.

[0138] As can be seen from the above description, in the embodiment of the application, for the target data frequently queried and not frequently changed, the dynamic adaptation layer can cache the target data, so that the target data can be responded by the cached target data when the target proxy service queries the target data subsequently, thereby the number of database access times can be reduced.

[0139] Figure 5 An embodiment block diagram of a database middleware switching device provided by the embodiment of the application is shown in the figure. Figure 5 As shown in the figure, the device comprises:

[0140] The construction module 51 is configured to construct a dynamic adaptation layer and execute the following steps by using the dynamic adaptation layer.

[0141] The request receiving module 52 is configured to obtain a database operation request of a target proxy service and configuration information of a plurality of database middlewares, wherein the configuration information comprises attribute information of each of the database middlewares and connection information for connecting each of the database middlewares.

[0142] The middleware determining module 53 is configured to determine a target middleware from the plurality of database middlewares according to a request type corresponding to the database operation request and the attribute information.

[0143] The information obtaining module 54 is configured to obtain target connection information corresponding to the target middleware from the plurality of connection information.

[0144] The middleware switching module 55 is configured to switch to the target middleware according to the target connection information, so as to realize connection between the target proxy service and the target middleware.

[0145] The monitoring module 56 is configured to monitor performance data corresponding to the dynamic adaptation layer in real time during execution of the above steps by the dynamic adaptation layer, wherein the performance data is used to represent data affecting performance of the dynamic adaptation layer.

[0146] The analysis module 57 is configured to analyze performance of the dynamic adaptation layer according to the performance data, and determine a performance problem existing in the dynamic adaptation layer.

[0147] The processing module 58 is configured to determine a corresponding processing strategy according to the performance problem, and process the performance problem according to the processing strategy.

[0148] In a possible implementation, the middleware determining module is specifically configured to:

[0149] determine a target performance according to a request type corresponding to the database operation request, wherein the target performance refers to performance required for processing a request of the request type;

[0150] determine a priority of each database middleware according to the target performance and attribute information of each database middleware;

[0151] determine the database middleware corresponding to the highest priority as the target middleware.

[0152] In a possible implementation, the middleware determining module is further configured to:

[0153] in a case where there are at least two database middlewares corresponding to the highest priority, determine each database middleware corresponding to the highest priority as a candidate middleware;

[0154] determine a load condition corresponding to each candidate middleware;

[0155] determine the candidate middleware corresponding to the lowest load as the target middleware.

[0156] In a possible implementation, the apparatus further includes a fault monitoring module configured to:

[0157] monitor the target middleware for faults during connection between the target proxy service and the target middleware;

[0158] in a case where the target middleware has a fault, trigger a fault recovery mechanism, wherein the fault recovery mechanism includes reconnecting the target middleware or switching to a backup database middleware.

[0159] In a possible implementation, the apparatus further includes a constructing module configured to:

[0160] construct a dynamic adaptation layer, and perform a database operation request for obtaining a target proxy service and configuration information of a plurality of database middlewares by using the dynamic adaptation layer, wherein the configuration information includes attribute information of each of the database middlewares and connection information for connecting each of the database middlewares, a target middleware is determined from the plurality of database middlewares according to a request type corresponding to the database operation request and the attribute information, target connection information corresponding to the target middleware is obtained from the plurality of connection information, and the target middleware is switched to according to the target connection information, so as to implement connection between the target proxy service and the target middleware.

[0161] In a possible implementation, the apparatus further includes a creating module configured to:

[0162] create a connection pool in the dynamic adaptation layer, and manage connection between the proxy service and the database middleware by using the connection pool.

[0163] In a possible implementation, the apparatus further includes an asynchronous processing module configured to:

[0164] determine operation content corresponding to the database operation request, wherein the operation content is used to represent an operation requested to be performed by the database operation request;

[0165] determine whether the database operation request is a time-consuming request according to the operation content;

[0166] perform asynchronous processing on the database operation request by using the dynamic adaptation layer in a case where the database operation request is the time-consuming request.

[0167] In a possible implementation, the apparatus further includes a caching module configured to:

[0168] obtain query frequency of each data of a database of the target proxy service and change frequency of each data;

[0169] determine data corresponding to the query frequency greater than a first threshold value and the change frequency less than a second threshold value as target data;

[0170] cache the target data by using the dynamic adaptation layer, so as to respond by using the cached target data in a case where the target proxy service queries the target data next time.

[0171] In a possible implementation, the apparatus further includes a monitoring module configured to:

[0172] monitoring performance data corresponding to the dynamic adaptation layer in real time, wherein the performance data is used to represent data affecting performance of the dynamic adaptation layer;

[0173] analyzing performance of the dynamic adaptation layer according to the performance data, and determining a performance problem existing in the dynamic adaptation layer;

[0174] determining a corresponding processing strategy according to the performance problem, and processing the performance problem according to the processing strategy.

[0175] As shown in Figure 6 The embodiment of the present application provides a device, which comprises a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112 and the memory 113 complete mutual communication through the communication bus 114,

[0176] The memory 113 is used to store a computer program.

[0177] In an embodiment of the present application, the processor 111 is used to execute the program stored in the memory 113, so as to realize the database middleware switching method provided by any one of the preceding method embodiments, which comprises the following steps:

[0178] constructing a dynamic adaptation layer, and using the dynamic adaptation layer to execute the following steps:

[0179] obtaining a database operation request of a target proxy service and configuration information of a plurality of database middlewares, wherein the configuration information comprises attribute information of each of the database middlewares and connection information used to connect each of the database middlewares;

[0180] determining a target middleware from the plurality of database middlewares according to a request type corresponding to the database operation request and the attribute information;

[0181] obtaining target connection information corresponding to the target middleware from the plurality of connection information;

[0182] switching to the target middleware according to the target connection information, so as to realize connection between the target proxy service and the target middleware;

[0183] monitoring performance data corresponding to the dynamic adaptation layer in real time during execution of the above steps by the dynamic adaptation layer, wherein the performance data is used to represent data affecting performance of the dynamic adaptation layer;

[0184] analyzing performance of the dynamic adaptation layer according to the performance data, and determining a performance problem existing in the dynamic adaptation layer;

[0185] According to the performance problem, a corresponding processing strategy is determined, and the performance problem is processed according to the processing strategy.

[0186] The embodiment of the application further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to realize steps of the database middleware switching method provided by any one of the foregoing method embodiments.

[0187] The apparatus embodiments described above are merely illustrative, wherein the units described as separate components can or can not be physically separate, and the components displayed as units can or can not be physical units, i.e., can be located in one place, or can be distributed on multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment scheme.

[0188] Through the description of the foregoing embodiments, those skilled in the art can clearly understand that each embodiment can be realized by means of software plus a general hardware platform, and of course can also be realized by hardware. Based on such understanding, the above technical solutions can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, and the like, and includes a plurality of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in each embodiment or some parts of the embodiments.

[0189] It should be understood that the terms used herein are for the purpose of describing particular example embodiments only and are not intended to be limiting. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. The terms "comprises", "comprising", "includes", "including" and the like are inclusive and therefore specify the presence of stated features, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, steps, operations, elements, components, and / or groups thereof. The method steps, processes, and operations described herein are not to be construed as necessarily requiring their performance in the particular order in which they are described, unless specifically indicated as such. It is also to be understood that additional or alternative steps can be employed.

[0190] The foregoing detailed description of the application has been presented for purposes of illustration and description. Various modifications and changes can be made to these embodiments without departing from the spirit and scope of the application. It is intended that the scope of the application should not be limited by the particular representative embodiments described above.

Claims

1. A database middleware switching method, characterized in that: The method comprises: Construct a dynamic adaptation layer and use the dynamic adaptation layer to perform the following steps: Obtaining a database operation request of a target proxy service and configuration information of a plurality of database middlewares, wherein the configuration information includes attribute information of each of the database middlewares and connection information for connecting to each of the database middlewares; determining a target middleware among a plurality of database middlewares according to a request type corresponding to the database operation request and the attribute information; Acquire target connection information corresponding to the target middleware from the plurality of connection information; Switching to the target middleware according to the target connection information to achieve connection between the target proxy service and the target middleware; During the process of the dynamic adaptation layer executing the above steps, real-time monitoring of performance data corresponding to the dynamic adaptation layer, wherein the performance data is used to represent data affecting the performance of the dynamic adaptation layer; Analyzing the performance of the dynamic adaptation layer according to the performance data to determine performance problems existing in the dynamic adaptation layer; A corresponding processing strategy is determined according to the performance problem, and the performance problem is processed according to the processing strategy.

2. The method according to claim 1, characterized in that The step of determining a target middleware among a plurality of database middlewares according to the request type corresponding to the database operation request and the attribute information includes: determining a target performance according to a request type corresponding to the database operation request, wherein the target performance refers to the performance required for processing a request of the request type; Determining the priority of each database middleware according to the target performance and attribute information of each database middleware; The database middleware with the highest corresponding priority is determined as the target middleware.

3. The method according to claim 2, characterized in that The method further comprises: In the case that there are at least two database middlewares with the highest corresponding priority, each database middleware with the highest corresponding priority is used as a candidate middleware; Determine the load corresponding to each candidate middleware; The candidate middleware with the lowest corresponding load is determined as the target middleware.

4. The method according to claim 1, wherein The method further comprises: During the process of connecting the target proxy service with the target middleware, performing fault monitoring on the target middleware; In the event that the target middleware fails, a failure recovery mechanism is triggered, wherein the failure recovery mechanism includes reconnecting to the target middleware, or switching to a standby database middleware.

5. The method according to claim 1, wherein The method further comprises: A connection pool is created in the dynamic adaptation layer, and the connection between the proxy service and the database middleware is managed by using the connection pool.

6. The method according to claim 1, characterized in that The method further comprises: Determining an operation content corresponding to the database operation request, wherein the operation content is used to represent the operation requested to be performed by the database operation request; determining whether the database operation request is a time-consuming request according to the operation content; In the case that the database operation request is a time-consuming request, the database operation request is asynchronously processed by using the dynamic adaptation layer.

7. The method according to claim 1, characterized in that The method further comprises: Obtain the query frequency of each data in the database and the change frequency of each data by the target proxy service; Determine data whose corresponding query frequency is greater than a first threshold and whose corresponding change frequency is less than a second threshold as target data; The target data is cached by using the dynamic adaptation layer, so that when the target proxy service queries the target data next time, the cached target data is used for response.

8. A database middleware switching device, characterized in that: The device comprises: A construction module is used to construct a dynamic adaptation layer and use the dynamic adaptation layer to perform the following steps: A request receiving module, configured to obtain a database operation request of a target proxy service and configuration information of a plurality of database middlewares, wherein the configuration information includes attribute information of each of the database middlewares and connection information for connecting to each of the database middlewares; a middleware determination module, configured to determine a target middleware among a plurality of database middlewares according to a request type corresponding to the database operation request and the attribute information; An information acquisition module, configured to acquire target connection information corresponding to the target middleware from the plurality of connection information; a middleware switching module, configured to switch to the target middleware according to the target connection information, so as to realize the connection between the target proxy service and the target middleware; A monitoring module, configured to monitor performance data corresponding to the dynamic adaptation layer in real time during the execution of the above steps by the dynamic adaptation layer, wherein the performance data is used to represent data affecting the performance of the dynamic adaptation layer; an analysis module, configured to analyze the performance of the dynamic adaptation layer according to the performance data and determine performance problems existing in the dynamic adaptation layer; The processing module is used to determine a corresponding processing strategy according to the performance problem, and process the performance problem according to the processing strategy.

Citation Information

Patent Citations

  • Multi-protocol self-adaption-based equipment intelligent perception Internet of Things gateway management platform

    CN112738237A

  • Database switching method and device based on data intermediate layer

    CN118820262A