A method and system for dynamically configuring variables
By storing the information of new variables in the CDN by applying for memory, the problem of being unable to use new variables when dynamically loading domain name configuration items is solved, achieving normal use of new variables and improving data synchronization efficiency.
Patent Information
- Application Number
- CN202110062593.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-18
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2041-01-18
AI Technical Summary
The existing variable maintenance method cannot use new variables normally when dynamically loading domain name configuration items, causing abnormalities in the domain name acceleration process.
Store the information of new variables in variable hash tables and variable arrays by applying for memory, record the used memory size and requested memory size of each hash bucket and array, and update this information when new variables are introduced to ensure The new variable can be used normally.
It realizes normal use after introducing new variables in CDN, improves the storage and synchronization efficiency of variable data, and avoids abnormal situations during domain name acceleration.
Smart Images

Figure CN114866413B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of Internet technology, and in particular to a method and system for dynamically configuring variables. Background Art
[0002] In CDN (Content Delivery Network), acceleration services can be provided for domain names through proxy servers.
[0003] In order to use variables normally when dynamically loading domain name configuration items, a variable hash table can be established. In this way, the corresponding variable value can be obtained through the loaded variable name.
[0004] However, the existing variable maintenance method can usually only use built-in variables or custom variables that have been defined, but cannot use new variables. In actual applications, when dynamically loading domain name configuration items, new variables are likely to be introduced. If these new variables cannot be used normally, the domain name acceleration process will be abnormal. Summary of the invention
[0005] The purpose of this application is to provide a method and system for dynamically configuring variables, which can use new variables normally.
[0006] To achieve the above-mentioned purpose, the present application provides, on the one hand, a method for dynamically configuring variables, which is applied to a main process, and includes: parsing variable configuration information, and recording memory information corresponding to variable data according to the variable configuration information; when a configuration update request is received, if the configuration update request introduces a new variable, writing data related to the new variable into the variable data, and updating the memory information of the variable data after the introduction of the new variable.
[0007] To achieve the above-mentioned purpose, the present application also provides a system for dynamically configuring variables, the system comprising: an information recording unit, used to parse variable configuration information, and record memory information corresponding to variable data according to the variable configuration information; a variable updating unit, used to, when receiving a configuration update request, if the configuration update request introduces a new variable, write data related to the new variable into the variable data, and update the memory information of the variable data after the introduction of the new variable.
[0008] To achieve the above-mentioned purpose, the present application also provides a method for dynamically configuring variables, which is applied in a working process, and includes: when receiving a domain name acceleration request, reading real-time information of the variable array from the shared memory, and the real-time information is used to characterize the current memory address and used memory size of the variable array; based on the real-time information, judging whether variable synchronization is required; if variable synchronization is required, first updating the used memory size according to the real-time information, and then updating the current memory address according to the real-time information.
[0009] To achieve the above-mentioned purpose, the present application also provides a system for dynamically configuring variables, the system comprising: a real-time information reading unit, for reading real-time information of a variable array from a shared memory when a domain name acceleration request is received, the real-time information being used to characterize the current memory address and used memory size of the variable array; a judgment unit, for judging whether variable synchronization is required based on the real-time information; and an update unit, for first updating the used memory size according to the real-time information, and then updating the current memory address according to the real-time information, if variable synchronization is required.
[0010] To achieve the above-mentioned purpose, the present application further provides a server on the other hand, the server comprising a memory and a processor, the memory being used to store a computer program, and the computer program, when executed by the processor, implements the above-mentioned method of dynamically configuring variables.
[0011] As can be seen from the above, the technical solution provided by one or more embodiments of the present application can improve the existing variable data to a certain extent, so that the new variable can be used normally according to the improved variable storage method. Specifically, the variable hash table can be improved to store the variable information of the new variable by applying for memory. In practical applications, the used memory size and the applied memory size of each hash bucket in the variable hash table can be recorded. In this way, when a new variable is introduced, the variable information of the new variable can be written into the corresponding target hash bucket, and the used memory size and the applied memory size of the target hash bucket can be updated at the same time. For the original variable array, the new variable can also be stored in this way of applying for memory. Specifically, the real-time information of the variable array can be recorded in the shared memory, and the real-time information can characterize the current memory address and the used memory size of the variable array. In this way, after the new variable is written into the variable array, the real-time information of the variable array can be updated. Subsequently, when the working process determines that variable synchronization is required, the used memory size of the variable array can be updated first according to the real-time information in the shared memory, and then the current memory address can be updated, so that the introduced new variable can be used normally. It can be seen that by making a small improvement to the storage structure of the existing variable data, the introduced new variables can be used normally. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0013] Figure 1 It is a schematic diagram of the steps of dynamically configuring variables executed by the main process in an embodiment of the present invention;
[0014] Figure 2 It is a schematic diagram of the flow of dynamic configuration variables executed by the main process in an embodiment of the present invention;
[0015] Figure 3 It is a schematic diagram of the steps of dynamically configuring variables executed by the working process in an embodiment of the present invention. DETAILED DESCRIPTION
[0016] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in combination with the specific implementation methods of this application and the corresponding drawings. Obviously, the described implementation methods are only part of the implementation methods of this application, not all of the implementation methods. Based on the implementation methods in this application, all other implementation methods obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0017] The method for dynamically configuring variables provided in the present application can be applied to devices such as node servers, load balancers, and proxy servers of CDN. In the above-mentioned node servers, load balancers, proxy servers, and other devices, a business system for implementing a business can usually be deployed, and the business system can be implemented based on a certain architecture. For example, in the current CDN, the nginx architecture is widely used in devices such as node servers, load balancers, and proxy servers due to its high performance and high stability. This application takes the nginx architecture as an example to illustrate the method for dynamically configuring variables.
[0018] Specifically, the technical solution provided by the present application only requires a small improvement in the structure of the variable data in the nginx architecture. The method for dynamically configuring variables applied to the nginx main process (master process) may include: parsing variable configuration information, and recording memory information corresponding to the variable data according to the variable configuration information; when receiving a configuration update request, if the configuration update request introduces a new variable, writing data related to the new variable in the variable data, and updating the memory information of the variable data after the introduction of the new variable.
[0019] Specifically, see Figure 1 and Figure 2 When the above method is actually applied, it can include the following steps.
[0020] S11: Parse the variable configuration information, and record the used memory size of each hash bucket in the variable hash table and the requested memory size of each hash bucket, and record the real-time information of the variable array in the shared memory, wherein the real-time information is used to characterize the current memory address and used memory size of the variable array.
[0021] In this implementation, the main process can create a shared memory and store variable data in nginx through the shared memory. In nginx, variable data can generally include the following:
[0022] 1) Array of variables
[0023] Variables is an ngx_array_t array structure, in which each variable can be written. In the existing nginx, variables supports incremental insertion, that is, when a new variable is introduced, the new variable can be written into the variable array normally. Specifically, the variable array can apply for a certain amount of memory space in advance, and then write each variable in sequence in the memory space. When introducing a new variable, if the current memory space is not enough to write the new variable, the variable array can reapply for a new memory space. Generally speaking, the size of the new memory space can be twice the size of the current memory space. After applying for a new memory space, the variables written in the current memory space can be copied to the new memory space, and then continue to write new variables in the new memory space. After applying for a new memory space, the current memory address of the ngx_array_t array structure is also modified to the address of the new memory space, and the used memory size of the ngx_array_t array structure is also correspondingly modified to the used memory size in the new memory space.
[0024] In actual applications, after the variables are copied to the new memory space, the old memory space is not released, so after the new variables appear, there will be no problem in accessing the old data through the old memory space. In this way, each time a new memory space is applied, the entire process does not affect the use of the previous old data, so when a process writes a new variable to the newly applied memory space, other processes can still read the old variables normally from the old memory space, and this process does not require a read-write lock.
[0025] 2) Variables hash table (variables_hash)
[0026] The variable hash table can store the corresponding variable information by the variable name, so that the corresponding variable information can be found in the variable hash table by the variable name. The variable hash table is a static hash table. In this application, it can be transformed into a hash table that supports data insertion without changing the data structure. Specifically, the variable hash table can store the data in the same hash bucket in the same continuous memory structure. Since the memory is continuous, the variable information in the hash bucket can be recorded by reserving memory space and applying for new memory space with reference to the data storage method of ngx_array_t. For example, for each hash bucket in the variable hash table, a corresponding memory space can be created in advance, and then the variable information in the hash bucket can be written into the memory space. When a new variable appears in the hash bucket, if the existing memory space is not enough to write the variable information of the new variable, a new memory space can be re-applied for the hash bucket, and the size of the new memory space can also be twice the size of the original memory space. Then, the variable information in the original memory space can be copied to the new memory space, and the variable information of the new variable can continue to be written in the new memory space. In this way, the process of adding new variable information can be done without a read-write lock.
[0027] In addition, in order to adapt to this improvement, the used memory size of each hash bucket in the variable hash table and the requested memory size of each hash bucket can be recorded. In this way, when new memory space is reapplied, the used memory size and the requested memory size can be updated after the variable information is written in the new memory space.
[0028] 3) Prefix variables (pre_variables)
[0029] Prefix variables are a form of variable array in nginx. Prefix variables can support variables with the same prefix to obtain corresponding variable values using the same method. In this application, the processing method of prefix variables can be consistent with the processing method of variable arrays, so prefix variables can also be included in variable arrays, which can be collectively referred to as variable arrays in this application.
[0030] 4) Variables hash array (variables_keys hash)
[0031] The variable hash array is a data structure used to store all non-prefix built-in variable information. This data structure itself supports incremental data updates. And the result of the variable hash array is only used in the process of updating variables. The process of obtaining variable values does not need to use this data structure, so the update process does not need to be locked.
[0032] As can be seen from the above, the variable data in nginx can be updated without the need for a read-write lock after a small amount of modification in the present application solution, so that higher read-write efficiency can be achieved during the update process of the variable data.
[0033] In this embodiment, the main process can initialize the data structure of each variable data mentioned above when parsing the variable configuration information. Among them, when initializing the data structure of the variable hash array and the variable hash table, the created shared memory can be used to replace the original process heap memory, and the memory pool pointer of the variable array can be set to point to the memory pool of the shared memory. Specifically, the address of the memory pool of the shared memory can be assigned to the memory pool pointer of the variable array. After the assignment, the memory applied for by the variable array in the future is the shared memory. In this way, the shared memory can be used to store the variable data of each data structure, and part of the data in the shared memory can be accessed by the worker process (worker process), so that data synchronization between multiple processes can be achieved.
[0034] In this application, each process can have its own process heap memory. Generally speaking, the data in the process heap memory cannot be accessed across processes. For example, work process A and work process B can have heap memory A and heap memory B respectively, then work process A can read and write data in heap memory A, and similarly, work process B can read and write data in heap memory B, but work process A cannot read and write data in heap memory B, and work process B cannot read and write data in heap memory A. Data in shared memory can be accessed by different processes. For example, data stored in shared memory can be accessed by different work processes, and can also be accessed by work processes and main processes.
[0035] In this embodiment, the main process can record the used memory size of each hash bucket in the variable hash table and the applied memory size of each hash bucket, and can record the real-time information of the variable array in the shared memory, which can characterize the current memory address and used memory size of the variable array. In practical applications, the variable information in the hash bucket and the variables in the variable array are usually stored in the process heap memory during initialization. After the memory pool is replaced with the shared memory, in order to apply for new memory space in the shared memory, the initial value of the applied memory size of the hash bucket can be set to be equal to the used memory size of the hash bucket, and the initial value of the applied memory size of the variable array can be set to be equal to the used memory size of the variable array. The purpose of this processing is that when a newly introduced variable appears, whether it is a hash bucket or a variable array, the currently applied memory space is not enough to write the data of the new variable, so the hash bucket and the variable data array need to re-apply for new memory space in the shared memory, so that the data can be transferred from the process heap memory to the shared memory, thereby realizing data sharing between multiple processes.
[0036] S13: When a configuration update request is received, if the configuration update request introduces a new variable, the new variable is written into the variable array, and the real-time information is updated, and the variable information of the new variable is written into the target hash bucket corresponding to the variable hash table, and the used memory size and the requested memory size of the target hash bucket are updated.
[0037] In this embodiment, the main process can create a work process and process the domain name acceleration request through the work process. In the process of processing the domain name acceleration request, when a domain name needs to dynamically update the configuration, the main process will receive the corresponding configuration update request. By parsing the configuration update request, the main process can determine whether a new variable is introduced. If a new variable is introduced, the data corresponding to the new variable can be written into the variable array and the variable hash table respectively.
[0038] Specifically, if the memory space currently applied for by the variable array and the hash bucket can write the data of the new variable, then the new variable can be directly written into the variable array, and the variable information of the new variable can be written into the hash bucket. After writing the data, the real-time information of the variable array can be updated (where the current memory address can remain unchanged and only the used memory size is updated), and the used memory size of the hash bucket can be updated.
[0039] If the target hash bucket's requested memory size is not enough to write the variable information of the new variable, then you can re-apply for new memory in the shared memory in the aforementioned manner, and the size of the new memory is larger than the original requested memory size. Then, you can copy the original variable information in the target hash bucket to the new memory, and continue to write the variable information of the new variable in the new memory. After writing the variable information in the target hash bucket, you can modify the used memory size of the target hash bucket to the used memory size in the new memory, and modify the requested memory size of the target hash bucket to the size of the new memory.
[0040] Similarly, if the requested memory size of the variable array is not enough to write new variables, you can re-apply for new memory in the shared memory, and the size of the new memory is also larger than the requested memory size of the variable array. Then the original variables in the variable array can be copied to the new memory, and new variables can continue to be written in the new memory. After writing new variables in the variable array, the current memory address of the variable array can be modified to the address of the new memory, and the used memory size of the variable array can be modified to the used memory size in the new memory. In actual applications, in order to avoid abnormal data reading, the current memory address can be updated first, and then the used memory size can be updated. The purpose of this processing is to assume that the original memory address of the variable array is A1, the used memory size is B, the new memory address is A2, and the used memory size is C, as shown below:
[0041] Before update: A1 B
[0042] After Update: A2 C
[0043] Since a new variable is introduced, C must be greater than B. At this time, according to the above method, the memory address can be updated first. Assuming that the used memory size has not been updated in time, the following status will appear:
[0044] Intermediate state: A2 B
[0045] In this intermediate state, since the memory space under the A2 address is larger than the memory space under the A1 address, no exception will occur when accessing the data of B under A2.
[0046] However, if you update the used memory size first, the following status will appear:
[0047] Intermediate state: A1 C
[0048] In this intermediate state, the memory space at address A1 is not enough to accommodate the data of C, so accessing the data of C at address A1 will be abnormal. This is why the current memory address is updated first, and then the used memory size is updated.
[0049] In this embodiment, after the main process completes the update of the new variable data, since the current memory address and used memory size of the variable array in the working process are still stored in the process heap memory, the working process actually uses the old memory address and the old memory size. Subsequently, the working process can keep in sync with the data of the main process by reading real-time information in the shared memory.
[0050] Specifically, see Figure 3 The method for dynamically configuring variables in nginx in the working process of the present application may include the following steps.
[0051] S21: When a domain name acceleration request is received, real-time information of the variable array is read from the shared memory, where the real-time information is used to represent the current memory address and used memory size of the variable array.
[0052] S23: Based on the real-time information, determine whether variable synchronization is required.
[0053] S25: If variable synchronization is required, first update the used memory size according to the real-time information, and then update the current memory address according to the real-time information.
[0054] In this embodiment, when the working process receives a domain name acceleration request, in order to ensure that the new variables introduced in the domain name acceleration request can be used normally, it can first actively synchronize data with the main process. Specifically, the main process will keep the real-time information of the variable array updated in the shared memory, so the working process can read the current real-time information from the shared memory, and then compare the first used memory size in the real-time information with the second used memory size recorded in the process heap memory of the working process. If the first used memory size is larger than the second used memory size, it means that the main process has completed the update process of the new variable, and the working process determines that variable synchronization is required. If the first used memory size is equal to the second used memory size, it means that no new variables are currently introduced, so the working process can determine that variable synchronization is not required.
[0055] In this implementation, when variable synchronization is required, the working process needs to update the used memory size first and then the current memory address in the opposite order of the main process. The purpose of this process is also to avoid data reading errors. For example, suppose the main process updates the variable data twice:
[0056] Initialization size after master parsing 10 address p1
[0057] When the master parses the 11th variable, it updates 1 size 20 address p2
[0058] When the master parses the 21st variable, it updates 2 size 40 address p3
[0059] Among them, size can be the used memory size, and address indicates the current memory address.
[0060] Assume that the original data in the process heap memory of the worker process is:
[0061] Worker initial value size 10 address p1
[0062] If the worker updates the address first and then the size, the following intermediate states may occur:
[0063] Worker update size 40 address p2
[0064] This is because after the worker updates address p2, the master updates the size for the second time (the size is updated to 40). Then when the worker updates the address and then updates the size, it will directly update the size to 40 (instead of 20). Obviously, address P2 is not large enough to accommodate data of size 40, and the worker process will fail to access the variable data.
[0065] If the worker process updates the size first and then the address in the above manner, the following intermediate states may occur:
[0066] Worker update size 20 address p3
[0067] This is because after the worker updates the size from 10 to 20, the master performs a second update (updates the address from p2 to p3). After the worker updates the size, it will directly update the address from p1 to p3. However, since the memory space under p3 is larger and can fully accommodate variable data of size 20, there will be no problem in reading data based on this intermediate state. When the worker process updates the next time, it will also update the size to 40, thus obtaining the correct size and address. This is why in the worker process, the used memory size needs to be updated first, and then the current memory address needs to be updated.
[0068] Corresponding to the above method, an embodiment of the present application further provides a system for dynamically configuring variables, the system comprising:
[0069] An information recording unit, used to parse variable configuration information and record memory information corresponding to variable data according to the variable configuration information;
[0070] The variable updating unit is used to, upon receiving a configuration update request, write data related to the new variable into the variable data if the configuration update request introduces a new variable, and update the memory information of the variable data after the new variable is introduced.
[0071] Similarly, another embodiment of the present application further provides a system for dynamically configuring variables, the system comprising:
[0072] A real-time information reading unit, used to read the real-time information of the variable array from the shared memory when receiving a domain name acceleration request, wherein the real-time information is used to characterize the current memory address and the used memory size of the variable array;
[0073] A judging unit, used for judging whether variable synchronization is required based on the real-time information;
[0074] The updating unit is used to update the used memory size according to the real-time information if variable synchronization is required, and then update the current memory address according to the real-time information.
[0075] The present application also provides a server, which includes a memory and a processor, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, the above-mentioned method of dynamically configuring variables is implemented.
[0076] The above-mentioned server can be a server deployed with an nginx system, the server can be a CDN node server, a load balancing server in the CDN, a proxy server in the CDN, etc.
[0077] As can be seen from the above, the technical solution provided by one or more embodiments of the present application can improve the existing variable data to a certain extent, so that the new variable can be used normally according to the improved variable storage method. Specifically, the variable hash table can be improved to store the variable information of the new variable by applying for memory. In practical applications, the used memory size and the applied memory size of each hash bucket in the variable hash table can be recorded. In this way, when a new variable is introduced, the variable information of the new variable can be written into the corresponding target hash bucket, and the used memory size and the applied memory size of the target hash bucket can be updated at the same time. For the original variable array, the new variable can also be stored in this way of applying for memory. Specifically, the real-time information of the variable array can be recorded in the shared memory, and the real-time information can characterize the current memory address and the used memory size of the variable array. In this way, after the new variable is written into the variable array, the real-time information of the variable array can be updated. Subsequently, when the working process determines that variable synchronization is required, the used memory size of the variable array can be updated first according to the real-time information in the shared memory, and then the current memory address can be updated, so that the introduced new variable can be used normally. It can be seen that by making a small improvement to the storage structure of the existing variable data, the introduced new variables can be used normally.
[0078] In addition, in the prior art, the variable information in the variable hash table is global data, and the variable data of the introduced new variable cannot be added to the variable hash table, so the corresponding variable information cannot be found according to the variable name. In this application, the data structure of the variable hash table is expanded, and the data synchronization between processes is performed through shared memory, so that the global data is directly converted into data that can be dynamically updated and used by each process, thereby realizing the dynamic configuration of new variables.
[0079] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the implementation of the system, the introduction of the implementation of the aforementioned method can be referred to for comparative explanation.
[0080] It will be appreciated by those skilled in the art that the embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may be in the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0081] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0082] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0083] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0084] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0085] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0086] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0087] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0088] The above is only the implementation mode of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A method for dynamically configuring variables, characterized in that: The method is applied to the main process of nginx, and the method includes: Parsing the variable configuration information, and recording the memory information corresponding to the variable data according to the variable configuration information, including: recording the real-time information of the variable array included in the variable data in the shared memory, the real-time information being used to characterize the current memory address and the used memory size of the variable array; When receiving a configuration update request, if the configuration update request introduces a new variable, writing data related to the new variable into the variable data, and updating memory information of the variable data after the new variable is introduced, including: if the applied memory size of the variable array is insufficient to write the new variable, reapplying for new memory in the shared memory, copying the original variables in the variable array to the new memory, writing the new variable into the new memory, and updating the real-time information of the variable array after the new variable is introduced; When the created working process receives a domain name acceleration request, reading real-time information of the variable array from the shared memory; The working process determines whether variable synchronization is required based on the real-time information; If variable synchronization is required, the working process synchronizes the variables with the main process.
2. The method according to claim 1, characterized in that The main process creates a memory pool of the shared memory, and the variable data also includes a variable hash table; recording memory information corresponding to the variable data includes: recording the used memory size of each hash bucket in the variable hash table and the requested memory size of each hash bucket.
3. The method according to claim 2, characterized in that The method further comprises: When initializing the data structures of the variable hash array and the variable hash table, the original process heap memory is replaced by the shared memory; The memory pool pointer of the variable array is set to point to the memory pool of the shared memory.
4. The method according to claim 2, characterized in that: After recording the used memory size of each hash bucket in the variable hash table and the requested memory size of each hash bucket, the method further includes: The initial value of the requested memory size of the hash bucket is set to be equal to the used memory size of the hash bucket.
5. The method according to claim 2, characterized in that: Writing data related to the new variable into the variable data and updating the memory information of the variable data after the new variable is introduced includes: The variable information of the new variable is written into the target hash bucket corresponding to the variable hash table, and the used memory size and the requested memory size of the target hash bucket are updated.
6. The method according to claim 5, characterized in that Writing the variable information of the new variable into the target hash bucket corresponding to the variable hash table includes: If the requested memory size of the target hash bucket is insufficient to write the variable information of the new variable, re-apply for new memory in the shared memory, and the size of the new memory is larger than the requested memory size; The original variable information in the target hash bucket is copied to the new memory, and the variable information of the new variable continues to be written into the new memory.
7. The method according to claim 6, characterized in that Updating the used memory size and the requested memory size of the target hash bucket includes: The used memory size of the target hash bucket is modified to the used memory size in the new memory, and the requested memory size of the target hash bucket is modified to the size of the new memory.
8. The method according to claim 1, characterized in that Updating the real-time information includes: The current memory address of the variable array is modified to the address of the new memory, and the used memory size of the variable array is modified to the used memory size in the new memory; wherein, the current memory address is updated first, and then the used memory size is updated.
9. The method according to claim 2, characterized in that: After recording the real-time information of the variable array in the shared memory, the method further comprises: The initial value of the requested memory size of the variable array is set to be equal to the used memory size of the variable array.
10. A system for dynamically configuring variables, characterized in that: The system is a system based on nginx architecture, and the system includes: An information recording unit, used to parse variable configuration information and record memory information corresponding to variable data according to the variable configuration information; A variable updating unit, configured to, upon receiving a configuration update request, write data related to the new variable into the variable data if the configuration update request introduces a new variable, and update memory information of the variable data after the new variable is introduced, including: if the memory size applied for the variable array is insufficient to write the new variable, reapply for new memory in the shared memory, copy the original variables in the variable array to the new memory, write the new variable into the new memory, and update the real-time information of the variable array after the new variable is introduced; A real-time information reading unit, used to read the real-time information of the variable array from the shared memory when receiving a domain name acceleration request, wherein the real-time information is used to represent the current memory address and the used memory size of the variable array; A judging unit, used for judging whether variable synchronization is required based on the real-time information; The updating unit is used to update the used memory size according to the real-time information if variable synchronization is required, and then update the current memory address according to the real-time information.
11. A method for dynamically configuring variables, characterized in that: The method is applied to the working process of nginx, and the method includes: When receiving a domain name acceleration request, read real-time information of the variable array from the shared memory, where the real-time information is used to represent the current memory address and used memory size of the variable array; Based on the real-time information, comparing a first used memory size in the real-time information with a second used memory size recorded in the process heap memory of the working process to determine whether variable synchronization is required; If variable synchronization is required, the used memory size is first updated according to the real-time information, and then the current memory address is updated according to the real-time information.
12. The method according to claim 11, characterized in that Determining whether variable synchronization is required includes: If the first used memory size is larger than the second used memory size, it is determined that variable synchronization is required; if the first used memory size is equal to the second used memory size, it is determined that variable synchronization is not required.
13. A system for dynamically configuring variables, characterized in that: The system is a system based on nginx architecture, and the system includes: A real-time information reading unit, used to read the real-time information of the variable array from the shared memory when receiving a domain name acceleration request, wherein the real-time information is used to represent the current memory address and the used memory size of the variable array; A judging unit, configured to compare, based on the real-time information, a first used memory size in the real-time information with a second used memory size recorded in a process heap memory of the working process, so as to judge whether variable synchronization is required; The updating unit is used to update the used memory size according to the real-time information if variable synchronization is required, and then update the current memory address according to the real-time information.
14. A server, characterized in that: The server comprises a memory and a processor, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, the method according to any one of claims 1 to 9 and 11 to 12 is implemented.
