A database access method and system
Patent Information
- Application Number
- CN202211402312.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-09
- Publication Date
- 2026-09-04
- Estimated Expiration
- 2042-11-09
AI Technical Summary
[0003]然而,负载均衡在DBMS场景下存在一定的弊端,具体如,负载均衡的随机分发的特点很可能导致首次建立数据库会话连接的计算服务器和处理后续数据库操作请求的计算服务器不同,进而使得后续的计算服务器丢失会话上下文而不能完成数据库操作,或者需要后续计算服务器重新建立数据库会话连接,导致数据库负荷增加
Smart Images

Figure CN115577033B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of information technology, and in particular to a database access method and system. Background Technology
[0002] A database (DB) is an effective technology for computer data management, allowing users to store and maintain computer data. To improve database access efficiency, Database Management Systems (DBMS) have been developed. Generally, a DBMS consists of a load balancer and multiple compute servers. Upon user requests, the compute servers establish communication connections with the relevant databases to complete the user's access and return the results to the user. The load balancer receives user requests and distributes them to the appropriate compute servers according to a load balancing strategy. A DBMS enables efficient processing of high-concurrency database access requests, thus improving database access efficiency.
[0003] However, load balancing has certain drawbacks in DBMS scenarios. Specifically, the random distribution characteristic of load balancing may result in different computing servers establishing the initial database session connection and handling subsequent database operation requests. This can cause subsequent computing servers to lose session context and fail to complete database operations, or require subsequent computing servers to re-establish database session connections, leading to increased database load. Therefore, some embodiments of this specification provide database access methods and systems for DBMS scenarios to address the aforementioned problems. Summary of the Invention
[0004] One embodiment of this specification provides a database access method executed by one of a plurality of computing servers, comprising: obtaining a client request forwarded by a load balancer; the client request including a database request; determining whether the client request also contains identification information; the identification information including a database session connection identifier and a corresponding server identifier; if the client request contains the identification information, determining whether the server identifier therein is consistent with its own identifier: if consistent, interacting with the corresponding database based on the database request and returning feedback data from the database to the client; if inconsistent, forwarding the client request to the computing server corresponding to the server identifier; if the client request does not contain the identification information, creating a database session connection with the corresponding database based on the database request in the client request, generating identification information based on the database session connection and its own identifier and returning it to the client.
[0005] One embodiment of this specification also provides a database access system, deployed on one of multiple computing servers, comprising: a client request acquisition module, used to acquire client requests forwarded by a load balancer; the client request includes a database request; an identification information judgment module, used to determine whether the client request also contains identification information; the identification information includes a database session connection identifier and a corresponding server identifier; a client request processing module, used to, if the client request contains the identification information, determine whether the server identifier therein is consistent with its own identifier: if consistent, then interact with the corresponding database based on the database request and return feedback data from the database to the client; if inconsistent, then forward the client request to the computing server corresponding to the server identifier; a session connection module, used to, if the client request does not contain the identification information, create a database session connection with the corresponding database based on the database request in the client request, generate identification information based on the database session connection and its own identifier, and return it to the client.
[0006] One embodiment of this specification also provides a database access device, including a processor and a storage medium, wherein the storage medium is used to store computer instructions, and the processor is used to execute at least a portion of the computer instructions to implement the database access method described above.
[0007] One embodiment of this specification also provides a database access method, executed by a client, comprising: obtaining database login information; generating a client request based on the database login information; sending the client request to a computing server through a load balancing server, so as to establish a database session connection with the corresponding database through the computing server; and receiving identification information returned by the computing server, the identification information including the database session connection identifier and the server identifier of the computing server.
[0008] One embodiment of this specification also provides a database access system deployed on a client, comprising: a login information acquisition module for acquiring database login information; a first client request generation module for generating a client request based on the database login information; a first client request sending module for sending the client request to a computing server through a load balancing server, so as to establish a database session connection with the corresponding database through the computing server; and an identification information receiving module for receiving identification information returned by the computing server, the identification information including the database session connection identifier and the server identifier of the computing server.
[0009] One embodiment of this specification also provides a database access device, including a processor and a storage medium, wherein the storage medium is used to store computer instructions, and the processor is used to execute at least a portion of the computer instructions to implement the database access method described above.
[0010] One embodiment of this specification also provides a database access method, executed by a client, comprising: obtaining a database operation instruction; generating a client request based on the database operation instruction and identification information; the identification information including a database session connection identifier with a target database and a corresponding server identifier; sending the client request to a computing server through a load balancing server, so that the computing server corresponding to the server identifier accesses the target database based on the database operation instruction to obtain feedback data from the target database; and receiving the feedback data returned by the computing server.
[0011] One embodiment of this specification also provides a database access system deployed on a client, comprising: an operation instruction acquisition module for acquiring database operation instructions; a second client request generation module for generating a client request based on the database operation instructions and identification information; the identification information including a database session connection identifier with a target database and a corresponding server identifier; a second client request sending module for sending the client request to a computing server through a load balancing server, so that the computing server corresponding to the server identifier can access the target database based on the database operation instructions to obtain feedback data from the target database; and a feedback data receiving module for receiving the feedback data returned by the computing server.
[0012] A database access apparatus includes a processor and a storage medium for storing computer instructions, wherein the processor is configured to execute at least a portion of the computer instructions to implement the database access method described above. Attached Figure Description
[0013] This specification will be further described by way of exemplary embodiments, which will be described in detail with reference to the accompanying drawings. These embodiments are not limiting; in these embodiments, the same reference numerals denote the same structures, wherein:
[0014] Figure 1 These are schematic diagrams illustrating database access scenarios according to some embodiments of this specification;
[0015] Figure 2 This is an exemplary flowchart of a database access method according to some embodiments of this specification;
[0016] Figure 3This is an exemplary flowchart of a database access method according to some embodiments of this specification;
[0017] Figure 4 This is an exemplary flowchart of a database access method according to some embodiments of this specification;
[0018] Figure 5 This is an exemplary scenario of a database access method shown in some embodiments of this specification;
[0019] Figure 6 This is an exemplary block diagram of a database access system according to some embodiments of this specification;
[0020] Figure 7 These are exemplary block diagrams of a database access system according to some embodiments of this specification;
[0021] Figure 8 This is an exemplary block diagram of a database access system according to some embodiments of this specification. Detailed Implementation
[0022] To more clearly illustrate the technical solutions of the embodiments in this specification, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are merely some examples or embodiments of this specification. For those skilled in the art, these drawings can be applied to other similar scenarios without creative effort. Unless obvious from the context or otherwise specified, the same reference numerals in the drawings represent the same structures or operations.
[0023] It should be understood that the terms “system,” “device,” “unit,” and / or “module” used herein are one way to distinguish different components, elements, parts, sections, or assemblies at different levels. However, if other terms can achieve the same purpose, they may be replaced by other expressions.
[0024] As indicated in this specification and claims, unless the context clearly indicates otherwise, the words "a," "an," "an," and / or "the" do not specifically refer to the singular and may also include the plural. Generally speaking, the terms "comprising" and "including" only indicate the inclusion of expressly identified steps and elements, which do not constitute an exclusive list, and the method or apparatus may also include other steps or elements.
[0025] Flowcharts are used in this specification to illustrate the operations performed by the system according to embodiments of this specification. It should be understood that the preceding or following operations are not necessarily performed in exact order. Instead, the steps can be processed in reverse order or simultaneously. Furthermore, other operations can be added to these processes, or one or more steps can be removed from them.
[0026] Figure 1 This is a schematic diagram of a database access scenario based on some embodiments of this specification.
[0027] like Figure 1 As shown, scenario 100 may include client 110, database management cluster 120 (or database management system, DBMS) and one or more databases 130.
[0028] Client 110 refers to one or more terminal devices or software used by a user. In some embodiments, the user of client 110 may be one or more users, including users directly using the service, or other related users. In some embodiments, user terminal 110 may be one or any combination of other devices with input and / or output functions, such as mobile device 110-1, tablet computer 110-2, laptop computer 110-3, etc. In some embodiments, a user may generate a client request through client 110, wherein the client request may include a database request for a certain database.
[0029] The database management cluster 120 may include one or more devices or software. For example, the database management cluster 120 may include a load balancer 121 and multiple computing servers (such as computing server 122-1, computing server 122-2, and computing server 122-3, etc.). The computing servers are peer-to-peer, and any computing server can handle client requests. The load balancer 121 is used to receive client requests sent by client 110 and distribute them to appropriate computing servers based on a certain load balancing strategy. In some embodiments, the load balancing strategy can be round-robin, such as the load balancing server 121 distributing each client request to different computing servers in chronological order; or the load balancing strategy can be a weighted strategy, such as the load balancing server 121 distributing client requests such that computing servers with higher weights have a higher probability of receiving client requests, where the weights can be determined based on the device performance of the computing servers; or the load balancing strategy can be a least-connections approach, such as the load balancing server 121 prioritizing the distribution of current client requests to the computing server with the fewest connections; or the load balancing strategy can be an IP address hash strategy, such as the load balancing server 121 calculating the hash value of the IP address of each client request, then calculating the modulus of the hash value relative to the number of computing servers, and finally distributing the client request to each computing server according to the modulus value.
[0030] The computing server can handle client requests. In some embodiments, the computing server can establish a database session connection with the corresponding database based on the database login information in the client request. Further, the computing server can request the corresponding database to execute the database operation instructions in the client request, obtain the execution result from the database, and send the result back to the client. In some embodiments, the computing server can be considered to act as a proxy for the client to access the database. The login information includes, but is not limited to, the database's IP address, port number, and login account information (such as login username and password). A database session connection, also known as a session connection, refers to a long-lived connection between the computing server and the corresponding database. Specifically, a long-lived connection means that both parties can continuously send multiple data packets on a single connection. During the connection maintenance period, if no data packets are sent, both parties need to send link detection packets to maintain the connection. In a database access scenario, data packets (from the computing server to the database) may include one or more database operation instructions, or data packets (from the database to the computing server) may include the result obtained after the database executes the operation instructions. In some embodiments, when a computing server establishes a database session connection with a database, the computing server allocates a region in its memory, which can be called a session. The session is used to store the session context of the database session connection (such as variables, attribute values, etc. involved in the session). When the computing server subsequently requests the database to execute some operation instructions through the session, it can directly read the session context recorded in the session to perform various operations on the database in a coherent and efficient manner.
[0031] Database 130, also known as a database server, is used to store or maintain large amounts of data. In some embodiments, the data stored in database 130 may be data used or generated in various industries, including but not limited to the financial industry, insurance industry, internet industry, automotive industry, catering industry, telecommunications industry, energy industry, entertainment industry, sports industry, logistics industry, medical industry, and security industry. In some embodiments, database 130 may include processing devices and one or more storage components, wherein the storage components may be random access memory (RAM), read-only memory (ROM), mass storage, removable storage, volatile read-write memory, etc., or any combination thereof. For example, mass storage may include disks, optical disks, solid-state drives, etc. Database 130 can receive database requests from client 110 or computing server to establish corresponding database session connections or execute operation instructions in the database request. Generally, the database will first verify the database login information in the database request. If successful, it will establish a database session connection with the corresponding client or computing server, and subsequently receive and execute database operation instructions from the client or computing server based on the session connection. The operation commands can include querying, adding new data, deleting existing data, and modifying existing data.
[0032] The existence of a load balancer allows a large number of client requests to be distributed more evenly across multiple computing servers for parallel processing, which obviously greatly improves the efficiency of client request processing. However, the random distribution characteristic of load balancing may result in the computing server that establishes the initial database session connection being different from the computing server that handles subsequent database operation requests. Even with an IP address hashing strategy, the aforementioned problem can still occur when the client's IP address changes.
[0033] As an example, client A sends a first client request to the DBMS, which includes database login information. The load balancer distributes the first client request to compute server 1 for processing. Compute server 1 establishes a session connection with the target database based on the database login information in the request and saves the session context. Subsequently, client A sends a second client request to the DBMS, which includes a query instruction for table 1 in the target database. The load balancer, according to a preset load balancing strategy, will likely distribute the second client request to compute server 2 for processing. At this time, compute server 2 has never established a session connection with the target database using client A's database login information. In order to complete the query request, compute server 2 needs to re-establish a session connection with the target database based on client A's database login information and then send the query instruction to the target database to complete the query task. This results in multiple compute servers in the DBMS establishing the same session connection with the same database. From the database's perspective, maintaining a large number of session connections for the same login account increases the database's burden. Even if the database performance is powerful enough to maintain numerous session connections, when computing server 2 interacts with the target database, it will lack some session context (i.e., the session context stored on computing server 1), thus failing to complete database operations coherently or even at all.
[0034] In view of this, some embodiments of this specification provide a database access method as compensation for load balancing in the DBMS, ensuring that client requests from the same login account can be processed by the same computing server, thereby further improving database access efficiency and enhancing user experience.
[0035] Figure 2 This is an exemplary flowchart of a database access method according to some embodiments of this specification.
[0036] In some embodiments, one or more steps in process 200 may be computed by a computing server (such as...). Figure 1 The process 200 is executed by any computing server in the process, and includes:
[0037] Step 210: Obtain the client request forwarded by the load balancer server. In some embodiments, step 210 may be performed by the client request acquisition module 610.
[0038] A client request is generated by the client and sent to the load balancer server (or sent to the database management cluster, where the load balancer server receives it). Upon receiving the request, the load balancer server forwards it to a specific computing server according to its load balancing strategy. Load balancing strategies can be found in [link to relevant documentation]. Figure 1 The relevant explanations will not be repeated here.
[0039] In some embodiments, a client request may further include a database request. A database request is a client's request for database services. This request can be sent to the computing server in the DBMS, allowing the computing server to act as an intermediary for the client to access the target database.
[0040] In some embodiments, the database request may specifically include a connection request (such as database login information) and / or an operation request. The connection request may include database login information, and the access request may include database operation instructions or include both database login information and database operation instructions. For details regarding database login information and database operation instructions, please refer to [link to relevant documentation]. Figure 1 The relevant explanations will not be repeated here.
[0041] In some embodiments, the client request may also include other access-related information, such as the client's IP address and the client's login information in the DBMS (i.e., DBMS login information), so that the computing server can authenticate the client request or identify the client. In some embodiments, the client request may further include identification information.
[0042] Step 220: Determine whether the client request also contains identification information. In some embodiments, step 220 may be performed by the identification information determination module 620.
[0043] When a computing server and a database have already established a session connection, identification information can be added to the client request when reconnecting to ensure that subsequent client requests can be successfully sent to the computing server that previously established a session connection with the database.
[0044] In some embodiments, the identification information includes a database session connection identifier and a corresponding server identifier. The database session connection identifier indicates that the current client is requesting a related database session connection, while the server identifier indicates the computing server that created and maintains the database session connection. The server identifier may include the ID of the corresponding computing server or other information that can uniquely identify the computing server, and may include numbers, characters, and / or letters. For details on how the identification information is generated, please refer to step 240 below.
[0045] Step 230: If the client request includes the identification information, determine whether the server identifier therein matches its own identifier. In some embodiments, step 230 may be executed by the client request processing module 630.
[0046] When step 220 determines that the client request contains identification information, it can be determined whether the corresponding database session connection has been created and maintained locally by comparing the identification information in the client request with the identifier of the current computing server itself. In some embodiments, when step 220 determines that the client request does not contain identification information, step 230 can be skipped, and step 240 can be executed directly.
[0047] In a DBMS, a unique server identifier can be configured for each compute server, and each compute server can store its own server identifier locally. In some embodiments, a unique identifier corresponding to the compute server can be generated and stored locally on the compute server when the compute server comes online or registers with the database management cluster.
[0048] In some embodiments, if the identification information in the client request matches the server's own identification, the computing server can interact with the corresponding database based on the database request and return the database's feedback data to the client, thus completing the processing of a client request. In some embodiments, the feedback data may include query results, processing results, status update results, etc. As an example, if the database request in the client request is an operation request, which includes a query instruction for table 1 in the target database, such as select * from "table 1", the computing server can encapsulate this instruction in a data packet and send it to the target database through a pre-established session connection with the target database. The target database encapsulates the query results into one or more data packets and sends them to the computing server through the session connection. Finally, the computing server returns the query results to the client.
[0049] In some embodiments, if the identification information in the client request is inconsistent with the server's own identification, the current computing server will forward the client request to the computing server corresponding to the server identification for processing, thereby improving processing efficiency. In some embodiments, each computing server in the DBMS can store the server identification and network address of other computing servers. Therefore, the current computing server can obtain the network address of the corresponding computing server from its local information based on the server identification in the client request, and then forward the client request to the computing server corresponding to the server identification. In other embodiments, the current computing server can query the metadata server based on the server identification in the client request to obtain the network address of the corresponding computing server. A detailed description of the metadata server can be found later and will not be repeated here.
[0050] Figure 5 This is an exemplary scenario of a database access method according to some embodiments of this specification. (Reference) Figure 5In this scenario, computing server 522-2 has established session connection 1 with database 530. Assuming client 510 needs to operate on database 530, it generates a client request based on the corresponding operation instructions and sends it to load balancer 521. At this time, the client request contains identification information, including the identifier of session connection 1 and the identifier of computing server 522-2. Load balancer 521 sends the client request to computing server 522-1 according to its load balancing strategy. Server 522-1 determines that the server identifier in the client request is inconsistent with its own, and then forwards the client request to the computing server corresponding to that identifier—i.e., computing server 522-2.
[0051] Computing server 522-2 obtains the client request from computing server 522-1 and processes the client request. The specific process is similar to the relevant content mentioned above when the server identifier in the client request matches the identifier of the current computing server, and will not be repeated here.
[0052] Step 240: If the client request does not contain the identification information, a database session connection is created with the corresponding database based on the database request in the client request. Identification information is generated based on the database session connection and its own identifier and returned to the client. In some embodiments, step 240 can be performed by the session connection module 640.
[0053] If the client request does not contain the identification information, it can be determined that the client may be establishing a session connection with the database in the request for the first time. It should be noted that the client request not containing the identification information may also be due to the computing server that previously established a database session connection being offline, but this does not affect the current computing server from executing step 240.
[0054] Accordingly, the computing server can establish a database session connection with the corresponding database based on the database login information requested in the client's request. For more information on establishing database session connections, please refer to [link to relevant documentation]. Figure 1 The relevant explanations will not be repeated here. In some embodiments, after establishing a database session connection, the computing server can continue to interact with the database further, such as performing corresponding operations on the database based on database operation instructions in the client request.
[0055] Furthermore, the computing server can generate a unique identifier for the database session connection, and generate identification information together with its own server identifier and return it to the client. When the client sends a subsequent client request corresponding to the database, the client request can be obtained and executed by the computing server based on the identification information.
[0056] In some embodiments, the computing server can generate a database session connection identifier for the database session connection based on an identifier generation algorithm (such as the Universally Unique Identifier (UUID) algorithm), and concatenate the database session connection identifier with its own server identifier to obtain the identification information. In some embodiments, the server can also generate identifiers for the database session connection based on other non-repeating random number algorithms or message digest algorithms, which are not limited in this specification. Using an identifier generation algorithm can effectively reduce the probability of duplicate identifiers generated by different computing servers for different database session connections in the DBMS, effectively ensuring the uniqueness of the connection identifier.
[0057] To compensate for the access inconvenience caused by load balancing to the DBMS, embodiments of this specification propose recording database session connection identifiers and corresponding server identifiers. To better maintain server identifiers and other data and facilitate querying, some embodiments of this specification introduce a metadata server. The metadata server can be... Figure 1 One of the servers in the database management cluster 120 stores metadata related to the database management cluster. Typically, the metadata server is configured not to execute client requests, and it is accessible to all computing servers in the database management cluster to perform operations such as querying, adding, or updating the data in the metadata server. In some embodiments, the metadata server does not necessarily need to be implemented on a separate server (or computing device), but rather as a module integrated into a computing server or a load balancer server.
[0058] In some embodiments, the metadata server may store information such as server identifiers and network addresses for multiple computing servers. There is a one-to-one correspondence between server identifiers and network addresses; any computing server can query the metadata server using its server identifier to obtain the corresponding network address. In some embodiments, whenever a computing server joins the DBMS, it sends its server identifier to the metadata server or requests the metadata server to configure a unique server identifier for it. Subsequently, the metadata server records the server identifiers and network addresses corresponding to each computing server.
[0059] In some embodiments, the metadata server may also store the status of multiple compute servers in the database management cluster. The status of a compute server may include active, offline, etc. In some embodiments, the metadata server may also update the status of each compute server so that other servers can be informed of the status of the relevant compute servers in a timely manner.
[0060] For example, each computing server in a DBMS can periodically send connection signals to the metadata server, allowing the metadata server to determine the status of each computing server based on these connection signals. In some embodiments, the connection signal can be a message or heartbeat signal including the current status of the computing server, and the connection signal can be sent at regular intervals (e.g., 30 seconds, 1 minute, 5 minutes, etc.) as required by the metadata server or database management cluster. The metadata server can determine or adjust the status of each computing server based on the connection signals. For example, if the metadata server does not receive a connection signal from a certain computing server for more than 3 minutes or for two connection signal sending cycles, the status of that computing server can be adjusted from "active" to "offline".
[0061] When a metadata server is introduced, if the current computing server determines in step 230 that the server identifier in the client request is inconsistent with its own, it can query the metadata server based on the server identifier. The metadata server can return the network address and status of the computing server corresponding to the server identifier. If the status is valid, the current computing server forwards the client request to the computing server corresponding to the server identifier based on its network address. If the status is offline, the current computing server can re-establish a database session connection with the corresponding database based on the client request and interact with the database accordingly. The metadata server records and updates the status of each computing server, and re-creates the database session connection through the current computing server when the original database session connection is offline, ensuring that client requests are processed in a timely manner and effectively improving the user experience.
[0062] Figure 3 This is an exemplary flowchart of a database access method according to some embodiments of this specification.
[0063] In some embodiments, one or more steps in process 300 may be performed by a client (such as...). Figure 1 The process, executed by client 110, includes the following steps:
[0064] Step 310: Obtain database login information. In some embodiments, step 310 may be performed by the login information acquisition module 710.
[0065] In some embodiments, database login information includes the database's network address (such as IP address, port number, etc.) and login account information required to log in to the database (such as account ID, password, etc.). In some embodiments, the client can receive static configuration information (such as the aforementioned database network address and login account information required to log in to the database) filled in by the user on the client interface, and generate database login information corresponding to the static configuration information. In some embodiments, the generated database login information can be displayed on the client interface in the form of records. In some embodiments, the client interface may include multiple records, each corresponding to different database login information.
[0066] Step 320: Generate a client request based on the database login information. In some embodiments, step 320 may be performed by the first client request generation module.
[0067] The client can further generate a client request (such as an HTTP request) based on the database login information obtained in step 310. In some embodiments, for multiple database login information records in the client interface, a client request for the corresponding database login information can be generated when the user selects or clicks on a certain record. Specifically, the client request may include a connection request to indicate the establishment of a session connection with the corresponding database based on the database login information. In some embodiments, the client request may also include an operation request for the corresponding database server, wherein the operation request may include database operation instructions in addition to the database login information to indicate the performance of an operation on the relevant database.
[0068] In some embodiments, the client request may also include other access-related information, such as the client's IP address and the client's login information in the DBMS (i.e., DBMS login information) so that the computing server can authenticate the client request or verify the client.
[0069] Step 330: The client request is sent to a server via a load balancer to establish a database session connection with the corresponding database. In some embodiments, step 330 may be performed by the first client request sending module 730.
[0070] For more information about load balancing servers, please refer to the description in step 210. After the load balancing server sends a client request to a computing server, that computing server establishes a database session connection with the database corresponding to the client request and generates identification information. For more information about identification information, please refer to the description in step 240, which will not be repeated here.
[0071] Step 340: Receive the identification information returned by the server. In some embodiments, step 340 may be performed by the identification information receiving module 740.
[0072] In some embodiments, the computing server may also return the results after executing operation instructions in the corresponding database.
[0073] In some embodiments, after the client establishes a session connection with the server by performing one or more steps in process 300, it can perform subsequent operations on the database. Therefore, process 300 may also include:
[0074] Step 350: Obtain database operation instructions.
[0075] Similar to database login information, database operation instructions can also be generated by the user through input or selection on the client interface and retrieved by the client. For example, suppose it is necessary to select the table data of listed companies from a data table containing companies in the database, the database operation instruction could include `select ListedCompany from Company`.
[0076] Step 360: Generate a client request based on the database operation instructions and the identification information.
[0077] In order for the client request to be sent to the computing server in step 330 again, the client generates a client request based on the identification information and database operation instructions returned by the computing server.
[0078] Similarly, client requests may also include other access-related information, such as the client's IP address and the client's login information in the DBMS (i.e., DBMS login information).
[0079] Step 370: The client request is sent to a computing server through a load balancer so that the computing server corresponding to the server identifier can access the corresponding database based on the database operation instructions to obtain the database feedback data.
[0080] In some embodiments, the load balancing server may send the client request to any computing server based on a load balancing strategy. The computing server can determine whether the request should be executed by itself or forwarded to the computing server corresponding to the server identifier through the server identifier in the client request. In some embodiments, the computing server that receives the client request can execute process 200 to complete the processing of the client request.
[0081] Step 380: Receive the feedback data returned by the computing server.
[0082] In some embodiments, the client may receive the feedback data returned from the server with which the session connection was established. It is readily apparent that, regardless of which computing server the load balancing server sends the client request to in step 370, the client can ultimately obtain the feedback data from the computing server with which the session connection was previously established. In other words, the embodiments of this specification ensure that the database access efficiency is no longer constrained by the load balancing strategy, allowing the DBMS to select any more efficient load balancing strategy according to actual needs.
[0083] Figure 4 This is an exemplary flowchart of a database access method according to some embodiments of this specification.
[0084] In cases where the user changes their client device (e.g., the user is transferred from another device), Figure 1 When a mobile device 110-1 switches to a laptop computer 110-3, and needs to continue operating on the database with which a session connection has been established through the DBMS, the client can directly initiate a client request according to process 400 based on existing identification information. In some embodiments, process 400 may include:
[0085] Step 410: Obtain database operation instructions. In some embodiments, step 410 may be executed by the operation instruction acquisition module 810.
[0086] Step 420: Generate a client request based on the database operation instructions and identification information, wherein the identification information includes a database session connection identifier with the target database and a corresponding computing server identifier. In some embodiments, step 420 may be executed by the second client request generation module 820.
[0087] Step 430: The client request is sent to a computing server via a load balancer, so that the computing server corresponding to the server identifier can access the target database based on the database operation instructions to obtain feedback data from the target database. In some embodiments, step 430 can be executed by the second client request sending module 830.
[0088] Step 440: Receive the feedback data returned by the computing server. In some embodiments, step 440 may be performed by the feedback data receiving module 830.
[0089] Steps 410 to 440 are similar to steps 350 to 380. For more details about steps 410 to 440, please refer to the descriptions in the corresponding positions above, which will not be repeated here.
[0090] As can be seen from process 400, when environmental changes such as changes in the client IP due to network changes or changes in the user's client cause the user to request data services from the same database using the same account, the user's client request can still be forwarded to the computing server that has established a session connection with the database. This avoids the database being started on multiple computing servers and avoids the loss of session context.
[0091] It should be noted that the above descriptions of processes 200, 300, and 400 are for illustrative purposes only and do not limit the scope of this specification. Those skilled in the art can make various modifications and changes to processes 200, 300, and 400 under the guidance of this specification. However, these modifications and changes remain within the scope of this specification. For example, steps 230 or 240 may be omitted.
[0092] Figure 6 This is an exemplary block diagram of a database access system according to some embodiments of this specification.
[0093] Figure 6 A database access system 600 is shown, which is deployed on one of a plurality of computing servers. It includes a client request acquisition module 610, an identification information judgment module 620, a client request processing module 630, and a session connection module 640.
[0094] The client request acquisition module 610 is used to acquire client requests forwarded by the load balancer server; the client requests include database requests.
[0095] In some embodiments, further description of the forwarded client requests can be found in the relevant content of step 210, and will not be repeated here.
[0096] The identification information determination module 620 is used to determine whether the client request still contains identification information; the identification information includes the database session connection identifier and the corresponding server identifier.
[0097] In some embodiments, further description of the identification information can be found in the relevant content of step 220, and will not be repeated here.
[0098] The client request processing module 630 is used to determine whether the server identifier in the client request is consistent with its own identifier if the client request contains the identifier information: if they are consistent, the module interacts with the corresponding database based on the database request and returns the feedback data of the database to the client; if they are inconsistent, the module forwards the client request to the computing server corresponding to the server identifier.
[0099] In some embodiments, further description of client request processing can be found in the relevant content of step 230, and will not be repeated here.
[0100] The session connection module 640 is used to create a database session connection with the corresponding database based on the database request in the client request if the client request does not contain the identification information, generate identification information based on the database session connection and its own identification, and return it to the client.
[0101] In some embodiments, further description of the session connection can be found in the relevant content of step 240, and will not be repeated here.
[0102] Figure 7 This is an exemplary block diagram of a database access system according to some embodiments of this specification.
[0103] Figure 7 A database access system 700 is shown, which is deployed on a client side and includes a login information acquisition module 710, a first client request generation module 720, a first client request sending module 730, and an identification information receiving module 740.
[0104] The login information acquisition module 710 is used to acquire database login information.
[0105] In some embodiments, further descriptions of database login information can be found in the relevant content of step 310, and will not be repeated here.
[0106] The first client request generation module 720 is used to generate a client request based on the login information in the database.
[0107] In some embodiments, further description of the client request can be found in the relevant content of step 310, and will not be repeated here.
[0108] The first client request sending module 730 is used to send the client request to a certain computing server through a load balancing server, so as to establish a database session connection with the corresponding database through the computing server.
[0109] In some embodiments, further description of the database session connection can be found in the relevant content of step 330, and will not be repeated here.
[0110] The identification information receiving module 740 is used to receive identification information returned by the computing server, the identification information including the database session connection identifier and the server identifier of the computing server.
[0111] In some embodiments, further description of the identification information can be found in the relevant content of step 340, and will not be repeated here.
[0112] Figure 8 This is an exemplary block diagram of a database access system according to some embodiments of this specification.
[0113] Figure 8 A database access system 800 is shown, which is arranged on the client side and includes an operation instruction acquisition module 810, a second client request generation module 820, a second client request sending module 830, and a feedback data receiving module 840.
[0114] The operation instruction acquisition module 810 is used to acquire database operation instructions.
[0115] In some embodiments, further descriptions of database operation instructions can be found in steps 350 or 410, and will not be repeated here.
[0116] The second client request generation module 820 is used to generate a client request based on the database operation instructions and identification information; the identification information includes the database session connection identifier with the target database and the corresponding server identifier.
[0117] In some embodiments, further descriptions of database operation instructions can be found in steps 350 or 410, and will not be repeated here.
[0118] The second client request sending module 830 is used to send the client request to a certain computing server through the load balancing server, so that the computing server corresponding to the server identifier can access the target database based on the database operation instructions and obtain the feedback data of the target database.
[0119] In some embodiments, further description of the second client request sending can be found in steps 360 or 420, and will not be repeated here.
[0120] The feedback data receiving module 840 is used to receive the feedback data returned by the computing server.
[0121] In some embodiments, further description of the feedback data can be found in steps 370 or 430, and will not be repeated here.
[0122] It should be understood that Figures 6-8The systems and modules shown can be implemented in various ways. For example, in some embodiments, the systems and modules can be implemented in hardware, software, or a combination of both. The hardware portion can be implemented using dedicated logic; the software portion can be stored in memory and executed by a suitable instruction execution device, such as a microprocessor or dedicated-design hardware. Those skilled in the art will understand that the methods and apparatus described above can be implemented using computer-executable instructions and / or included in processor control code, for example, on a carrier medium such as a disk, CD, or DVD-ROM, a programmable memory such as read-only memory (firmware), or a data carrier such as an optical or electronic signal carrier. The apparatus and modules described in this specification can be implemented not only with hardware circuits such as very large-scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, or programmable hardware devices such as field-programmable gate arrays, programmable logic devices, etc., but also with software, for example, executed by various types of processors, or with a combination of the aforementioned hardware circuits and software (e.g., firmware).
[0123] It should be noted that the above description of the data download device and its modules is for convenience only and should not be construed as limiting this specification to the embodiments described. It is understood that those skilled in the art, after understanding the principle of this device, may arbitrarily combine the various modules or construct sub-devices connected to other modules without departing from this principle. For example, Figure 6 The identification information judgment module 620 and the client request processing module 630 can be the same module. Alternatively, the various modules in the system can reside on the same server or belong to different servers. Such variations are all within the scope of this specification.
[0124] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0125] The beneficial effects that the embodiments of this specification may bring include, but are not limited to: (1) By generating identification information when establishing a database session connection for the first time, subsequent client requests can be processed by the computing server that has already established a session connection, reducing the database access burden and ensuring that the session context is not lost; (2) Storing the server status in the metadata server facilitates access management and improves the user experience; (3) The database access efficiency is no longer constrained by the load balancing strategy, and the DBMS can choose any better load balancing strategy according to actual needs.
[0126] It should be noted that different embodiments may produce different beneficial effects. In different embodiments, the beneficial effects may be any one or a combination of the above, or any other possible beneficial effects.
[0127] The basic concepts have been described above. Obviously, for those skilled in the art, the detailed disclosure above is merely illustrative and does not constitute a limitation of this specification. Although not explicitly stated herein, those skilled in the art may make various modifications, improvements, and corrections to this specification. Such modifications, improvements, and corrections are suggested in this specification and therefore remain within the spirit and scope of the exemplary embodiments described herein.
[0128] Furthermore, this specification uses specific terms to describe embodiments thereof. For example, "an embodiment," "one embodiment," and / or "some embodiments" refer to a particular feature, structure, or characteristic associated with at least one embodiment of this specification. Therefore, it should be emphasized and noted that references to "an embodiment," "one embodiment," or "an alternative embodiment" in different locations throughout this specification do not necessarily refer to the same embodiment. Moreover, certain features, structures, or characteristics in one or more embodiments of this specification can be appropriately combined.
[0129] Furthermore, unless expressly stated in the claims, the order of processing elements and sequences, the use of numbers and letters, or other names described in this specification are not intended to limit the order of the processes and methods described herein. Although various examples have been discussed in the foregoing disclosure of some embodiments of the invention that are currently considered useful, it should be understood that such details are for illustrative purposes only, and the appended claims are not limited to the disclosed embodiments; rather, the claims are intended to cover all modifications and equivalent combinations that conform to the spirit and scope of the embodiments described herein. For example, while the system components described above can be implemented using hardware devices, they can also be implemented solely using software solutions, such as installing the described system on existing servers or mobile devices.
[0130] Similarly, it should be noted that, in order to simplify the description disclosed herein and thus aid in the understanding of one or more embodiments of the invention, the foregoing description of embodiments in this specification may sometimes combine multiple features into a single embodiment, drawing, or description thereof. However, this method of disclosure does not imply that the subject matter of this specification requires more features than those mentioned in the claims. In fact, the embodiments contain fewer features than all the features of a single embodiment disclosed above.
[0131] In some embodiments, numbers describing the quantity of components and attributes are used. It should be understood that such numbers used in the description of embodiments are modified in some examples with the terms "approximately," "approximately," or "generally." Unless otherwise stated, "approximately," "approximately," or "generally" indicates that the numbers are allowed to vary by ±20%. Accordingly, in some embodiments, the numerical parameters used in the specification and claims are approximate values, which may be changed depending on the characteristics required by individual embodiments. In some embodiments, numerical parameters should take into account specified significant digits and employ a general method of digit reservation. Although the numerical ranges and parameters used to confirm their breadth of range in some embodiments of this specification are approximate values, in specific embodiments, such values are set as precisely as feasible.
[0132] For each patent, patent application, patent application publication, and other material, such as articles, books, specifications, publications, and documents, referenced in this specification, the entire contents of which are incorporated herein by reference. This excludes historical application documents that are inconsistent with or conflict with the content of this specification, as well as documents that limit the broadest scope of the claims in this specification (currently or subsequently appended to this specification). It should be noted that in the event of any inconsistency or conflict between the descriptions, definitions, and / or terminology used in the supplementary materials to this specification and the content of this specification, the descriptions, definitions, and / or terminology used in this specification shall prevail.
[0133] Finally, it should be understood that the embodiments described in this specification are merely illustrative of the principles of the embodiments described herein. Other variations may also fall within the scope of this specification. Therefore, alternative configurations of the embodiments described herein are intended to be illustrative rather than limiting, and should be considered consistent with the teachings of this specification. Accordingly, the embodiments described herein are not limited to those explicitly introduced and described herein.
Claims
1. A database access method, executed by one of a plurality of computing servers, comprising: Retrieve client requests forwarded by the load balancer based on the load balancing policy; The client requests include database requests, and the load balancing strategies include round-robin, weighted strategies, least connections, or IP address hashing strategies. Determine whether the client request also contains identification information; the identification information includes a database session connection identifier and a corresponding server identifier. If the client request contains the identification information, it is determined whether the server identifier therein is consistent with its own identifier: if they are consistent, the database is interacted with based on the database request, and the feedback data of the database is returned to the client. If they do not match, the client request is forwarded to the computing server corresponding to the server identifier; If the client request does not contain the identification information, a database session connection is created with the corresponding database based on the database request in the client request, and identification information is generated based on the database session connection and its own identification and returned to the client.
2. The method as described in claim 1, wherein, The step of forwarding the client request to the computing server corresponding to the server identifier includes: The query is made to the metadata server based on the server identifier; the metadata server stores and updates the server identifiers, network addresses and statuses of multiple computing servers. When the computing server corresponding to the server identifier is in a valid state, the client request is forwarded to the computing server corresponding to the server identifier based on its network address.
3. The method as described in claim 1 or 2, wherein, Also includes: It sends its own identifier and network address to the metadata server; In addition, a connection signal is periodically sent to the metadata server so that the metadata server can determine the status of a particular computing server based on the connection signal.
4. The method of claim 1, wherein, The database request includes database login information and / or database operation instructions; the database login information includes the database's network address and login account information.
5. A database access system, deployed on one of multiple computing servers, comprising: The client request acquisition module is used to acquire client requests forwarded by the load balancer server based on the load balancing strategy. The client requests include database requests, and the load balancing strategies include round-robin, weighted strategies, least connections, or IP address hashing strategies. The identification information determination module is used to determine whether the client request still contains identification information; the identification information includes a database session connection identifier and a corresponding server identifier. The client request processing module is used to determine whether the server identifier in the client request is consistent with its own identifier if the client request contains the identifier information; if they are consistent, the module interacts with the corresponding database based on the database request and returns the feedback data of the database to the client. If they do not match, the client request is forwarded to the computing server corresponding to the server identifier; The session connection module is used to create a database session connection with the corresponding database based on the database request in the client request if the client request does not contain the identification information, generate identification information based on the database session connection and its own identification, and return it to the client.
6. A database access apparatus, comprising a processor and a storage medium, the storage medium for storing computer instructions, the processor for executing at least a portion of the computer instructions to implement any one of the database access methods according to claims 1 to 4.
7. A database access method, executed by a client, comprising: Retrieve database login information; A client request is generated based on the login information in the database; The client request is sent to a computing server through a load balancing server based on a load balancing strategy, so that a database session connection with the corresponding database can be established through the computing server. The load balancing strategy includes round-robin, weight strategy, least connections method or IP address hash strategy. Receive identification information returned by the computing server, the identification information including a database session connection identifier and a server identifier of the computing server to obtain database operation instructions; A client request is generated based on the database operation instructions and the identification information; The client request is sent to a computing server through a load balancer, so that the computing server corresponding to the server identifier can access the corresponding database based on the database operation instructions to obtain the database feedback data. Receiving the feedback data returned by the computing server; wherein, the step of sending the client request to a computing server through a load balancer, so that the computing server corresponding to the server identifier can access the corresponding database based on the database operation instructions to obtain the database feedback data, includes: A computing server determines whether the server identifier matches its own identifier: if they match, it interacts with the corresponding database based on the database operation instructions and returns the database's feedback data to the client; if they do not match, it forwards the client request to the computing server corresponding to the server identifier.
8. The method as described in claim 7, wherein the database login information includes the database's network address and login account information.
9. A database access system, deployed on a client side, comprising: The login information retrieval module is used to retrieve login information from the database. The first client request generation module is used to generate a client request based on the login information in the database. The first client request sending module is used to send the client request to a specific computing server through a load balancing server based on a load balancing strategy, so as to establish a database session connection with the corresponding database through the computing server; wherein, the load balancing strategy includes round-robin, weighted strategy, least connections method, or IP address hash strategy. Sending the client request to the specific computing server through the load balancing server allows the computing server corresponding to the server identifier to access the target database based on the database operation instructions and obtain feedback data from the target database. This includes: the specific computing server determining whether the server identifier matches its own identifier; if they match, it interacts with the corresponding database based on the database operation instructions and returns the database's feedback data to the client; if they do not match, it forwards the client request to the computing server corresponding to the server identifier. The identification information receiving module is used to receive identification information returned by the computing server. The identification information includes a database session connection identifier and a server identifier of the computing server.
10. A database access apparatus, comprising a processor and a storage medium, the storage medium for storing computer instructions, the processor for executing at least a portion of the computer instructions to implement any one of the database access methods according to claims 7-8.
11. A database access method, executed by a client, comprising: Retrieve database operation commands; A client request is generated based on the database operation instructions and identification information; The identification information includes the database session connection identifier with the target database and the corresponding server identifier; The client request is sent to a computing server through a load balancing server based on a load balancing strategy, so that the computing server corresponding to the server identifier can access the target database based on the database operation instructions and obtain the feedback data from the target database; the load balancing strategy includes round-robin, weighted strategy, least connections method or IP address hash strategy; Receive the feedback data returned by the computing server; The step of sending the client request to a specific computing server via a load balancer, so that the computing server corresponding to the server identifier can access the target database based on the database operation instructions to obtain feedback data from the target database, includes: A computing server determines whether the server identifier matches its own identifier: if they match, it interacts with the corresponding database based on the database operation instructions and returns the database's feedback data to the client; if they do not match, it forwards the client request to the computing server corresponding to the server identifier.
12. A database access system, deployed on a client side, comprising: The operation instruction acquisition module is used to acquire database operation instructions; The second client request generation module is used to generate a client request based on the database operation instructions and identification information; The identification information includes the database session connection identifier with the target database and the corresponding server identifier; The second client request sending module is used to send the client request to a specific computing server through a load balancing server based on a load balancing strategy, so that the computing server corresponding to the server identifier can access the target database and obtain feedback data from the target database based on the database operation instructions. The load balancing strategy includes round-robin, weighted strategy, least connections method, or IP address hash strategy. The step of sending the client request to a specific computing server through the load balancing server, so that the computing server corresponding to the server identifier can access the target database and obtain feedback data from the target database based on the database operation instructions, includes: the specific computing server determining whether the server identifier matches its own identifier; if they match, it interacts with the corresponding database based on the database operation instructions and returns the feedback data of that database to the client; if they do not match, it forwards the client request to the computing server corresponding to the server identifier. The feedback data receiving module is used to receive the feedback data returned by the computing server.
13. A database access apparatus, comprising a processor and a storage medium for storing computer instructions, the processor for executing at least a portion of the computer instructions to implement the database access method of claim 11.
Citation Information
Patent Citations
Method and equipment for remaining persistency of security socket layer conversation
CN101296238A