Database connection control method and device, computer device and readable storage medium

By obtaining service identification information and configuration information, the upper limit of the number of connections for each instance is determined and managed, which solves the service anomaly problem caused by improper management of the number of database connections, realizes flexible connection control, and improves the reliability of database connections.

CN114238408BActive Publication Date: 2026-04-07CHINA PING AN PROPERTY INSURANCE CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-20
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

In existing technologies, the number of database connections is not effectively managed, resulting in the number of connections exceeding the limit, causing service abnormalities, and it is impossible to set the connection limit for each service instance individually.

Method used

By obtaining the service identifier information of the target service, and based on the pre-defined correspondence between the configuration information and the service identifier information, the upper limit of the number of connections for each instance is determined and sent to the target service to manage the number of database connections.

Benefits of technology

It enables flexible control over the upper limit of service and instance connections, preventing the uncontrolled expansion of database connection numbers and improving the reliability of database connections.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114238408B_ABST
    Figure CN114238408B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of databases, and provides a database connection control method and device, computer equipment and a readable storage medium, the method comprising the following steps: obtaining service identification information of a target service; obtaining first configuration information of the target service according to the service identification information, wherein the first configuration information comprises a first connection upper limit and a connection distribution strategy; determining a second connection upper limit corresponding to each instance in the target service according to the number of instances in the target service and the first connection upper limit based on the connection distribution strategy; and sending the second connection upper limit corresponding to each instance in the target service to the target service, wherein the second connection upper limit is used for indicating the connection number of the instance to the database, the flexibility of setting the connection upper limit of the service and the instance is improved, and the disorderly expansion of the database connection number is prevented. In addition, the application also relates to the blockchain technology, and the configuration information can be stored in the blockchain.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of database, and particularly relates to a database connection control method and device, computer equipment and a readable storage medium. BACKGROUND

[0002] With the development of mobile Internet, more and more users join the mobile Internet tide. With the increase of users, more and more user data is generated, and the data is generally stored in a database. Commonly used relational database management systems include MYSQL, ORACLE, etc. The more the database applications, such as user data query or user data writing, the more the database connections consumed. If not controlled, the number of connections will exceed the upper limit of the database, thereby causing service abnormalities. Although the database connection pool technology can manage the database connections of the service, there are still technical problems that when multiple services jointly connect to the same database, the upper limit of the connection number of each service cannot be limited, and when multiple instances of the same service are deployed, the upper limit of the connection number of a certain instance cannot be set individually. SUMMARY

[0003] The main purpose of the present application is to provide a database connection control method and device, computer equipment and a readable storage medium, which aims to improve the flexibility of setting the upper limit of the connection number of the service and the instance, thereby preventing the disordered expansion of the database connection number.

[0004] In a first aspect, the present application provides a database connection control method, which is used for a database connection configuration platform, and the method comprises the following steps:

[0005] obtaining service identification information of a target service;

[0006] obtaining first configuration information of the target service according to the service identification information based on a preset corresponding relationship between the configuration information and the service identification information, wherein the first configuration information comprises a first upper limit of the connection number and a connection number allocation strategy;

[0007] determining a second upper limit of the connection number corresponding to each instance in the target service according to the number of instances in the target service and the first upper limit of the connection number based on the connection number allocation strategy;

[0008] sending the second upper limit of the connection number corresponding to each instance in the target service to the target service, wherein the second upper limit of the connection number is used to indicate the connection number of the instance connecting to the database.

[0009] In a second aspect, the present application further provides a database connection control device, which comprises:

[0010] a service identification information obtaining module, configured to obtain service identification information of a target service;

[0011] The first configuration information acquisition module is used to acquire the first configuration information of the target service based on the preset correspondence between configuration information and service identification information, according to the service identification information, wherein the first configuration information includes a first connection limit and a connection allocation strategy;

[0012] The second connection limit determination module is used to determine the second connection limit for each instance in the target service based on the connection allocation strategy, the number of instances in the target service, and the first connection limit.

[0013] The second connection limit sending module is used to send the second connection limit corresponding to each instance in the target service to the target service. The second connection limit is used to indicate the maximum number of connections that the instance can make to the database.

[0014] Thirdly, this application also provides a computer device, which includes a memory and a processor;

[0015] The memory is used to store computer programs;

[0016] The processor is configured to execute the computer program and, in executing the computer program, implement the database connection control method as described above.

[0017] Fourthly, this application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the database connection control method described above.

[0018] This application provides a database connection control method, apparatus, computer device, and readable storage medium. The method includes: obtaining service identifier information of a target service; based on a preset correspondence between configuration information and service identifier information, obtaining first configuration information of the target service according to the service identifier information, wherein the first configuration information includes a first connection limit and a connection allocation strategy; based on the connection allocation strategy, determining a second connection limit corresponding to each instance in the target service according to the number of instances in the target service and the first connection limit; sending the second connection limit corresponding to each instance in the target service to the target service, wherein the second connection limit is used to indicate the number of connections the instance makes to the database, thereby improving the flexibility of setting the connection limit of services and instances, preventing the disorderly expansion of the number of database connections, and improving the reliability of database connections. Attached Figure Description

[0019] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 A flowchart illustrating a database connection control method provided in an embodiment of this application;

[0021] Figure 2 This application provides an illustration of an application scenario for a database connection control method according to an embodiment of this application.

[0022] Figure 3 This is a schematic diagram of database connection control interaction according to an embodiment of this application;

[0023] Figure 4 A schematic block diagram of a database connection control device provided in an embodiment of this application;

[0024] Figure 5 This is a schematic block diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0025] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0026] The flowchart shown in the attached diagram is for illustrative purposes only and does not necessarily include all content and operations / steps, nor does it necessarily have to be performed in the order described. For example, some operations / steps can be broken down, combined, or partially merged, so the actual execution order may change depending on the actual situation.

[0027] This application provides a database connection control method, apparatus, computer device, and readable storage medium. The database connection control method can be applied to terminal devices, such as mobile phones, tablets, laptops, and desktop computers. It can also be applied to servers, which can be standalone servers or cloud servers providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.

[0028] The following detailed description of some embodiments of this application is provided in conjunction with the accompanying drawings. Unless otherwise specified, the following embodiments and features can be combined with each other.

[0029] Please see Figure 1 , Figure 1 This is a flowchart illustrating a database connection control method provided in an embodiment of this application. The database connection control method can be used on terminal devices or servers.

[0030] Terminal devices may include at least one of the following: mobile phones, tablets, laptops, and desktop computers; servers may be standalone servers or cloud servers that provide cloud computing services.

[0031] Please see Figure 2 , Figure 2 This is an application scenario diagram of a database connection control method provided in an embodiment of this application.

[0032] like Figure 2 As shown, the service identification information can be obtained by the server from the terminal device. The second connection limit is obtained according to the database connection control method and then sent to the terminal device. It is understood that there is a connection relationship between the terminal device and the target service. The second connection limit can be stored in the server or the terminal device, which is not limited here.

[0033] like Figure 1 As shown, the database connection control method includes steps S101 to S104.

[0034] Step S101: Obtain the service identifier information of the target service.

[0035] For example, service identification information may include service address information and service name. It is understood that service address information may include the service IP address.

[0036] Optionally, such as Figure 3 As shown, when the target service starts, it can upload its corresponding service identification information to the database connection configuration platform.

[0037] In some embodiments, the target service may include multiple instances; for example, a corresponding number of database connection pool proxies may be introduced into the multiple instances of the target service.

[0038] In some embodiments, in response to the startup of the target service, the database connection pool proxy uploads the service address information, service name, and instance address information of the corresponding instance to the database connection configuration platform.

[0039] Step S102: Based on the preset correspondence between configuration information and service identification information, obtain the first configuration information of the target service according to the service identification information, wherein the first configuration information includes the first connection limit and the connection allocation strategy.

[0040] Optionally, such as Figure 3 As shown, the service identifier information uniquely maps to a set of configuration information in the database connection configuration platform. Based on the service identifier information corresponding to the target service, the first configuration information of the target service is determined in the database connection configuration platform.

[0041] For example, configuration information can be stored in a blockchain. The blockchain referred to in this application is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include an underlying blockchain platform, a platform product service layer, and an application service layer.

[0042] Understandably, when a server needs to use configuration information, it can broadcast to the blockchain to determine the storage node or storage address of the configuration information in order to retrieve the configuration information.

[0043] In some embodiments, the configuration information for each service can be stored on a database connection configuration platform. For example, different IDs can be used to represent different configuration information. For instance, the configuration information for service A corresponds to ID C_A, and the configuration information for service B corresponds to ID C_B. The configuration information C_A and C_B are stored on the database connection configuration platform. It is understood that the database connection configuration platform can obtain the configuration information C_A based on the service identifier information of service A, and the database connection configuration platform can obtain the configuration information C_B based on the service identifier information of service B.

[0044] It is understandable that the maximum number of first connections in the configuration information C_A corresponding to service A may be different from the maximum number of first connections in the configuration information C_B corresponding to service B, which means that service A and service B may have different maximum numbers of database connections.

[0045] Step S103: Based on the connection number allocation strategy, determine the second connection number limit for each instance in the target service according to the number of instances in the target service and the first connection number limit.

[0046] In some embodiments, the database connection configuration platform can determine the number of instances in the target service based on the number of instance address information received.

[0047] For example, connection allocation strategies may include an equal distribution strategy, a weighted strategy, and a preset allocation strategy.

[0048] Optionally, based on the connection allocation strategy, a second connection limit for each instance in the target service is determined according to the number of instances in the target service and the first connection limit, including:

[0049] When the connection allocation strategy is an equal-sharing strategy, the second connection limit for each instance in the target service is determined based on the ratio of the first connection limit to the number of instances in the target service.

[0050] When the connection number allocation strategy is a weighted strategy, the second connection number upper limit corresponding to each instance in the target service is determined based on the first connection number upper limit, the number of weight items in the weighted strategy, and the weight of each item.

[0051] When the connection allocation strategy is the preset allocation strategy, the upper limit of the second connection number corresponding to each instance in the target service is determined according to the preset connection number corresponding to each instance in the target service in the preset allocation strategy.

[0052] Optionally, when the connection allocation strategy is a weighted strategy, a second connection limit is determined for each instance in the target service based on the first connection limit, the number of weights in the weighted strategy, and the weight of each weight, including:

[0053] If the number of instances in the target service is equal to the number of weights in the weighting strategy, the second connection limit for each instance in the target service is determined by multiplying the first connection limit by the weight of each item.

[0054] If the number of instances in the target service is not equal to the number of weight items in the weighting strategy, adjust the number of weight items in the weighting strategy according to the number of instances in the target service to obtain the weight of each item after adjustment. Also, determine the second connection limit corresponding to each instance in the target service based on the product of the first connection limit and the weight of each item.

[0055] In some embodiments, when the connection allocation strategy for service A is an equal-distribution strategy, assuming that the upper limit of the first connection count for service A in its configuration information is N, and the number of instances in service A is n, where both the upper limit of the first connection count N and the number of instances in service A are positive integers, then the upper limit of the second connection count corresponding to each instance in service A is:

[0056] Understandably, when the ratio of the first connection limit to the number of instances in the target service is not an integer, the database connection configuration platform can choose to round up or down to determine the second connection limit for each instance in the target service.

[0057] In some embodiments, when the connection allocation strategy for service B is a weighted strategy, assuming that the upper limit of the first connection count for service B in its configuration information is M, where M is a positive integer, the number of instances in service B is 3, and the weights in the weighted strategy are 1:2:3 (i.e., the number of weight items in the weighted strategy is 3), then the weight corresponding to instance 1 is... The maximum number of second connections corresponding to Instance 1 is The weight corresponding to Example 2 is The upper limit of the second number of connections corresponding to Instance 2 is The weight corresponding to Instance 3 is The maximum number of second connections corresponding to Instance 3 is

[0058] In some embodiments, if the number of instances in service B is 5, and the weights in the weighting strategy are 1:2:3 (meaning the number of instances in the target service is greater than the number of weight items in the weighting strategy), then the number of weight items in the weighting strategy needs to be adjusted according to the number of instances in service B to obtain the adjusted weights for each item. For example, a cyclical weight allocation method can be used to adjust the number of weight items in the weighting strategy, resulting in an adjusted weight of 1:2:3:1:2. In this case, the weight corresponding to instance 1 is... The maximum number of second connections corresponding to Instance 1 is The weight corresponding to Example 2 is The upper limit of the second number of connections corresponding to Instance 2 is The weight corresponding to Instance 3 is The maximum number of second connections corresponding to Instance 3 is The weight corresponding to Instance 4 is The maximum number of second connections corresponding to Instance 4 is The weight corresponding to Instance 5 is The maximum number of second connections corresponding to Instance 5 is

[0059] Similarly, when the number of instances in the target service is less than the number of weight items in the weighting strategy, the number of weight items in the weighting strategy can be adjusted according to the number of instances in the target service to obtain the weight of each item after adjustment, thereby determining the upper limit of the second connection number corresponding to each instance.

[0060] Understandably, when the product of the first connection limit and the weights of each item is not an integer, the database connection configuration platform can choose to round up or down to determine the second connection limit for each instance in the target service.

[0061] In some embodiments, when the connection number allocation strategy of service C is a preset allocation strategy, the preset number of connections for the corresponding instance can be specified according to the instance address information, thereby determining the upper limit of the second connection number for each instance in service C.

[0062] In some embodiments, when the target service is scaled up, that is, when the number of instances in the target service increases and the number of database connection pool proxies also increases accordingly, in response to the change in the number of instances, the second connection limit of each instance in the target service can be automatically balanced based on the connection allocation strategy, such as the equal distribution strategy, the weight strategy, or the preset allocation strategy, in conjunction with the first connection limit in the configuration information.

[0063] Step S104: Send the second connection limit for each instance in the target service to the target service. The second connection limit is used to indicate the number of connections the instance makes to the database.

[0064] Optionally, sending the second connection limit corresponding to each instance in the target service to the target service further includes:

[0065] Send the second connection limit for each instance in the target service to the database connection pool proxy for each instance in the target service. The database connection pool proxy manages the number of database connections for the corresponding instance based on the second connection limit.

[0066] In some embodiments, after the database connection configuration platform determines the upper limit of the second connection number corresponding to each instance in the target service, it can send the upper limit of the second connection number corresponding to each instance to the target service. The target service can then allocate the upper limit of the second connection number corresponding to each instance to the database connection pool agent corresponding to each instance. Alternatively, the upper limit of the second connection number corresponding to each instance can be sent to the database connection pool agent corresponding to each instance, so that the database connection pool agent can manage the number of database connections for the corresponding instance according to the upper limit of the second connection number of the corresponding instance.

[0067] Optionally, the first configuration information may also include database address information;

[0068] The method also includes:

[0069] Send database address information to the target service. The database address information is used to instruct the database connection pool agent corresponding to each instance in the target service to connect to the corresponding database.

[0070] Optionally, the first configuration information may also include login information;

[0071] The method also includes:

[0072] Send login information to the target service so that the database connection pool corresponding to each instance in the target service can proxy the connection to the corresponding database.

[0073] For example, database address information may include the database IP address and port.

[0074] For example, login information may include a login password.

[0075] In some embodiments, such as Figure 3 As shown, after receiving the database address information from the first configuration information sent by the database connection configuration platform, the target service determines the database it needs to connect to. After receiving the login password from the first configuration information sent by the database connection configuration platform, the target service connects to the database based on the login password. It can be understood that when there is a corresponding database connection pool, the target service connecting to the corresponding database is equivalent to the target service connecting to the corresponding database connection pool. The database connection pool can be used to manage the maximum number of connections the target service can make to the corresponding database.

[0076] In some embodiments, the database address information and login information in the first configuration information corresponding to the target service stored in the database connection configuration platform are encrypted information.

[0077] In some embodiments, after the target service receives encrypted database address information and login information, the database connection pool proxy jointly decrypts the encrypted database address information and login information to obtain the real database address information and login information, thereby connecting to the corresponding database. It is understood that the target service cannot know the real database address information and login information before decrypting the encrypted database address information and login information, thus improving database security.

[0078] Optionally, the method further includes:

[0079] Obtain configuration information change detection commands for the target service;

[0080] Based on the configuration information change detection command, obtain the second configuration information of the target service;

[0081] Compare the second configuration information with the first configuration information;

[0082] If the second configuration information is different from the first configuration information, the second configuration information is sent to the target service.

[0083] In some embodiments, if the first connection limit or connection allocation strategy in the configuration information changes, the database connection configuration platform determines the second connection limit corresponding to each instance in the target service based on the changed first connection limit or connection allocation strategy, and sends the changed configuration information to the target service, so that the database connection pool agent can manage the number of connections of the corresponding instance based on the changed second connection limit.

[0084] In some embodiments, if the database address information or login information in the configuration information changes, the database connection configuration platform sends the changed configuration information to the target service, so that the target service can disconnect the database connection and database port connection before the change, and connect to the corresponding database, the corresponding database connection pool and the corresponding port according to the changed database address information or login information.

[0085] In some embodiments, the time interval for the target service to upload configuration information change detection instructions can be set, so that the database connection pool agent periodically uploads configuration information change detection instructions to the database connection configuration platform, thereby facilitating the timely updating of relevant configurations.

[0086] The database connection control method provided in the above embodiments obtains the service identifier information of the target service, and based on the correspondence between the preset configuration information and the service identifier information, obtains the first configuration information of the target service according to the service identifier information. The first configuration information includes a first connection limit and a connection allocation strategy. Based on the connection allocation strategy, and according to the number of instances in the target service and the first connection limit, a second connection limit corresponding to each instance in the target service is determined. The second connection limit corresponding to each instance in the target service is sent to the target service. The second connection limit is used to indicate the number of connections in the instance connection database, improving the flexibility of setting the connection limit of the service and instances, thereby preventing the disorderly expansion of the database connection number.

[0087] Please see Figure 4 , Figure 4 This is a schematic block diagram of a database connection control device provided in an embodiment of this application. The database connection control device can be configured in a server or terminal device to execute the aforementioned database connection control method.

[0088] like Figure 4 As shown, the database connection control device includes: a service identification information acquisition module 110, a first configuration information acquisition module 120, a second connection limit determination module 130, and a second connection limit sending module 140.

[0089] The service identifier information acquisition module 110 is used to acquire the service identifier information of the target service.

[0090] The first configuration information acquisition module 120 is used to acquire the first configuration information of the target service based on the preset correspondence between configuration information and service identification information, according to the service identification information, wherein the first configuration information includes a first connection limit and a connection allocation strategy.

[0091] The second connection limit determination module 130 is used to determine the second connection limit for each instance in the target service based on the connection allocation strategy, the number of instances in the target service, and the first connection limit.

[0092] The second connection limit sending module 140 is used to send the second connection limit corresponding to each instance in the target service to the target service. The second connection limit is used to indicate the maximum number of connections that the instance can make to the database.

[0093] For example, the second connection number upper limit determination module 130 includes: an equal distribution strategy determination submodule, a weight strategy determination submodule, and a preset allocation strategy determination submodule.

[0094] The equal-split strategy determination submodule is used to determine the second connection limit for each instance in the target service based on the ratio of the first connection limit to the number of instances in the target service when the connection allocation strategy is an equal-split strategy.

[0095] The weight strategy determination submodule is used to determine the second connection limit for each instance in the target service based on the first connection limit, the number of weight items in the weight strategy, and the weight of each item when the connection allocation strategy is a weight strategy.

[0096] The preset allocation strategy determination submodule is used to determine the second connection limit for each instance of the target service based on the preset connection number corresponding to each instance in the target service when the connection allocation strategy is a preset allocation strategy.

[0097] For example, the weight strategy determination submodule includes a first weight strategy determination submodule and a second weight strategy determination submodule.

[0098] The first weight strategy determination submodule is used to determine the second connection limit for each instance in the target service if the number of instances in the target service is equal to the number of weight items in the weight strategy, based on the product of the first connection limit and the weight of each item.

[0099] The second weighting strategy determination submodule is used to adjust the number of weighting items in the weighting strategy according to the number of instances in the target service if the number of instances in the target service is not equal to the number of weighting items in the weighting strategy, to obtain the weight of each item after adjustment, and to determine the second connection limit corresponding to each instance in the target service according to the product of the first connection limit and the weight of each item.

[0100] For example, the second connection limit sending module 140 includes a second connection limit submodule.

[0101] The second connection limit submodule is used to send the second connection limit corresponding to each instance in the target service to the database connection pool proxy corresponding to each instance in the target service. The database connection pool proxy manages the number of database connections for the corresponding instance according to the second connection limit.

[0102] For example, the database connection control device further includes a database address information sending module.

[0103] The database address information sending module is used to send the database address information to the target service, wherein the database address information is used to instruct the database connection pool corresponding to each instance in the target service to proxy the connection to the corresponding database.

[0104] For example, the database connection control device further includes a login information sending module.

[0105] The login information sending module is used to send the login information to the target service, so that the database connection pool corresponding to each instance in the target service can be proxyed to enter the corresponding database.

[0106] For example, the database connection control device further includes: a detection instruction acquisition module, a second configuration information acquisition module, a configuration information comparison module, and a second configuration information sending module.

[0107] The detection instruction acquisition module is used to acquire the configuration information change detection instruction of the target service.

[0108] The second configuration information acquisition module is used to acquire the second configuration information of the target service according to the configuration information change detection instruction.

[0109] The configuration information comparison module is used to compare the second configuration information and the first configuration information.

[0110] The second configuration information sending module is used to send the second configuration information to the target service if the second configuration information is different from the first configuration information.

[0111] It should be noted that those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the above-described apparatus and its modules and units can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0112] The method of this application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics devices, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0113] For example, the above-described methods and apparatus can be implemented as a computer program that can run on a computer device.

[0114] Please see Figure 5 , Figure 5 This is a schematic block diagram illustrating the structure of a computer device provided in an embodiment of this application. The computer device may be a server or a terminal device.

[0115] like Figure 5 As shown, the computer device includes a processor, a memory, and a network interface connected via a system bus, wherein the memory may include a storage medium and internal memory.

[0116] The storage medium may store the operating system and computer programs. These computer programs include program instructions that, when executed, cause the processor to perform any database connection control method.

[0117] The processor provides computing and control capabilities, supporting the operation of the entire computer device.

[0118] Internal memory provides an environment for the execution of computer programs stored in the storage medium. When these computer programs are executed by the processor, the processor can perform any database connection control method.

[0119] This network interface is used for network communication, such as sending assigned tasks. Those skilled in the art will understand that... Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0120] It should be understood that a processor can be a Central Processing Unit (CPU), but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other convertible logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among these, a general-purpose processor can be a microprocessor or any conventional processor.

[0121] In one embodiment, the processor is configured to run a computer program stored in memory to perform the following steps:

[0122] Obtain the service identifier information of the target service;

[0123] Based on the preset correspondence between configuration information and service identification information, the first configuration information of the target service is obtained according to the service identification information, wherein the first configuration information includes a first connection limit and a connection allocation strategy;

[0124] Based on the connection number allocation strategy, the second connection number limit for each instance in the target service is determined according to the number of instances in the target service and the first connection number limit.

[0125] Send the second connection limit for each instance in the target service to the target service. The second connection limit is used to indicate the number of connections the instance makes to the database.

[0126] In one embodiment, when the processor implements the method of determining the second connection limit for each instance in the target service based on the connection number allocation strategy, according to the number of instances in the target service and the first connection limit, it is configured to:

[0127] When the connection allocation strategy is an equal-sharing strategy, the second connection limit for each instance in the target service is determined based on the ratio of the first connection limit to the number of instances in the target service.

[0128] When the connection number allocation strategy is a weighted strategy, the second connection number upper limit corresponding to each instance in the target service is determined based on the first connection number upper limit, the number of weight items in the weighted strategy, and the weight of each item.

[0129] When the connection allocation strategy is a preset allocation strategy, the upper limit of the second connection number corresponding to each instance in the target service is determined according to the preset connection number corresponding to each instance in the target service in the preset allocation strategy.

[0130] In one embodiment, when the processor implements the step of determining the second connection limit for each instance in the target service based on the first connection limit and the number of weights and their respective weights in the weight strategy when the connection allocation strategy is a weighted strategy, the processor is configured to:

[0131] If the number of instances in the target service is equal to the number of weight items in the weighting strategy, the second connection limit for each instance in the target service is determined based on the product of the first connection limit and the weight of each item.

[0132] If the number of instances in the target service is not equal to the number of weight items in the weighting strategy, the number of weight items in the weighting strategy is adjusted according to the number of instances in the target service to obtain the weight of each item after adjustment. In addition, the second connection limit corresponding to each instance in the target service is determined according to the product of the first connection limit and the weight of each item.

[0133] In one embodiment, when the processor implements the sending of the second connection limit corresponding to each instance in the target service to the target service, it is configured to:

[0134] The second connection limit for each instance in the target service is sent to the database connection pool proxy for each instance in the target service. The database connection pool proxy manages the number of database connections for the corresponding instance based on the second connection limit.

[0135] In one embodiment, the first configuration information further includes database address information, and the processor, when implementing the database connection control method, is used to implement:

[0136] The database address information is sent to the target service, and the database address information is used to instruct the database connection pool corresponding to each instance in the target service to proxy the connection to the corresponding database.

[0137] In one embodiment, the first configuration information further includes login information, and the processor, when implementing the database connection control method, is used to implement:

[0138] The login information is sent to the target service so that the database connection pool corresponding to each instance in the target service proxies the corresponding database.

[0139] In one embodiment, the processor, when implementing the database connection control method, is configured to:

[0140] Obtain the configuration information change detection command for the target service;

[0141] According to the configuration information change detection command, the second configuration information of the target service is obtained;

[0142] Compare the second configuration information with the first configuration information;

[0143] If the second configuration information is different from the first configuration information, the second configuration information is sent to the target service.

[0144] It should be noted that those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of database connection control described above can be referred to the corresponding process in the aforementioned database connection control method embodiments, and will not be repeated here.

[0145] This application also provides a computer-readable storage medium storing a computer program, which includes program instructions. When the program instructions are executed, the method implemented can be referred to in various embodiments of the database connection control method of this application.

[0146] The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiments, such as the hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, SmartMedia Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the computer device.

[0147] It should be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.

[0148] It should also be understood that the term "and / or" as used in this specification and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes such combinations. It should be noted that, herein, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.

[0149] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments. The above descriptions are merely specific implementations of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A database connection control method, characterized in that, This is for a database connection configuration platform, which stores configuration information for multiple services; Each instance in the service connects to a corresponding database connection pool proxy; the database connection control method includes: Obtain the service identifier information of the target service; Based on the preset correspondence between configuration information and service identification information, the first configuration information of the target service is obtained according to the service identification information, wherein the first configuration information includes a first connection limit and a connection allocation strategy; Based on the connection number allocation strategy, the second connection number limit for each instance in the target service is determined according to the number of instances in the target service and the first connection number limit. Send the second connection limit for each instance in the target service to the target service, whereby the second connection limit is used to indicate the number of connections the instance makes to the database. The instance address information of the instance in the target service is obtained through the database connection pool proxy connected to the target service; The number of instances in the target service is determined based on the number of instance address information received. In response to changes in the number of instances in the target service, a second connection limit is determined for each instance in the target service based on the connection allocation strategy and the first connection limit. The first configuration information also includes encrypted database address information and encrypted login information; The database connection control method further includes: The encrypted database address information and the encrypted login information are sent to the target service, so that all database connection pool proxies in the target service can jointly decrypt the encrypted database address information and the encrypted login information to obtain the real database address information and the real login information. Then, the database connection pool proxies corresponding to each instance in the target service can connect to the corresponding database based on the real database address information and the real login information.

2. The database connection control method according to claim 1, characterized in that, The step of determining the second connection limit for each instance in the target service based on the connection allocation strategy, according to the number of instances in the target service and the first connection limit, includes: When the connection allocation strategy is an equal-sharing strategy, the second connection limit for each instance in the target service is determined based on the ratio of the first connection limit to the number of instances in the target service. When the connection number allocation strategy is a weighted strategy, the second connection number upper limit corresponding to each instance in the target service is determined based on the first connection number upper limit, the number of weight items in the weighted strategy, and the weight of each item. When the connection allocation strategy is a preset allocation strategy, the upper limit of the second connection number corresponding to each instance in the target service is determined according to the preset connection number corresponding to each instance in the target service in the preset allocation strategy.

3. The database connection control method according to claim 2, characterized in that, When the connection allocation strategy is a weighted strategy, the second connection limit for each instance in the target service is determined based on the first connection limit, the number of weights in the weighted strategy, and the weight of each weight, including: If the number of instances in the target service is equal to the number of weight items in the weighting strategy, the second connection limit for each instance in the target service is determined based on the product of the first connection limit and the weight of each item. If the number of instances in the target service is not equal to the number of weight items in the weighting strategy, the number of weight items in the weighting strategy is adjusted according to the number of instances in the target service to obtain the weight of each item after adjustment. In addition, the second connection limit corresponding to each instance in the target service is determined according to the product of the first connection limit and the weight of each item.

4. The database connection control method according to any one of claims 1 to 3, characterized in that, Sending the second connection limit corresponding to each instance in the target service to the target service includes: The second connection limit for each instance in the target service is sent to the database connection pool proxy for each instance in the target service. The database connection pool proxy manages the number of database connections for the corresponding instance based on the second connection limit.

5. The database connection control method according to any one of claims 1 to 3, characterized in that, Also includes: Obtain the configuration information change detection command for the target service; According to the configuration information change detection command, obtain the second configuration information of the target service; Compare the second configuration information with the first configuration information; If the second configuration information is different from the first configuration information, the second configuration information is sent to the target service.

6. A database connection control device, characterized in that, The device includes: The service identifier information acquisition module is used to acquire the service identifier information of the target service; The first configuration information acquisition module is used to acquire the first configuration information of the target service based on the preset correspondence between configuration information and service identification information, according to the service identification information, wherein the first configuration information includes a first connection limit and a connection allocation strategy; The second connection limit determination module is used to determine the second connection limit for each instance in the target service based on the connection allocation strategy, the number of instances in the target service, and the first connection limit. The second connection limit sending module is used to send the second connection limit corresponding to each instance in the target service to the target service. The second connection limit is used to indicate the number of connections the instance makes to the database. The database connection control device is also used for: The instance address information of the instance in the target service is obtained through the database connection pool proxy connected to the target service; The number of instances in the target service is determined based on the number of instance address information received. In response to changes in the number of instances in the target service, a second connection limit is determined for each instance in the target service based on the connection allocation strategy and the first connection limit. The first configuration information also includes encrypted database address information and encrypted login information; The database connection control method further includes: The encrypted database address information and the encrypted login information are sent to the target service, so that all database connection pool proxies in the target service can jointly decrypt the encrypted database address information and the encrypted login information to obtain the real database address information and the real login information. Then, the database connection pool proxies corresponding to each instance in the target service can connect to the corresponding database based on the real database address information and the real login information.

7. A computer device, the computer device comprising a memory and a processor; The memory is used to store computer programs; Its features are, The processor is configured to execute the computer program and, in executing the computer program, implement the database connection control method as described in any one of claims 1 to 5.

8. A computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the database connection control method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Internal and external parameters based database connection pool monitoring and management method and apparatus

    CN105302692A

  • Load balancing system for remote service calling based on real-time load rate

    CN106453125A

  • Connection pool scheduling method and device

    CN110471773A