Data loading method and device and storage medium
By creating a multi-layered process structure in the target service, loading hot update data and replacing the service process, the service stability problem during hot data updates is solved, achieving zero interruption and efficient data updates.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TRAVELSKY TECHNOLOGY LIMITED
- Filing Date
- 2025-11-28
- Publication Date
- 2026-04-17
AI Technical Summary
In existing technologies, the service stability is poor when hot data is updated, which can lead to service interruptions and affect users' ability to obtain the latest information.
By creating a multi-layered process structure during the operation of the target service, the first process receives the loading instruction, creates the second target process, loads the hot-update data, and gradually replaces the third original process with the third target process. The third target process shares the dataset, processes user requests, and ensures service stability.
It achieves zero interruption during hot data updates, maintains concurrent performance, and improves service stability and response speed.
Smart Images

Figure CN121880340A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing, and more specifically, to a data loading method, apparatus, and storage medium. Background Technology
[0002] Currently, domestic freight rate data is updated relatively quickly. When processing domestic freight rate data, the domestic freight rate search system first receives the data and saves it to a local data processing server. Then, the data processing service processes the data into a domestic freight rate database file that can be used by the domestic freight rate search system. Once the database file is generated, the data processing service sends a data switching command to the domestic freight rate search system.
[0003] Existing data update methods typically require stopping the service, updating and reloading data files, and then restarting the service. This approach is clearly inadequate when handling frequently accessed data, leading to service interruptions and impacting service stability. For example, in domestic passenger ticket fare search systems, due to frequent changes in fare data (e.g., updates every 5 minutes), traditional shutdown-based update methods would prevent users from accessing the latest fare information during data update periods, thus affecting service stability.
[0004] There is currently no effective solution to the problem of poor service stability during hot data updates in related technologies. Summary of the Invention
[0005] The main objective of this application is to provide a data loading method, apparatus, and storage medium to solve the problem of poor service stability during hot data updates in related technologies.
[0006] To achieve the above objectives, according to one aspect of this application, a data loading method is provided. The method includes: during the operation of a target service, receiving a hot-update data loading instruction through a first process, and creating a second target process based on the first process, wherein the first process also controls a second original process, the second original process being used to load original data and control a third original process, the third original process being used to handle user requests for the target service; loading a target dataset corresponding to the hot-update data using the second target process; after loading the target dataset corresponding to the hot-update data, replacing the third original process with the third target process using the second target process and the second original process, wherein the third target process shares the target dataset loaded by the second target process, and the third target process is used to handle user requests for the target service.
[0007] Furthermore, replacing the service process of the target service from the third original process to the third target process based on the second target process and the second original process includes: creating a third target process using the second target process; after the creation of the third target process is completed, stopping the third original process using the second original process, wherein the third target process and the third original process have the same port number, and the port number is used to provide the service process of the target service.
[0008] Furthermore, creating a third target process using the second target process includes: using the second target process to call a fork function to create a third target process corresponding to the second target process, so that the third target process shares the target dataset loaded by the second target process; establishing a preset connection based on the third target process, binding the preset connection to the port of the service process, and listening on the port based on the preset connection.
[0009] Furthermore, after using the second target process to call the fork function to create a third target process corresponding to the second target process, so that the third target process shares the target dataset loaded by the second target process, the method further includes: using the third target process to create a termination signal handler, wherein the termination signal handler is used to stop the third target process after the third target process receives a stop signal sent by the second target process.
[0010] Furthermore, creating a second target process based on the first process includes: creating a second target process by calling a fork function based on the first process; and establishing a communication channel between the first process and the second target process through a pipe communication function, wherein the communication channel is used by the first process to send a preset notification to the second target process, and the types of preset notifications include creating a third target process and stopping the third target process.
[0011] Furthermore, there are multiple service processes. Replacing the service process of the target service from the third original process with the third target process using the second target process and the second original process includes: creating third target processes one by one using the second target process to obtain multiple third target processes, wherein the number of third target processes is equal to the number of service processes, and the port number of the third target processes is the same as that of the third original process; in the process of creating third target processes one by one using the second target process, the method includes: after each third target process is created, stopping one third original process using the second original process.
[0012] Furthermore, in the process of replacing the service process of the target service from the third original process to the third target process using the second target process and the second original process, the method further includes: receiving a second loading instruction for the second hot update data through the first process, and creating a second replacement process based on the first process; loading the second target dataset corresponding to the second hot update data using the second replacement process; obtaining the progress of replacing the service process of the target service from the third original process to the third target process, and creating a preset number of third replacement processes based on the progress using the second replacement process; replacing the remaining service processes of the target service from the third original process to the third replacement process using the second replacement process and the second original process, wherein the third replacement process is used to handle user requests for the target service.
[0013] To achieve the above objectives, according to another aspect of this application, a data loading apparatus is provided. The apparatus includes: a first creation unit, configured to receive a hot-update data loading instruction through a first process during the operation of a target service, and create a second target process based on the first process, wherein the first process further controls a second original process, the second original process being used to load original data and control a third original process, the third original process being used to handle user requests for the target service; a data loading unit, configured to load a target dataset corresponding to the hot-update data using the second target process; and a process replacement unit, configured to, after loading the target dataset corresponding to the hot-update data, replace the service process of the target service from the third original process with the third target process using the second target process and the second original process, wherein the third target process shares the target dataset loaded by the second target process, and the third target process is used to handle user requests for the target service.
[0014] Furthermore, the process replacement unit includes: a second creation module for creating a third target process using the second target process; and a process stopping module for stopping the third original process using the second original process after the creation of the third target process is completed, wherein the third target process and the third original process have the same port number, and the port number is used to provide the service process for the target service.
[0015] Furthermore, the second creation module includes: a function call submodule, used to create a third target process corresponding to the second target process by calling a forked function from the second target process, so that the third target process can share the target dataset loaded by the second target process; and a connection listening submodule, used to establish a preset connection based on the third target process, bind the preset connection to the port of the service process, and listen on the port based on the preset connection.
[0016] Furthermore, the device also includes: a signal processor creation submodule, used to create a third target process corresponding to the second target process by calling a fork function using the second target process, so that the third target process shares the target dataset loaded by the second target process, and then use the third target process to create a termination signal processor, wherein the termination signal processor is used to stop the third target process after the third target process receives a stop signal sent by the second target process.
[0017] Furthermore, the first creation unit includes: a process creation module, used to create a second target process based on the first process calling a forking function; and a pipe establishment module, used to establish a communication pipe between the first process and the second target process through a pipe communication function, wherein the communication pipe is used by the first process to send a preset notification to the second target process, and the types of preset notifications include creating a third target process and stopping the third target process.
[0018] Furthermore, there are multiple service processes, and the process replacement unit includes: a sequential creation module, used to create third target processes one by one using the second target process to obtain multiple third target processes, wherein the number of third target processes is equal to the number of service processes, and the port number of the third target process is the same as that of the third original process; and a sequential stop module, used to stop one third original process using the second original process after each third target process is created during the process of creating third target processes one by one using the second target process.
[0019] Furthermore, the device also includes: a second instruction receiving module, used to receive a second loading instruction for the second hot update data through the first process during the process of replacing the service process of the target service from the third original process to the third target process using the second target process and the second original process, and to create a second replacement process according to the first process; a second data loading module, used to load the second target dataset corresponding to the second hot update data using the second replacement process; a progress determination module, used to obtain the progress of replacing the service process of the target service from the third original process to the third target process, and to create a preset number of third replacement processes using the second replacement process according to the progress; and a remaining process replacement module, used to replace the remaining service processes of the target service from the third original process to the third replacement process using the second replacement process and the second original process, wherein the third replacement process is used to handle user requests for the target service.
[0020] According to another aspect of this application, a computer-readable storage medium is provided, which includes a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform any data loading method.
[0021] According to another aspect of this application, an electronic device is provided, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include methods for performing any data loading method.
[0022] According to another aspect of this application, a computer program product is provided, including computer instructions that, when executed by a processor, implement the steps of the data loading method described above.
[0023] In this embodiment, during the operation of the target service, a first process receives a hot-update data loading instruction, and a second target process is created based on the first process. The first process also controls a second original process, which is used to load original data and control a third original process, which is used to handle user requests for the target service. The second target process loads the target dataset corresponding to the hot-update data. After loading the target dataset corresponding to the hot-update data, the second target process and the second original process replace the third original process with the third target process for the target service. The third target process shares the target dataset loaded by the second target process and is used to handle user requests for the target service. This solves the technical problem of poor service stability during hot data updates in the prior art. Attached Figure Description
[0024] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0025] Figure 1 A hardware structure block diagram of a computer terminal for implementing a data loading method is shown.
[0026] Figure 2 This is a flowchart of a data loading method provided according to an embodiment of this application;
[0027] Figure 3 This is a schematic diagram of a data loading device provided according to an embodiment of this application;
[0028] Figure 4 This is a structural block diagram of an electronic device according to an embodiment of this application. Detailed Implementation
[0029] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0030] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0031] It should be noted that the information collected in this application (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) are information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of this data all comply with relevant laws, regulations, and standards, necessary confidentiality measures have been taken, and they do not violate public order and good morals. Corresponding access points are provided for users to choose to authorize or refuse. For example, interfaces are set up between this system and relevant users or organizations, providing users with corresponding access points to choose to agree to or refuse automated decision-making results; if the user chooses to refuse, the process proceeds to the expert decision-making stage.
[0032] Example 1
[0033] According to an embodiment of this application, a method embodiment for loading data is also provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0034] The method embodiment provided in Embodiment 1 of this application can be executed on a mobile terminal, computer terminal, or similar computing device. Figure 1 A hardware structure block diagram of a computer terminal (or mobile device) for implementing a data loading method is shown. Figure 1 As shown, the computer terminal 10 (or mobile device) may include one or more processors 102 (shown as 102a, 102b, ..., 102n in the figure) 102 (processor 102 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of a BUS bus), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0035] It should be noted that the aforementioned one or more processors 102 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 10 (or mobile device). As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).
[0036] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the data loading method in this embodiment. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby implementing the above-mentioned data loading method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0037] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0038] The display may be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 10 (or mobile device).
[0039] Under the aforementioned operating environment, this application provides the following: Figure 2 The data loading method shown. Figure 2 This is a flowchart of the data loading method according to Embodiment 1 of this application.
[0040] Step S201: During the operation of the target service, the first process receives the hot update data loading instruction and creates a second target process based on the first process. The first process also controls a second original process. The second original process is used to load the original data and control a third original process. The third original process is used to handle user requests for the target service.
[0041] Optionally, the target service in this embodiment can be a passenger ticket fare search service. The passenger ticket fare search service can be based on an in-memory database. The data stored in the in-memory database includes relational data and non-relational data. In this case, the data storage and loading method differs from that of a traditional relational database. That is, when hot data is updated, data reloading and process restarting are inevitable, leading to service interruption. In this embodiment, a process can be created in the operating system to obtain a first process. The first process, as the first-level process constructed in this embodiment, is used for external communication with the passenger ticket fare search service (i.e., receiving loading instructions for hot-updated data) and controlling the second-level process. The second-level process includes a second original process and a second target process. Different second-level processes are used to load different datasets. The second-level process (e.g., the second target process) is used for loading hot-updated data and controlling the third-level process. The third-level process includes a third original process and a third target process. The third-level process is used to handle user requests for the target service. This embodiment constructs three levels of processes to implement data loading.
[0042] For example, during the operation of the target service, the service provided to users is based on the V1 version dataset. Subsequently, a need arises for hot data updates, updating the service provided to users to the V2 version dataset (i.e., the target dataset described below), and the service update process does not require stopping the target service. The V2 version dataset and the V1 version dataset can have a 5-minute interval, meaning the dataset upon which the target service provides services to users is updated every 5 minutes. The hot data update loading instruction can be an instruction to switch the dataset upon which the target service is based. The first process receives the loading instruction by creating a first thread and receiving the hot data update loading instruction through that first thread.
[0043] Step S202: Load the target dataset corresponding to the hot update data using the second target process.
[0044] For example, the second original process can take 3 minutes to update the target dataset corresponding to the hot-update data. The dataset for the passenger ticket fare search service is usually quite large, and the target dataset can be 500GB in size. The hot-update data is the target dataset, and the hot data update is to switch the dataset on which the target service is based to the target dataset.
[0045] Step S203: After loading the target dataset corresponding to the hot update data, the service process of the target service is replaced by the third target process using the second target process and the second original process. The third target process shares the target dataset loaded by the second target process and is used to handle user requests for the target service.
[0046] Optionally, after the second target process loads the target dataset, it sends a completion message to the first process via a communication pipe. One or more third target processes can be created and controlled based on the second target process, perhaps using the `fork` function, so that each third target process shares all the data in the second target process (i.e., the aforementioned target dataset). The second original process can also control one or more third original processes. The number of third original processes and the number of third target processes depend on the concurrency performance of the target service. If the target service supports 10 concurrent processes, then before step S203, there are 10 second original processes, and after step S203, there are 10 third target processes. During the replacement process in step S203, a second original process can be stopped only after each third target process is created, and the next third target process can be created only after stopping the second original process, to maintain a total of 10 running third original processes and third target processes, ensuring that the performance supporting the aforementioned 10 concurrent processes is not affected.
[0047] For example, step S203, which replaces 10 third-level original processes with 10 third-level target processes, takes 2 minutes in total. At the 1-minute mark, there are still 10 third-level processes used to handle user requests for the target service: 5 third-level original processes and 5 third-level target processes. When the target service needs to process a user request, it can randomly select one of these 10 third-level processes to process it. In step S203, this embodiment does not aim to process every user request with the latest third-level target process. The objective of this embodiment is to ensure that the target service is not interrupted and its concurrency performance is not affected during data loading.
[0048] In summary, by receiving the hot update data loading instruction through the first process during the operation of the target service, and creating a second target process based on the first process, the second target process loads the target dataset corresponding to the hot update data. After loading the target dataset corresponding to the hot update data, the second target process and the second original process replace the third original process with the third target process for the target service. This ensures zero interruption of the target service under the demand for frequent hot data updates, guarantees unaffected concurrent performance, and improves the stability of the target service when loading data in hot data update scenarios by only affecting a single task when a single third-level process crashes.
[0049] To improve service stability during hot data updates, optionally, replacing the service process of the target service from the third original process to the third target process based on the second target process and the second original process includes: creating a third target process using the second target process; and stopping the third original process using the second original process after the creation of the third target process is completed, wherein the third target process and the third original process have the same port number, and the port number is used to provide the service process for the target service.
[0050] For example, the process name of the second original process could be Controller1, and the process name of the second target process could be Controller2. The first process notifies the second target process through a communication pipe to create a third target process. After the third target process is created, the second target process sends a creation completion status to the first process. The first process notifies the second original process through a communication pipe to stop a third original process. After the third original process is stopped, the second original process sends a stop completion status to the first process. The port number corresponding to the third target process is the same (for example, both are port number 6000), that is, the port number of the service process before and after the replacement remains unchanged, to ensure the stability of the target service calling the dataset.
[0051] In summary, based on the second target process and the second original process, the service process of the target service is replaced by the third target process instead of the third original process. This three-layer process mechanism improves the service stability during hot data updates.
[0052] To improve service stability during hot data updates, optionally, creating a third target process using the second target process includes: using the second target process to call a fork function to create a third target process corresponding to the second target process, so that the third target process shares the target dataset loaded by the second target process; establishing a preset connection based on the third target process, binding the preset connection to the port of the service process, and listening on the port based on the preset connection.
[0053] For example, a third target process can be created by calling the fork function (i.e., the fork function) in the second target process. The newly created third target process will automatically share the target dataset loaded in the second target process. This is due to the characteristics of the fork function; the new process (i.e., the third target process) inherits the memory space and open file descriptors of the parent process (i.e., the second target process), including the memory mapping of the dataset. Therefore, the third target process can directly access and use the target dataset without reloading. After the third target process is created, a pre-established connection can be established, which can be a socket connection (i.e., a TCP socket connection), to receive and process client requests. The pre-established connection can be bound to the port of the service process (e.g., port number 6000), and listening on this port can begin. At this point, the third target process will begin receiving user requests sent through this port, thus seamlessly joining the service processing queue and providing the same service interface as before the update.
[0054] In summary, by utilizing the second target process to call the forked function to create the third target process and sharing the target dataset, and through the mechanism of establishing a pre-defined connection and listening on the port, the problem of poor service stability during hot data updates is effectively solved. This achieves zero service interruption and smooth transition in high-frequency data change scenarios, and significantly improves the response speed, strong data consistency and service stability during hot data updates.
[0055] To improve service stability during hot data updates, the method may optionally include, after using the second target process to call the fork function to create a third target process corresponding to the second target process so that the third target process shares the target dataset loaded by the second target process, the method further includes: using the third target process to create a termination signal handler, wherein the termination signal handler is used to stop the third target process after the third target process receives a stop signal sent by the second target process.
[0056] Optionally, a termination signal handler (i.e., a SIGTERM signal handler) can be created using the third target process. This termination signal handler listens for the SIGTERM signal. When the target dataset needs to be switched to a higher version (e.g., version V3) via hot data update, the second target process can send a SIGTERM signal (i.e., a stop signal) to the third target process. When the third target process receives the SIGTERM signal, it marks itself as stopped and finishes execution, cleans up resources, terminates threads, and releases memory, ensuring no unreleased resources are left during the update process. Similarly, before the second target process is created based on the first process, all service processes for the target service are third original processes. These third original processes are managed by the second original process, and they also have their own termination signal handlers. By sending a stop signal from the second original process to the third original process, the third original process can be stopped using the second original process.
[0057] In summary, by introducing a termination signal handler, it can be ensured that during hot data updates, the old third-party original process can be smoothly replaced by the new third-party target process without service interruption or data inconsistency, thus avoiding potential system resource leaks and improving service stability during hot data updates.
[0058] To improve service stability during hot data updates, optionally, creating a second target process based on the first process includes: creating a second target process by calling a fork function based on the first process; and establishing a communication channel between the first process and the second target process through a pipe communication function, wherein the communication channel is used by the first process to send a preset notification to the second target process, and the types of preset notifications include creating a third target process and stopping the third target process.
[0059] Optionally, the first process serves as the control core of the data loading method in this embodiment. The first process creates a second target process by calling a fork function (i.e., the fork function). (The second original process is also created by the first process using the fork function; both the second original process and the second target process are second-level processes.) The first process also establishes a communication pipe by calling the pipe2 function (i.e., the pipe communication function). This communication pipe serves as a communication bridge between the first process and the second target process. Pipe communication is an inter-process communication mechanism that allows the first process to send preset notifications to the second target process.
[0060] For example, the preset notification could be to load target data, create a third target process, or stop the third target process (when a V3 version dataset appears, it will control the second target process to stop the third target process, and the stopping of the aforementioned third original process is controlled by the corresponding second original process), thereby guiding the updating of the dataset and the management of the third target process.
[0061] In summary, by creating a second target process and establishing a communication channel, communication overhead is reduced, a communication foundation is provided for process replacement, and service stability is improved during hot data updates.
[0062] To improve service stability during hot data updates, optionally, the number of service processes can be multiple. Replacing the service process of the target service from the third original process with the third target process using the second target process and the second original process includes: creating third target processes one by one using the second target process to obtain multiple third target processes, wherein the number of third target processes is equal to the number of service processes, and the port number of the third target processes is the same as that of the third original process; in the process of creating third target processes one by one using the second target process, the method includes: after each third target process is created, stopping one third original process using the second original process.
[0063] For example, if there are 10 service processes, meaning the target service has a concurrency of 10, and there were originally 10 original processes (processes 1 through 10), then after creating target process 1, stop target process 10, then create target process 2, and stop target process 2. This process is repeated until target process 10 is created and then stopped. This achieves a smooth, zero-interruption replacement of the service processes. Simultaneously, during this replacement process, the number of running service processes remains at 10, ensuring that the concurrent performance of the service processes does not degrade, avoiding CPU resource contention and resource waste.
[0064] In summary, when there are multiple service processes, by creating third target processes one by one and stopping third original processes one by one, the service of the target service is kept uninterrupted and the concurrent performance is not affected during the data loading process, thus improving the service stability during hot data updates.
[0065] To improve service stability during hot data updates, optionally, in the process of replacing the service process of the target service from the third original process to the third target process using the second target process and the second original process, the method further includes: receiving a second loading instruction for the second hot update data through the first process, and creating a second replacement process based on the first process; loading the second target dataset corresponding to the second hot update data using the second replacement process; obtaining the progress of replacing the service process of the target service from the third original process to the third target process, and creating a preset number of third replacement processes using the second replacement process based on the progress; and replacing the remaining service processes of the target service from the third original process to the third replacement process using the second replacement process and the second original process, wherein the third replacement process is used to handle user requests for the target service.
[0066] For example, the second original process loads the V1 version dataset, and the third original process shares the V1 version dataset with the second original process. When a loading request for the V2 version dataset is received, the second target process loads the V2 version dataset (i.e., the target dataset mentioned above), and the third target process shares the V1 version dataset with the second target process. During the process of replacing the third original process with the third target process, if a loading request for the V3 version dataset is received (i.e., the first process receives the second loading instruction for the second hot-update data), the second replacement process loads the V3 version dataset, and the third replacement process shares the V3 version dataset with the second replacement process. The progress of replacing the third original process with the third target process can be determined first. For example, if the third original process 1 and the third original process 2 have already been replaced with the third target process 1 and the third target process 2 (preset number 2), then two third replacement processes are created first to ensure that concurrency performance does not decrease. Eight third replacement processes remain, and then the third original processes are replaced one by one to achieve a smooth replacement of service processes.
[0067] In summary, by first determining the progress and then replacing each remaining service process based on the target service, the system can receive new loading instructions and perform smooth replacements during the hot data loading update process. This effectively addresses hot data loading in scenarios with frequent data changes and improves service stability during hot data updates.
[0068] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0069] Example 2
[0070] This application also provides a data loading apparatus. It should be noted that the data loading apparatus of this application can be used to execute the data loading method provided in this application. The data loading apparatus provided in this application will be described below.
[0071] According to an embodiment of this application, an apparatus for implementing the above-described data loading method is also provided, such as... Figure 3 As shown, the device includes:
[0072] The first creation unit 301 is used to receive a hot update data loading instruction through a first process during the operation of the target service, and create a second target process based on the first process. The first process also controls a second original process, which is used to load original data and control a third original process. The third original process is used to process user requests for the target service.
[0073] Data loading unit 302 is used to load the target dataset corresponding to the hot update data using the second target process;
[0074] The process replacement unit 303 is used to replace the service process of the target service from the third original process to the third target process after loading the target dataset corresponding to the hot update data, using the second target process and the second original process. The third target process shares the target dataset loaded by the second target process and is used to handle user requests for the target service.
[0075] The data loading apparatus provided in this application embodiment, through a first creation unit 301, receives a hot-update data loading instruction through a first process during the operation of the target service, and creates a second target process based on the first process. The first process also controls a second original process, which is used to load original data and control a third original process. The third original process is used to handle user requests for the target service. The data loading unit 302 uses the second target process to load the target dataset corresponding to the hot-update data. After loading the target dataset corresponding to the hot-update data, the process replacement unit 303 uses the second target process and the second original process to replace the service process of the target service from the third original process to the third target process. The third target process shares the target dataset loaded by the second target process and is used to handle user requests for the target service. This solves the problem of poor service stability during hot data updates in related technologies, thereby improving the verification efficiency of standardization materials.
[0076] Optionally, in the data loading apparatus provided in this application embodiment, the process replacement unit 303 includes: a second creation module, used to create a third target process using a second target process; and a process stopping module, used to stop the third original process using the second original process after the creation of the third target process is completed, wherein the third target process and the third original process have the same port number, and the port number is used to provide the service process of the target service.
[0077] Optionally, in the data loading device provided in this application embodiment, the second creation module includes: a function call submodule, used to create a third target process corresponding to the second target process by calling a forked function using the second target process, so that the third target process shares the target dataset loaded by the second target process; and a connection listening submodule, used to establish a preset connection based on the third target process, bind the preset connection to the port of the service process, and listen to the port based on the preset connection.
[0078] Optionally, in the data loading apparatus provided in the embodiments of this application, the apparatus further includes: a signal processor creation submodule, used to create a third target process corresponding to the second target process by calling a fork function using the second target process, so that the third target process shares the target dataset loaded by the second target process, and then use the third target process to create a termination signal processor, wherein the termination signal processor is used to stop the third target process after the third target process receives a stop signal sent by the second target process.
[0079] Optionally, in the data loading device provided in this application embodiment, the first creation unit 301 includes: a process creation module, used to create a second target process based on the first process calling a forking function; and a pipe establishment module, used to establish a communication pipe between the first process and the second target process through a pipe communication function, wherein the communication pipe is used for the first process to send a preset notification to the second target process, and the type of the preset notification includes creating a third target process and stopping the third target process.
[0080] Optionally, in the data loading device provided in this application embodiment, the number of service processes is multiple, and the process replacement unit 303 includes: a sequential creation module, used to create third target processes one by one using the second target process to obtain multiple third target processes, wherein the number of third target processes is equal to the number of service processes, and the port number of the third target process is the same as that of the third original process; and a sequential stop module, used to stop one third original process using the second original process after each third target process is created during the process of creating third target processes one by one using the second target process.
[0081] Optionally, in the data loading apparatus provided in this application embodiment, the apparatus further includes: a second instruction receiving module, configured to receive a second loading instruction for the second hot update data through a first process during the process of replacing the service process of the target service from the third original process to the third target process using the second target process and the second original process, and to create a second replacement process based on the first process; a second data loading module, configured to load the second target dataset corresponding to the second hot update data using the second replacement process; a progress determination module, configured to obtain the progress of replacing the service process of the target service from the third original process to the third target process, and to create a preset number of third replacement processes using the second replacement process based on the progress; and a remaining process replacement module, configured to replace the remaining service processes of the target service from the third original process to the third replacement process using the second replacement process and the second original process, wherein the third replacement process is used to process user requests for the target service.
[0082] It should be noted that the first creation unit 301, data loading unit 302, and process replacement unit 303 mentioned above correspond to steps S201 to S203 in Embodiment 1. The instances and application scenarios implemented by the units and corresponding steps are the same, but are not limited to the content disclosed in Embodiment 1. It should be noted that the above modules or units can be hardware or software components stored in memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n). The above modules can also be part of a device and run in the computer terminal 10 provided in Embodiment 1.
[0083] Example 3
[0084] Embodiments of this application may provide an electronic device. Figure 4 This is a structural block diagram of an electronic device according to an embodiment of this application. Figure 4 As shown, the electronic device may include: one or more ( Figure 4 (Only one is shown) Processor 402, memory 404, memory controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.
[0085] The memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the methods and apparatus in the embodiments of this application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby implementing the above-described methods. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0086] The processor can access information and applications stored in memory via a transmission device to execute the following steps: During the operation of the target service, a first process receives a loading instruction for hot-update data and creates a second target process based on the first process. The first process also controls a second original process, which is used to load original data and control a third original process, which is used to handle user requests for the target service. The second target process loads the target dataset corresponding to the hot-update data. After loading the target dataset corresponding to the hot-update data, the second target process and the second original process replace the third original process with the third target process for the service process of the target service. The third target process shares the target dataset loaded by the second target process and is used to handle user requests for the target service.
[0087] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: create a third target process using the second target process; after the creation of the third target process is completed, stop the third original process using the second original process, wherein the third target process and the third original process have the same port number, and the port number is used to provide the service process for the target service.
[0088] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: using the second target process to call the fork function to create a third target process corresponding to the second target process, so that the third target process can share the target dataset loaded by the second target process; establishing a preset connection based on the third target process, binding the preset connection to the port of the service process, and listening on the port based on the preset connection.
[0089] The processor can also call information and applications stored in memory via a transmission device to perform the following steps: create a termination signal handler using a third target process, wherein the termination signal handler is used to stop the third target process after the third target process receives a stop signal sent by the second target process.
[0090] The processor can also call information and applications stored in memory through a transmission device to perform the following steps: create a second target process by calling a forking function based on the first process; establish a communication channel between the first process and the second target process through a pipe communication function, wherein the communication channel is used by the first process to send a preset notification to the second target process, and the types of preset notifications include creating a third target process and stopping the third target process.
[0091] The processor can also call information and applications stored in memory through a transmission device to perform the following steps: creating third target processes one by one using the second target processes to obtain multiple third target processes, wherein the number of third target processes is equal to the number of service processes, and the port number of the third target processes is the same as that of the third original processes; in the process of creating third target processes one by one using the second target processes, the method includes: after each third target process is created, stopping one third original process using the second original process.
[0092] The processor can also invoke information and applications stored in memory via a transmission device to perform the following steps: receiving a second loading instruction for the second hot update data through a first process, and creating a second replacement process based on the first process; loading a second target dataset corresponding to the second hot update data using the second replacement process; obtaining the progress of replacing the service process of the target service from the third original process to the third target process, and creating a preset number of third replacement processes based on the progress using the second replacement process; replacing the remaining service processes of the target service from the third original process to the third replacement process using the second replacement process and the second original process, wherein the third replacement process is used to handle user requests for the target service.
[0093] This application provides a data loading scheme. During the operation of the target service, a first process receives a hot-update data loading instruction, and a second target process is created based on the first process. The first process also controls a second original process, which loads original data and controls a third original process, which handles user requests for the target service. The second target process loads the target dataset corresponding to the hot-update data. After loading the target dataset, the second target process and the second original process replace the third original process with the third target process, where the third target process shares the target dataset loaded by the second target process. This solves the technical problem of poor service stability during hot data updates in the prior art.
[0094] Those skilled in the art will understand that Figure 4The structure shown is for illustrative purposes only. Electronic devices can also be smartphones, tablets, handheld computers, mobile internet devices (MIDs), PADs, and other terminal devices. Figure 4 This does not limit the structure of the aforementioned electronic device. For example, electronic devices may also include components that are more... Figure 4 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 4 The different configurations shown.
[0095] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0096] Example 4
[0097] Embodiments of this application also provide a storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the data loading method provided in Embodiment 1.
[0098] Optionally, in this embodiment, the storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.
[0099] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for performing the following steps: during the operation of the target service, a first process receives a loading instruction for hot-update data, and a second target process is created based on the first process. The first process also controls a second original process, which is used to load original data and control a third original process, which is used to handle user requests for the target service. The second target process loads the target dataset corresponding to the hot-update data. After loading the target dataset corresponding to the hot-update data, the second target process and the second original process replace the third original process with the third target process for the service process of the target service. The third target process shares the target dataset loaded by the second target process and is used to handle user requests for the target service.
[0100] Optionally, in this embodiment, the computer-readable storage medium is further configured to store program code for performing the following steps: creating a third target process using the second target process; after the creation of the third target process is completed, stopping the third original process using the second original process, wherein the third target process and the third original process have the same port number, and the port number is used to provide the service process for the target service.
[0101] Optionally, in this embodiment, the computer-readable storage medium is further configured to store program code for performing the following steps: using the second target process to call a forking function to create a third target process corresponding to the second target process, so that the third target process shares the target dataset loaded by the second target process; establishing a preset connection based on the third target process, binding the preset connection to the port of the service process, and listening to the port based on the preset connection.
[0102] Optionally, in this embodiment, the computer-readable storage medium is further configured to store program code for performing the following steps: creating a termination signal handler using a third target process, wherein the termination signal handler is used to stop the third target process after the third target process receives a stop signal sent by the second target process.
[0103] Optionally, in this embodiment, the computer-readable storage medium is further configured to store program code for performing the following steps: creating a second target process based on a forking function called by the first process; establishing a communication channel between the first process and the second target process through a pipe communication function, wherein the communication channel is used for the first process to send a preset notification to the second target process, and the type of the preset notification includes creating a third target process and stopping the third target process.
[0104] Optionally, in this embodiment, the computer-readable storage medium is further configured to store program code for performing the following steps: creating third target processes one by one using the second target processes to obtain multiple third target processes, wherein the number of third target processes is equal to the number of service processes, and the port number of the third target processes is the same as that of the third original processes; in the process of creating third target processes one by one using the second target processes, the method includes: after each third target process is created, stopping one third original process using the second original process.
[0105] Optionally, in this embodiment, the computer-readable storage medium is further configured to store program code for performing the following steps: receiving a second loading instruction for the second hot update data through a first process, and creating a second replacement process based on the first process; loading a second target dataset corresponding to the second hot update data using the second replacement process; obtaining the progress of replacing the service process of the target service from the third original process to the third target process, and creating a preset number of third replacement processes based on the progress using the second replacement process; replacing the remaining service processes of the target service from the third original process to the third replacement process using the second replacement process and the second original process, wherein the third replacement process is used to handle user requests for the target service.
[0106] This application also provides a computer program product that, when executed on a data processing device, is adapted to perform data loading method steps.
[0107] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0108] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0109] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0110] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0111] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0112] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0113] The above description is only a preferred 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 data loading method, characterized in that, include: During the operation of the target service, a first process receives a hot update data loading instruction and creates a second target process based on the first process. The first process also controls a second original process, which is used to load original data and control a third original process. The third original process is used to process user requests for the target service. The target dataset corresponding to the hot update data is loaded using the second target process; After loading the target dataset corresponding to the hot update data, the service process of the target service is replaced by the third target process using the second target process and the second original process. The third target process shares the target dataset loaded by the second target process and is used to process user requests for the target service.
2. The method according to claim 1, characterized in that, Replacing the service process of the target service from the third original process with the third target process based on the second target process and the second original process includes: A third target process is created using the second target process; After the creation of the third target process is completed, the third original process is stopped using the second original process. The third target process has the same port number as the third original process, and the port number is used to provide the service process for the target service.
3. The method according to claim 2, characterized in that, Creating a third target process using the second target process includes: The second target process calls a forking function to create a third target process corresponding to the second target process, so that the third target process shares the target dataset loaded by the second target process; A preset connection is established based on the third target process, the preset connection is bound to the port of the service process, and the port is listened to based on the preset connection.
4. The method according to claim 3, characterized in that, After creating a third target process corresponding to the second target process by calling a forking function using the second target process, so that the third target process shares the target dataset loaded by the second target process, the method further includes: A termination signal handler is created using the third target process, wherein the termination signal handler is used to stop the third target process after the third target process receives a stop signal sent by the second target process.
5. The method according to claim 1, characterized in that, Creating a second target process based on the first process includes: The second target process is created based on the fork function called by the first process; A communication channel is established between the first process and the second target process through a pipe communication function. The communication channel is used by the first process to send a preset notification to the second target process. The types of preset notifications include creating the third target process and stopping the third target process.
6. The method according to claim 1, characterized in that, The number of service processes is multiple, and replacing the service process of the target service from the third original process to the third target process using the second target process and the second original process includes: Using the second target process, third target processes are created one by one to obtain multiple third target processes, wherein the number of third target processes is equal to the number of service processes, and the port number of the third target processes is the same as that of the third original process; In the process of creating third target processes one by one using the second target process, the method includes: After each creation of the third target process, one of the third original processes is stopped using the second original process.
7. The method according to claim 6, characterized in that, In the process of replacing the service process of the target service from the third original process to the third target process using the second target process and the second original process, the method further includes: The first process receives the second loading instruction for the second hot update data and creates a second replacement process based on the first process. The second replacement process is used to load the second target dataset corresponding to the second hot update data; Obtain the progress of replacing the service process of the target service from the third original process to the third target process, and create a preset number of third replacement processes using the second replacement process based on the progress; The remaining service processes of the target service are replaced by the third replacement process using the second replacement process and the second original process. The third replacement process is used to handle user requests for the target service.
8. A data loading device, characterized in that, include: The first creation unit is used to receive a hot update data loading instruction through a first process during the operation of the target service, and to create a second target process based on the first process. The first process also controls a second original process, which is used to load original data and control a third original process, which is used to process user requests for the target service. The data loading unit is used to load the target dataset corresponding to the hot update data using the second target process; The process replacement unit is used to replace the service process of the target service from the third original process to the third target process after loading the target dataset corresponding to the hot update data, using the second target process and the second original process. The third target process shares the target dataset loaded by the second target process and is used to process user requests for the target service.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored executable program, wherein, when the executable program is executed, it controls the device on which the computer-readable storage medium is located to perform the data loading method according to any one of claims 1 to 7.
10. An electronic device, characterized in that, include: Memory, which stores executable programs; A processor for running the program, wherein the program, when running, performs the data loading method according to any one of claims 1 to 7.
11. A computer program product comprising computer instructions, characterized in that, When the computer instructions are executed by the processor, they implement the steps of the data loading method according to any one of claims 1 to 7.