Database switching method and apparatus, computer device, and storage medium
By starting the target module package at the terminal interface to monitor access parameters and switching the database and limiting the rate when the threshold is reached, the security problem caused by improper database switching timing is solved, and the reliability and security of database access are improved.
Patent Information
- Application Number
- CN202210978596.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-16
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2042-08-16
AI Technical Summary
In existing technologies, improper timing of database switching can lead to reduced data security, especially under heavy load conditions. Switching the database too early can cause security problems.
By launching the target module package at N interfaces on the terminal, obtaining access parameters, and switching to the second database when the first threshold is exceeded, and simultaneously launching a rate limiting command when the second threshold is exceeded, the access parameters are dynamically monitored to determine the switching timing, thereby ensuring the reliability and security of the database.
It enables accurate determination of database switchover timing when the load is too high, alleviating the pressure on the primary database, improving the reliability and security of database access, and avoiding the security reduction caused by premature switchover.
Smart Images

Figure CN115328987B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of big data, and in particular to a database switching method, apparatus, computer equipment and storage medium. Background Technology
[0002] Currently, with the rapid development of network equipment technology, network access via terminals has become very common. Among these, database access is an important component of network access, and the security and stability of the database access process are of paramount importance.
[0003] In related technologies, the database's load capacity determines the minimum load capacity in a network access project. Generally, a database system consists of a master database and several slave databases. The master database is used for updating and querying data when accessed from the terminal. Under excessive load, the pressure on the master database can be reduced by switching databases.
[0004] However, switching databases at the wrong time (e.g., switching databases too early) may lead to reduced data security. Summary of the Invention
[0005] This invention provides a database switching method, apparatus, computer equipment, and storage medium that can improve the reliability and security of database switching.
[0006] To solve the above-mentioned technical problems, one technical solution adopted by the embodiments of the present invention is: providing a database switching method, comprising: when a terminal wants to initiate data access at N interfaces of a first database, starting and running N programs corresponding to the N interfaces of a target module package, obtaining access parameters of the N access interfaces of the terminal corresponding to the first database, wherein the N programs correspond one-to-one with the N interfaces; when the access parameters corresponding to the target interface exceed a first threshold, switching the first database corresponding to the target interface to a second database, wherein the target interface is at least one of the N interfaces, the first database and the second database are different databases, the first threshold corresponds to the access pressure threshold of the first database, and the access pressure threshold is the maximum access threshold that the first database can withstand.
[0007] Optionally, after switching the first database corresponding to the target interface to the second database, the method further includes: when the access parameters of the terminal on the N interfaces exceed a second threshold, initiating a terminal access rate limiting instruction, wherein the second threshold is greater than the first threshold, and the terminal access rate limiting instruction is used to: indicate the restriction of the terminal's access requests on the N interfaces.
[0008] Optionally, when the terminal wants to initiate data access at N interfaces of the first database, starting and running the N programs corresponding to the N interfaces of the target module package to obtain the access parameters of the N access interfaces corresponding to the first database includes: when the terminal wants to initiate data access at the N interfaces of the first database, starting the target module package corresponding to the first database; sending an instruction to the terminal to agree to access the first database; and obtaining the access parameters of the N access interfaces corresponding to the first database according to the running results of the N programs corresponding to the N interfaces of the target module package.
[0009] Optionally, when the terminal wants to initiate data access at N interfaces of the first database, before starting and running the N programs corresponding to the N interfaces to obtain the access parameters of the N access interfaces corresponding to the first database, the method further includes: inserting the target module package into the access program of the server corresponding to the first database.
[0010] Optionally, inserting the target module package into the access program of the server corresponding to the first database includes: inserting the target program corresponding to the target module package into the running program corresponding to the first database; and adding target annotations to the target program fields corresponding to the target program in the running program corresponding to the first database.
[0011] Optionally, the step of starting and running the target module package corresponding to the N programs at the N interfaces of the first database when the terminal wants to start data access includes: when the terminal wants to start data access at the N interfaces of the first database, reading the target annotation in the first database; and starting and running the target module package corresponding to the N programs at the N interfaces according to the target annotation.
[0012] Optionally, the startup and execution of the target module package includes the N programs corresponding to the N interfaces, including: starting and running the aspect programming corresponding to the target program, wherein the aspect programming is used to: trigger the server to run the N programs for the N interfaces.
[0013] To address the aforementioned technical problems, this invention also provides a database switching device, comprising: an acquisition module, configured to, when a terminal intends to initiate data access at N interfaces of a first database, launch and run N programs corresponding to the N interfaces of a target module package, and acquire access parameters of the N access interfaces of the terminal corresponding to the first database, wherein the N programs correspond one-to-one with the N interfaces; and a switching module, configured to, when the access parameters corresponding to the target interface acquired by the acquisition module exceed a first threshold, switch the first database corresponding to the target interface to a second database, wherein the target interface is at least one of the N interfaces, the first database and the second database are different databases, and the first threshold corresponds to an access pressure threshold of the first database, wherein the access pressure threshold is the maximum access threshold that the first database can withstand.
[0014] Optionally, the device further includes a startup module, which is configured to initiate a terminal access rate limiting instruction when the access parameters of the terminal on the N interfaces exceed a second threshold, wherein the second threshold is greater than the first threshold, and the terminal access rate limiting instruction is used to: indicate the restriction of the terminal's access requests on the N interfaces.
[0015] Optionally, the device further includes: a startup module, configured to start a target module package corresponding to the first database when the terminal wants to initiate data access at N interfaces of the first database; a sending module, configured to send an indication message to the terminal agreeing to access the first database; and an acquisition module, specifically configured to acquire access parameters of the N access interfaces corresponding to the first database based on the running results of the target module package in the N programs corresponding to the N interfaces.
[0016] Optionally, the apparatus further includes an insertion module for inserting a target module package into the access program of the server corresponding to the first database.
[0017] Optionally, the apparatus further includes: the insertion module, specifically configured to insert the target program corresponding to the target module package into the running program corresponding to the first database; and the addition module, configured to add target annotations to the target program fields corresponding to the target program inserted by the insertion module in the running program corresponding to the first database.
[0018] Optionally, the device further includes: a reading module, configured to read target annotations from the first database when the terminal intends to initiate data access at N interfaces of the first database; and a startup module, configured to start and run the N programs corresponding to the N interfaces of the target module package based on the target annotations read by the reading module.
[0019] Optionally, the device further includes: a startup module, used to start and run the aspect programming corresponding to the target program, wherein the aspect programming is used to: trigger the server to run N programs for the N interfaces.
[0020] To address the aforementioned technical problems, this invention also provides a computer device, including a memory and a processor. The memory stores computer-readable instructions, which, when executed by the processor, cause the processor to perform the steps of the database switching method described above.
[0021] To address the aforementioned technical problems, this embodiment of the invention also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the database switching method described above.
[0022] The beneficial effects of this invention are as follows: When a terminal needs to access data at N interfaces of the first database, the network device will launch and run the N programs corresponding to the N interfaces in the target module package. This allows the network device to obtain the access parameters of the N interfaces corresponding to the first database during the terminal's access process (the N programs correspond one-to-one with the N interfaces). If the access parameters of at least one of the N interfaces exceed a first threshold, the network device will switch the first database corresponding to the target interface to a second database different from the first database. This allows the terminal to access the data content previously required by the target interface through the second database. In this way, the network device monitors the terminal's access parameters at the N interfaces through the target module package. When the access parameters of the target interface reach a predetermined threshold, the network device switches the database of the target interface. Furthermore, by dynamically monitoring the access parameters of multiple interfaces and flexibly switching some or all monitored interfaces according to the actual access situation, and because the predetermined threshold corresponds to the maximum data pressure that the database can actually bear, the timing of database switching can be accurately determined. This not only alleviates the pressure on the main database and improves the reliability of database access, but also balances the security of database access. Attached Figure Description
[0023] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0024] Figure 1 This is a basic flowchart of a database switching method according to a specific embodiment of the present invention;
[0025] Figure 2 This is a schematic diagram of the basic structure of a database switching device according to an embodiment of the present invention;
[0026] Figure 3 This is a basic structural block diagram of a computer device according to an embodiment of the present invention. Detailed Implementation
[0027] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.
[0028] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the word “comprising” as used in the specification of this application means the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0029] It will be understood by those skilled in the art that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have the same meaning as in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless specifically defined as herein.
[0030] Those skilled in the art will understand that the term "terminal" as used herein includes both devices that are wireless signal receivers, devices that are wireless signal receivers without transmitting capability, and devices with receiving and transmitting hardware, having receiving and transmitting hardware capable of performing bidirectional communication on a bidirectional communication link. Such devices may include: cellular or other communication devices having a single-line display, a multi-line display, or a cellular or other communication device without a multi-line display; PCS (Personal Communications Service) that can combine voice, data processing, fax, and / or data communication capabilities; PDA (Personal Digital Assistant) that may include a radio frequency receiver, pager, Internet / intranet access, web browser, notepad, calendar, and / or GPS (Global Positioning System) receiver; and conventional laptop and / or handheld computers or other devices that have and / or include a radio frequency receiver. As used herein, "terminal" can be portable, transportable, installed in a means of transportation (air, sea, and / or land), or suitable and / or configured to operate locally, and / or in a distributed manner, operating in any other location on Earth and / or in space. "Terminal" as used herein can also be a communication terminal, an internet access terminal, or a music / video playback terminal, such as a PDA, a MID (Mobile Internet Device), and / or a mobile phone with music / video playback capabilities, or a smart TV, set-top box, etc.
[0031] Please see Figure 1 , Figure 1 This is a basic flowchart of the database switching method provided in this embodiment, applied to a network device, including steps 201 and 202:
[0032] Step 201: When the terminal wants to initiate data access at one of the N interfaces of the first database, the network device starts and runs the N programs corresponding to the N interfaces of the target module package to obtain the access parameters of the N access interfaces of the terminal corresponding to the first database.
[0033] In this embodiment of the application, the above N programs correspond one-to-one with N interfaces.
[0034] In this embodiment of the application, the above-mentioned N access interfaces are the access interfaces of the above-mentioned terminal in the above-mentioned first database.
[0035] It should be noted that terminal access to database interfaces can include various types, such as query interfaces, add interfaces, and modify interfaces. There is no limit to the number of each type of interface a terminal can use when accessing a single database.
[0036] In this embodiment of the application, the above N interfaces are query interfaces when the terminal accesses the database.
[0037] In this embodiment of the application, the terminal may initiate data access on the N interfaces of the first database by sending an access request to the database to a network device (e.g., a server), and the network device has not yet accepted the access request.
[0038] In this embodiment, the target module package is a module package pre-stored in a server within a program used to handle terminal access to the database. For example, the program corresponding to the target module package is inserted into the program used to handle terminal access to the database on the server.
[0039] In this embodiment, the target module package can be user-defined or pre-stored by the network device, for example, it can be user-defined by the network device. This embodiment does not limit this.
[0040] In one example, the target module package mentioned above can be a target proxy class, such as a Jar package named Sentinel Dababase.jar.
[0041] In this embodiment of the application, the target module package includes a target program, which will be started and run when the terminal accesses the database.
[0042] Furthermore, the aforementioned target program is a network device layer program, applicable to all databases.
[0043] In this embodiment of the application, the target program described above will generate aspect-oriented programming when it starts running.
[0044] It is understandable that the aforementioned aspect-oriented programming refers to inserting the program corresponding to the target module package into the relevant program that handles terminal access to the database. This aspect-oriented programming enables the server to run the program corresponding to the target module package when the N interfaces of the first database are accessed by the terminal, that is, to run N programs on N interfaces, and in other words, all N programs are triggered by running the aforementioned target module package.
[0045] Optionally, in this embodiment, the target module in step 201 is included in the N programs corresponding to the N interfaces. The database switching method provided in this embodiment includes the following step A:
[0046] Step A: The network device starts and runs the aspect programming corresponding to the target program mentioned above.
[0047] For example, the aspect programming described above is used to trigger the server to run N programs for the N interfaces described above.
[0048] It is understandable that the aforementioned target module package will trigger the generation of this aspect programming when it starts up and runs. This aspect programming can intervene in the operation of N interfaces, that is, a program runs at each of the N interfaces, with N interfaces corresponding to N programs, in order to monitor the access parameters of the N interfaces.
[0049] In this way, by starting and running the aspect-oriented programming method corresponding to the above target program, the N interfaces of the terminal accessing the database can be monitored, thereby ensuring the reliability of the statistical access parameters and maximizing the security of data access when switching databases in the future.
[0050] Step 202: If the access parameters corresponding to the target interface exceed the first threshold, the network device switches the first database corresponding to the target interface to the second database.
[0051] In this embodiment of the application, the target interface is at least one of N interfaces, and the first database and the second database are different databases.
[0052] In this embodiment of the application, the target interface may be some or all of the N interfaces, and this embodiment of the application does not limit this.
[0053] In this embodiment of the application, the access parameters mentioned above can be parameters related to the terminal accessing the first database, such as the number of accesses.
[0054] In this embodiment of the application, the first threshold can be preset by the network device or set by the user; this embodiment of the application does not limit it.
[0055] In this embodiment of the application, the first threshold corresponds to the access parameter. For example, when the access parameter is the number of accesses, the first threshold corresponds to the threshold of the number of accesses.
[0056] In this embodiment of the application, the first threshold corresponds to the pressure threshold of the first database.
[0057] It is understood that the first threshold mentioned above represents the access pressure borne by the first database, and the access pressure threshold mentioned above represents the maximum access threshold that the first database can withstand.
[0058] In this embodiment of the application, the first database is the master database and the second database is the slave database.
[0059] Furthermore, the aforementioned second database may include one or more databases.
[0060] In this embodiment of the application, there is a network connection between the first database and the second database.
[0061] In one embodiment, the server can set a first threshold for the access parameters of N interfaces of the first database. If the access parameters of a target interface among the N interfaces exceed the first threshold, the target interface used by the terminal to access is switched from the first database to the second database.
[0062] Example 1: The server pre-sets the access limit for each query interface in the first database to be 10 times / microsecond. When the first database is accessed by a terminal, including three query interfaces (query interface 1, query interface 2, and query interface 3), if the access count of query interface 1 and query interface 2 both exceed 10 times / microsecond, then the database corresponding to query interface 1 and query interface 2 will be switched from the first database to the second database.
[0063] Furthermore, when there are multiple second databases, the network device can poll and switch the target interface among the multiple second databases. This application embodiment does not limit this.
[0064] In the database switching method provided in this application embodiment, when a terminal needs to access data at N interfaces of a first database, the network device will launch and run N programs corresponding to the N interfaces in the target module package. This allows the network device to obtain the access parameters of the N interfaces corresponding to the first database during the terminal's access (the N programs correspond one-to-one with the N interfaces). If the access parameters of at least one of the N interfaces exceed a first threshold, the network device will switch the first database corresponding to the target interface to a second database different from the first database. This allows the terminal to access the data content previously required by the target interface through the second database. Thus, the network device monitors the terminal's access parameters at the N interfaces through the target module package. When the access parameters of the target interface reach a predetermined threshold, the network device switches the database of the target interface. Furthermore, by dynamically monitoring the access parameters of multiple interfaces and flexibly switching some or all monitored interfaces based on actual access conditions, and because the predetermined threshold corresponds to the maximum data pressure that the database can actually bear, the timing of database switching can be accurately determined. This not only alleviates the pressure on the main database and improves the reliability of database access, but also balances the security of database access.
[0065] Optionally, in this embodiment of the application, after step 202 above, the database switching method provided in this embodiment of the application further includes the following step B:
[0066] Step B: If the access parameters of the above-mentioned terminal on the above-mentioned N interfaces exceed the second threshold, initiate the terminal access rate limiting instruction.
[0067] For example, if the second threshold is greater than the first threshold, the terminal access rate limiting instruction is used to: instruct the terminal to restrict access requests on the N interfaces.
[0068] In this embodiment of the application, the second threshold can be preset by the network device or set by the user; this embodiment of the application does not limit it.
[0069] In this embodiment of the application, the second threshold corresponds to the access parameter. For example, when the access parameter is the number of accesses, the second threshold corresponds to the threshold of the number of accesses.
[0070] In this embodiment of the application, the access parameters defined by the second threshold are the access parameters corresponding to the N interfaces of the terminal as a whole, that is, the sum of the access parameters of the N interfaces is compared with the second threshold.
[0071] Example 2: Combining with Example 1 above, if the server pre-sets the access limit for all query interfaces in the first database to be 30 times / microsecond, after the database corresponding to query interface 1 and query interface 2 is switched from the first database to the second database, if the total access count of query interface 1, query interface 2, and query interface 3 is 30 times / microsecond, the server will send an access rate limiting command to the terminal to limit the terminal's access.
[0072] In this way, by setting a second threshold, the network device monitors the access parameters of N interfaces by launching the target module package. If the second threshold is exceeded, the rate is limited in time. This ensures normal access for users to the greatest extent possible while maintaining server stability and avoiding server "avalanche" phenomena to the greatest extent.
[0073] Optionally, in this embodiment of the application, in step 201 above, the database switching method provided by this embodiment of the application includes the following steps C1 to C3:
[0074] Step C1: When the terminal wants to initiate data access at one of the N interfaces of the first database, the network device starts the target module packet corresponding to the first database.
[0075] Step C2: The network device sends an instruction to the terminal to grant access to the aforementioned first database.
[0076] Step C3: The network device obtains the access parameters of the N access interfaces corresponding to the first database based on the running results of the N programs corresponding to the N interfaces of the target module package.
[0077] For example, the network device accepts the terminal's access request to access the first database and sends an instruction message to the terminal agreeing to access the first database.
[0078] For example, the target module package described above can be referred to the foregoing description, and will not be repeated here.
[0079] In this embodiment of the application, the network sends an instruction message to the terminal to agree to access the first database in order to formally initiate the terminal's access to the database. That is, when the network device sends the instruction message to the terminal to agree to access the first database, the N interfaces will generate the terminal's access data. The network device will run the N programs corresponding to the N interfaces by running the target module, obtain the running results, and then obtain the access parameters of the N access interfaces corresponding to the first database.
[0080] In this embodiment of the application, the above-mentioned running results include the access parameters of the N access interfaces corresponding to the first database.
[0081] In this way, by setting the target module package, the network device can start the monitoring program before the terminal officially accesses the first database, so that the access parameters of N interfaces can be monitored comprehensively and accurately in the future, thereby improving the efficiency of terminal access to the database while ensuring the stability of the database.
[0082] Optionally, in this embodiment of the application, before step 201 above, the database switching method provided in this embodiment of the application includes the following step D:
[0083] Step D: The network device inserts the target module package into the access program of the server corresponding to the first database.
[0084] It is understandable that the aforementioned target module package can be a monitoring program that can be inserted into the access program corresponding to the first database server. For example, the aforementioned monitoring program can be Java code.
[0085] It should be noted that the above monitoring program is compatible with the access program of the server corresponding to the first database. It does not substantially change the access program of the server corresponding to the first database; it merely adds a monitoring function to the access program.
[0086] Thus, by inserting a compatible target module package into the access program of the server corresponding to the first database, the access program can be reasonably expanded without substantially changing the access program. As a result, when the terminal accesses the database in the future, not only can the efficiency of accessing the database be improved, but the stability of the database can also be guaranteed.
[0087] Optionally, in this embodiment of the application, in step C above, the database switching method provided by this embodiment of the application includes the following steps E1 and E2:
[0088] Step E1: The network device inserts the target program corresponding to the target module package into the running program corresponding to the first database.
[0089] Step E2: In the running program corresponding to the first database, the network device adds target annotations to the target program fields corresponding to the target program.
[0090] For example, the target program described above can be a program used to monitor N interfaces when a terminal accesses a database.
[0091] For example, the above target annotation can prompt the network device to run the target program first when the terminal wants to initiate data access on N interfaces of the first database.
[0092] For example, the above target annotations can be user-defined or preset by the network device, and the application embodiments do not limit this.
[0093] For example, if the target module package is a Jar file named Sentinel Dababase.jar, then its annotation can be: @SentinelDababase
[0094] Optionally, in this embodiment of the application, when the terminal initiates data access on N interfaces of the first database in step 201 above, the target module package is launched and run in the N programs corresponding to the N interfaces. The database switching method provided in this embodiment of the application includes the following steps E1 and E2:
[0095] Step F1: When the terminal initiates data access on N interfaces of the first database, the network device reads the target annotations in the first database.
[0096] Step F2: The network device starts and runs the N programs corresponding to the N interfaces of the above target module package according to the above target annotation.
[0097] Thus, before the terminal actually starts accessing the database, the network device reads the above target annotations and runs the N programs corresponding to the above N interfaces of the target module package. This ensures that the access parameters are not missed after the terminal actually starts accessing the database, thereby guaranteeing the accuracy of the access parameters.
[0098] To address the aforementioned technical problems, embodiments of the present invention also provide a database switching device. Please refer to [link / reference needed] for details. Figure 2 , Figure 2 This is a schematic diagram of the basic structure of the database switching device in this implementation.
[0099] like Figure 2 As shown, a database switching device includes: an acquisition module 301, configured to, when a terminal intends to initiate data access at N interfaces of a first database, launch and run N programs corresponding to the N interfaces of the target module package to acquire access parameters of the N access interfaces of the terminal corresponding to the first database, wherein the N programs correspond one-to-one with the N interfaces; and a switching module 302, configured to, when the access parameters corresponding to the target interface acquired by the acquisition module 301 exceed a first threshold, switch the first database corresponding to the target interface to a second database, wherein the target interface is at least one of the N interfaces, the first database and the second database are different databases, the first threshold corresponds to the access pressure threshold of the first database, and the access pressure threshold is the maximum access threshold that the first database can withstand.
[0100] When a terminal needs to access data at N interfaces of the first database, the database switching device will launch and run the N programs corresponding to the N interfaces in the target module package. This allows the device to obtain the access parameters of the N interfaces corresponding to the first database during the terminal's access (the N programs correspond one-to-one with the N interfaces). If the access parameters of at least one of the N interfaces exceed a first threshold, the database switching device will switch the first database corresponding to the target interface to a second database different from the first database. This allows the terminal to access the data content previously accessed by the target interface through the second database. In this way, the database switching device monitors the terminal's access parameters at the N interfaces through the target module package. When the access parameters of the target interface reach a predetermined threshold, the database for the target interface is switched. Furthermore, by dynamically monitoring the access parameters of multiple interfaces and flexibly switching some or all monitored interfaces based on actual access conditions, and because the predetermined threshold corresponds to the maximum data pressure that the database can actually handle, the timing of database switching can be accurately determined. This not only alleviates the pressure on the main database and improves the reliability of database access, but also balances the security of database access.
[0101] In some embodiments, the device further includes a startup module, which is configured to initiate a terminal access rate limiting instruction when the access parameters of the terminal on the N interfaces exceed a second threshold, wherein the second threshold is greater than the first threshold, and the terminal access rate limiting instruction is used to: indicate the restriction of the terminal's access requests on the N interfaces.
[0102] In some embodiments, the apparatus further includes: a startup module, configured to start a target module package corresponding to the first database when the terminal intends to initiate data access at N interfaces of the first database; a sending module, configured to send an indication message to the terminal agreeing to access the first database; and an acquisition module, specifically configured to acquire access parameters of the N access interfaces corresponding to the first database based on the running results of the target module package in the N programs corresponding to the N interfaces.
[0103] In some embodiments, the apparatus further includes an insertion module for inserting a target module package into the access program of the server corresponding to the first database.
[0104] In some embodiments, the apparatus further includes: the insertion module, specifically configured to insert the target program corresponding to the target module package into the running program corresponding to the first database; and the addition module, configured to add target annotations to the target program fields corresponding to the target program inserted by the insertion module in the running program corresponding to the first database.
[0105] In some embodiments, the apparatus further includes: a reading module, configured to read target annotations from the first database when the terminal intends to initiate data access at N interfaces of the first database; and a startup module, configured to start and run the N programs corresponding to the N interfaces of the target module package based on the target annotations read by the reading module.
[0106] In some embodiments, the apparatus further includes a startup module for initiating and running aspect programming corresponding to the target program, wherein the aspect programming is used to trigger the server to run N programs for the N interfaces.
[0107] To address the aforementioned technical problems, embodiments of the present invention also provide a computer device. Please refer to [link / reference needed]. Figure 3 , Figure 3 This is a basic structural block diagram of the computer device in this embodiment.
[0108] like Figure 3The diagram shows the internal structure of a computer device. The computer device includes a processor, non-volatile storage medium, memory, and a network interface connected via a system bus. The non-volatile storage medium stores the operating system, database, and computer-readable instructions. The database may store control information sequences. When the computer-readable instructions are executed by the processor, they enable the processor to implement a data relationship reconstruction method. The processor provides computing and control capabilities, supporting the operation of the entire computer device. The memory stores computer-readable instructions, which, when executed by the processor, enable the processor to implement a data relationship reconstruction method. The network interface of the computer device is used for communication with a terminal. Those skilled in the art will understand that… Figure 3 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.
[0109] In this embodiment, the processor is used to execute... Figure 2 The specific functions of module 301 and switching module 302 are obtained in the memory, which stores the program code and various types of data required to execute the above modules. The network interface is used for data transmission between the user terminal and the server. In this embodiment, the memory stores the program code and data required to execute all sub-modules in the data relationship reconstruction device, and the server can call the server's program code and data to execute the functions of all sub-modules.
[0110] Computer equipment constructs node feature maps and corresponding adjacency matrices from the data relationships between collected transaction nodes. A graph neural network (Graph Neural Network) is then used to extract features from these maps and matrices. Based on the extracted features, relationships are reconstructed. During this reconstruction, the Graph Neural Network reconstructs the data based on the learned hidden logical relationships between the data nodes. This process of reconstructing relationships is essentially the restoration of the data node feature maps and adjacency matrices. By disassembling and reassembling the data node feature maps and adjacency matrices, the Graph Neural Network verifies the correctness of the learned hidden relationships between transaction nodes. Then, it uses these learned hidden relationships to reconstruct the relationships between each transaction node and selects target transaction nodes that meet certain criteria for further application. Through graph processing technology, it deeply interprets the logical relationships behind the data, improving the depth and efficiency of data analysis.
[0111] The present invention also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the data relationship reconstruction method of any of the above embodiments.
[0112] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, optical disk, or read-only memory (ROM), or random access memory (RAM).
[0113] The present invention also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the data relationship reconstruction method of any of the above embodiments.
[0114] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, optical disk, or read-only memory (ROM), or random access memory (RAM).
[0115] Those skilled in the art will understand that the steps, measures, and solutions in the various operations, methods, and processes discussed in this application can be alternated, modified, combined, or deleted. Furthermore, other steps, measures, and solutions in the various operations, methods, and processes discussed in this application can also be alternated, modified, rearranged, decomposed, combined, or deleted. Furthermore, steps, measures, and solutions in the prior art that are similar to those disclosed in this application can also be alternated, modified, rearranged, decomposed, combined, or deleted.
[0116] The above description is only a partial embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A database switching method, applied to network devices, characterized in that, The method includes: When a terminal wants to initiate data access at N interfaces of the first database, the target module package is launched and run in N programs corresponding to the N interfaces to obtain the access parameters of the N access interfaces of the terminal in the first database. The N programs correspond one-to-one with the N interfaces. If the access parameters corresponding to the target interface exceed the first threshold, the first database corresponding to the target interface is switched to the second database. The target interface is at least one of N interfaces. The first database and the second database are different databases. The first threshold corresponds to the access pressure threshold of the first database. The access pressure threshold is the maximum access threshold that the first database can withstand. The first database is the master database, and the second database is the slave database. The second database includes one or more databases. The first threshold is the access parameter setting of the N interfaces of the first database. After switching the first database corresponding to the target interface to the second database, the method further includes: When the access parameters of the terminal on the N interfaces exceed the second threshold, a terminal access rate limiting instruction is initiated. The second threshold is greater than the first threshold. The terminal access rate limiting instruction is used to: indicate that the access requests of the terminal on the N interfaces are restricted. The second threshold is set by the access parameters corresponding to the N interfaces of the terminal as a whole. When a terminal wants to initiate data access at one of the N interfaces of the first database, the target module package is launched and run in the N programs corresponding to the N interfaces to obtain the access parameters of the terminal at the N access interfaces corresponding to the first database, including: When the terminal wants to initiate data access at one of the N interfaces of the first database, the target module package corresponding to the first database is launched. Send an instruction message to the terminal granting permission to access the first database; Based on the execution results of the N programs corresponding to the N interfaces of the target module package, the access parameters of the N access interfaces corresponding to the first database of the terminal are obtained.
2. The method according to claim 1, characterized in that, When a terminal intends to initiate data access at one of the N interfaces of the first database, before starting and running the N programs corresponding to the N interfaces and obtaining the access parameters of the N access interfaces corresponding to the first database, the method further includes: Insert the target module package into the access program of the server corresponding to the first database.
3. The method according to claim 2, characterized in that, The step of inserting the target module package into the access program of the server corresponding to the first database includes: Insert the target program corresponding to the target module package into the running program corresponding to the first database; In the running program corresponding to the first database, target annotations are added to the target program fields corresponding to the target program.
4. The method according to claim 3, characterized in that, When the terminal wants to initiate data access at N interfaces of the first database, the target module package is launched and run in N programs corresponding to the N interfaces, including: When the terminal wants to initiate data access at one of the N interfaces of the first database, it reads the target annotation in the first database. Based on the target annotation, start and run the N programs corresponding to the N interfaces of the target module package.
5. The method according to claim 1, characterized in that, The target module package for startup and execution is comprised of the N programs corresponding to the N interfaces, including: Initiate and run the aspect programming corresponding to the target program, wherein the aspect programming is used to: trigger the server to run N programs for the N interfaces.
6. A database switching device, characterized in that, include: The acquisition module is used to start and run the target module package corresponding to the N programs at the N interfaces of the first database when the terminal wants to initiate data access. The target module package is used to acquire the access parameters of the N access interfaces of the terminal corresponding to the first database. The N programs correspond one-to-one with the N interfaces. A switching module is used to switch the first database corresponding to the target interface to a second database when the access parameters corresponding to the target interface obtained by the acquisition module exceed a first threshold. The target interface is at least one of N interfaces. The first database and the second database are different databases. The first threshold corresponds to the access pressure threshold of the first database. The access pressure threshold is the maximum access threshold that the first database can withstand. The first database is the master database, and the second database is the slave database. The second database includes one or more databases. The first threshold is set by the access parameters of the N interfaces of the first database. The startup module is used to initiate a terminal access rate limiting instruction when the access parameters of the terminal on the N interfaces exceed a second threshold. The second threshold is greater than the first threshold. The terminal access rate limiting instruction is used to: indicate that the access requests of the terminal on the N interfaces are restricted. The second threshold is set by the access parameters corresponding to the N interfaces of the terminal as a whole. The acquisition module is specifically used to start the target module package corresponding to the first database when the terminal wants to start data access at N interfaces of the first database; Send an instruction message to the terminal granting permission to access the first database; Based on the execution results of the N programs corresponding to the N interfaces of the target module package, the access parameters of the N access interfaces corresponding to the first database of the terminal are obtained.
7. A computer device, characterized in that, The system includes a memory and a processor, wherein the memory stores computer-readable instructions that, when executed by the processor, cause the processor to perform the steps of the database switching method as claimed in any one of claims 1 to 5.
8. A storage medium storing computer-readable instructions, characterized in that, When the computer-readable instructions are executed by one or more processors, the one or more processors perform the steps of the database switching method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Method and device for deploying a plurality of applications in multi-instance database service
CN109753292A
ORM-based database monitoring method and system, server and storage medium
CN111078501A
Flow control method and device, electronic equipment and storage medium
CN111262791A
Database connection switching method and device, equipment and medium
CN112000738A