Configuration hot update method, device and equipment of load balancer and storage medium

By loading configuration files in Nginx service and real-time update of dynamic configuration tables using preset interfaces, the service interruption problem caused by static configuration of traditional Nginx ports is solved, ensuring the continuous availability and business continuity of the service.

CN120498992APending Publication Date: 2025-08-15BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510848527.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-23
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

Traditional Nginx port configuration is static and strongly bound, resulting in restarting when service modifications are required, affecting service continuity and availability.

Method used

By obtaining the configuration file and loading it into memory, a dynamic configuration table is formed, and real-time changes in configuration data are achieved using the preset interface, and the target domain name configuration data for connection requests is dynamically injected without restarting the service.

Benefits of technology

Real-time update of Nginx port configuration is realized, ensuring the continuous availability of services and business continuity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120498992A_ABST
    Figure CN120498992A_ABST
Patent Text Reader

Abstract

The invention relates to a configuration hot updating method, device and equipment of a balancing load device and a storage medium, and the method comprises the steps: starting an Nginx service in the balancing load device, loading a first configuration file comprising all configuration parameters of each monitor and a second configuration file comprising related data of an initial back-end server into a memory of a balancing load device to obtain an initial dynamic configuration table; receiving a configuration change request through a preset interface, and changing configuration data in the initial dynamic configuration table based on the configuration change request to obtain a target dynamic configuration table; in the process of monitoring the pre-monitoring port, a connection request is received, and the connection request carries a target IP address, a port number and SNI domain name information; and according to the target IP address and the port number, judging whether to release the connection request, when the connection request is released, determining target domain name configuration data corresponding to the SNI domain name information, and dynamically injecting the target domain name configuration data into a new connection established based on the connection request.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, apparatus, device, and storage medium for hot updating configuration of a load balancer. Background Art

[0002] In the network service architecture, port configuration is a key factor in ensuring that the service can provide normal external access. It determines which service instance the client request should be forwarded to, directly affecting the availability and stability of the service.

[0003] Traditional Nginx port configuration is often hardcoded into files, such as explicitly specifying listen ports like listen 80 or listen 443ssl in the nginx.conf file. This configuration method strongly binds port information to the configuration file, leaving all port rules in static text and lacking flexibility.

[0004] Once the service is running, if you need to modify the port, whether adding a new port or modifying an existing port configuration, you must manually modify the corresponding content in the configuration file. After completing the modification, you must restart the service using commands such as nginx reload for the new port configuration to take effect. This process will cause a brief service interruption and affect service continuity. Summary of the Invention

[0005] The present application provides a configuration hot update method, apparatus, device and storage medium for a load balancer. This method can realize real-time changes to the configuration data in the initial dynamic configuration table by calling a preset interface, and there is no need to execute a reload command to restart the load balancer after the change, thereby ensuring the continuous availability and business continuity of the service from the underlying mechanism.

[0006] In a first aspect, the present application provides a method for hot updating configuration of a load balancer, the method comprising:

[0007] Obtain a first configuration file and a second configuration file, wherein the first configuration file includes all configuration parameters of each listener, and the second configuration file includes relevant data of the initial backend server;

[0008] Starting the Nginx service in the load balancer, loading the first configuration file and the second configuration file into the memory of the load balancer, and obtaining an initial dynamic configuration table;

[0009] receiving a configuration change request through a preset interface, and changing the configuration data in the initial dynamic configuration table based on the configuration change request to obtain a target dynamic configuration table;

[0010] In the process of using the listener template configuration in the Nginx service to listen to the pre-listening port, receiving a connection request sent by the client through the pre-listening port, the connection request carrying the target IP address, port number and server name indication (SNI) domain name information;

[0011] Based on the target IP address and port number, determine whether to release the connection request. When the connection request is released, enter the TLS handshake phase, determine the target domain name configuration data corresponding to the SNI domain name information, and dynamically inject the target domain name configuration data into the new connection established based on the connection request.

[0012] Optionally, the initial dynamic configuration table includes a shared memory dictionary corresponding to the first configuration file. When the configuration change request is received through the first interface, the configuration change request is used to change data in the shared memory dictionary. Changing the configuration data in the initial dynamic configuration table based on the configuration change request to obtain a target dynamic configuration table includes:

[0013] According to the configuration change request, data in the shared memory dictionary is changed to obtain a changed shared memory dictionary.

[0014] Optionally, the initial dynamic configuration table includes logical upstream data of the backend server group obtained based on the second configuration file. When the configuration change request is received through the second interface, the configuration change request is used to update the upstream data. The configuration data in the initial dynamic configuration table is changed based on the configuration change request to obtain a target dynamic configuration table, including:

[0015] According to the configuration change request, change the upstream data corresponding to the current working process;

[0016] After changing the upstream data corresponding to the current working process, the process identifier of the current working process is added to the process list corresponding to the change message, the operation count of the change message is increased by 1, and a change message is generated based on the change content in the configuration change request, the process list, and the operation count. The change message is attached to a bidirectional linked list in the form of a target, so that other working processes change the corresponding upstream data according to the change message on the bidirectional linked list;

[0017] The process list is used to store identifiers of working processes that have executed change operations.

[0018] Optionally, changing corresponding upstream data according to the change message on the bidirectional linked list includes:

[0019] Obtain other process identifiers of the other working processes;

[0020] Detecting whether the other process identifier exists in the process list of the change message;

[0021] When the other process identifier does not exist in the process list of the change message, the corresponding upstream data is changed according to the change content in the change message, the other process identifier is added to the process list of the change message, and the operation count of the change message is increased by 1.

[0022] Optionally, the method further includes:

[0023] Checking whether the operation count is equal to the total number of working processes;

[0024] When the operation count is equal to the total number of working processes, the change message is destroyed to release memory.

[0025] Optionally, determining whether to allow the connection request based on the target IP address and port number includes:

[0026] In the LRU cache of the current working process, query whether the target data exists, wherein the target data is the target IP address and port number;

[0027] When the target data exists in the LRU cache of the current working process, determining whether to release the connection request according to the cache entry corresponding to the target data in the LRU cache;

[0028] When the target data does not exist in the LRU cache of the current working process, the shared memory dictionary is queried to determine whether the target data exists, and when the target data exists in the shared memory dictionary, it is determined to release the connection request; when the target data does not exist in the shared memory dictionary, it is determined not to release the connection request.

[0029] Optionally, determining whether to release the connection request according to a cache entry corresponding to the target data in the LRU cache includes:

[0030] Detecting whether the cache item is expired;

[0031] When the cache item has not expired, determining to release the connection request;

[0032] When the cache item expires, obtaining a first version number corresponding to the cache item and a second version number corresponding to the shared memory dictionary;

[0033] When the first version number and the second version number are consistent, resetting the cache expiration time corresponding to the cache item and determining to release the connection request;

[0034] When the first version number and the second version number are inconsistent, the target data is queried from the shared memory dictionary. When the target data is found from the shared memory dictionary, the data item and version number corresponding to the target data are loaded into the LRU cache, and it is determined to release the connection request. When the target data is not found from the shared memory dictionary, it is determined not to release the connection request.

[0035] Optionally, determining the target domain name configuration data corresponding to the SNI domain name information includes:

[0036] In the target listener configuration data queried based on the target IP address and port number, detecting whether there is domain name configuration data associated with the SNI domain name information;

[0037] When domain name configuration data associated with the SNI domain name information exists in the target listener configuration data, determining the domain name configuration data as target domain name configuration data;

[0038] When the domain name configuration data associated with the SNI domain name information does not exist in the target listener configuration data, the default configuration data is determined as the target domain name configuration data.

[0039] In a second aspect, the present application provides a configuration hot update device for a load balancer, the device comprising:

[0040] an acquiring unit, configured to acquire a first configuration file and a second configuration file, wherein the first configuration file includes all configuration parameters of each listener, and the second configuration file includes relevant data of the initial backend server;

[0041] A starting unit, configured to start the Nginx service in the load balancing device, load the first configuration file and the second configuration file into the memory of the load balancing device, and obtain an initial dynamic configuration table;

[0042] a changing unit, configured to receive a configuration change request through a preset interface, and to change the configuration data in the initial dynamic configuration table based on the configuration change request to obtain a target dynamic configuration table;

[0043] A receiving unit is configured to receive a connection request sent by a client through the pre-listening port during a process of listening to the pre-listening port using the listener template configuration in the Nginx service, wherein the connection request carries the target IP address, port number, and server name indication (SNI) domain name information;

[0044] A determination unit is used to determine whether to release the connection request based on the target IP address and port number. When the connection request is released, the TLS handshake phase is entered, the target domain name configuration data corresponding to the SNI domain name information is determined, and the target domain name configuration data is dynamically injected into the new connection established based on the connection request.

[0045] Optionally, the initial dynamic configuration table includes a shared memory dictionary corresponding to the first configuration file. When the configuration change request is received through the first interface, the configuration change request is used to change data in the shared memory dictionary. The changing unit is configured to:

[0046] According to the configuration change request, data in the shared memory dictionary is changed to obtain a changed shared memory dictionary.

[0047] Optionally, the initial dynamic configuration table includes logical upstream data of the backend server group obtained based on the second configuration file. When the configuration change request is received through the second interface, the configuration change request is used to update the upstream data. The changing unit is configured to:

[0048] According to the configuration change request, change the upstream data corresponding to the current working process;

[0049] After changing the upstream data corresponding to the current working process, the process identifier of the current working process is added to the process list corresponding to the change message, the operation count of the change message is increased by 1, and a change message is generated based on the change content in the configuration change request, the process list, and the operation count. The change message is attached to a bidirectional linked list in the form of a target, so that other working processes change the corresponding upstream data according to the change message on the bidirectional linked list;

[0050] The process list is used to store identifiers of working processes that have executed change operations.

[0051] Optionally, the changing unit is configured to:

[0052] Obtain other process identifiers of the other working processes;

[0053] Detecting whether the other process identifier exists in the process list of the change message;

[0054] When the other process identifier does not exist in the process list of the change message, the corresponding upstream data is changed according to the change content in the change message, the other process identifier is added to the process list of the change message, and the operation count of the change message is increased by 1.

[0055] Optionally, the device further includes a detection unit, wherein the detection unit is configured to:

[0056] Checking whether the operation count is equal to the total number of working processes;

[0057] When the operation count is equal to the total number of working processes, the change message is destroyed to release memory.

[0058] Optionally, the determining unit is configured to:

[0059] In the LRU cache of the current working process, query whether the target data exists, wherein the target data is the target IP address and port number;

[0060] When the target data exists in the LRU cache of the current working process, determining whether to release the connection request according to the cache entry corresponding to the target data in the LRU cache;

[0061] When the target data does not exist in the LRU cache of the current working process, the shared memory dictionary is queried to determine whether the target data exists, and when the target data exists in the shared memory dictionary, it is determined to release the connection request; when the target data does not exist in the shared memory dictionary, it is determined not to release the connection request.

[0062] Optionally, the determining unit is configured to:

[0063] Detecting whether the cache item is expired;

[0064] When the cache item has not expired, determining to release the connection request;

[0065] When the cache item expires, obtaining a first version number corresponding to the cache item and a second version number corresponding to the shared memory dictionary;

[0066] When the first version number and the second version number are consistent, resetting the cache expiration time corresponding to the cache item and determining to release the connection request;

[0067] When the first version number and the second version number are inconsistent, the target data is queried from the shared memory dictionary. When the target data is found from the shared memory dictionary, the data item and version number corresponding to the target data are loaded into the LRU cache, and it is determined to release the connection request. When the target data is not found from the shared memory dictionary, it is determined not to release the connection request.

[0068] Optionally, the determining unit is configured to:

[0069] In the target listener configuration data queried based on the target IP address and port number, detecting whether there is domain name configuration data associated with the SNI domain name information;

[0070] When domain name configuration data associated with the SNI domain name information exists in the target listener configuration data, determining the domain name configuration data as target domain name configuration data;

[0071] When the domain name configuration data associated with the SNI domain name information does not exist in the target listener configuration data, the default configuration data is determined as the target domain name configuration data.

[0072] In a third aspect, the present application provides a configuration hot update device for a load balancer, comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; and at least one memory connected to the at least one bus, wherein the processor is configured to:

[0073] Obtain a first configuration file and a second configuration file, wherein the first configuration file includes all configuration parameters of each listener, and the second configuration file includes relevant data of the initial backend server;

[0074] Starting the Nginx service in the load balancer, loading the first configuration file and the second configuration file into the memory of the load balancer, and obtaining an initial dynamic configuration table;

[0075] receiving a configuration change request through a preset interface, and changing the configuration data in the initial dynamic configuration table based on the configuration change request to obtain a target dynamic configuration table;

[0076] In the process of using the listener template configuration in the Nginx service to listen to the pre-listening port, receiving a connection request sent by the client through the pre-listening port, the connection request carrying the target IP address, port number and server name indication (SNI) domain name information;

[0077] Based on the target IP address and port number, determine whether to release the connection request. When the connection request is released, enter the TLS handshake phase, determine the target domain name configuration data corresponding to the SNI domain name information, and dynamically inject the target domain name configuration data into the new connection established based on the connection request.

[0078] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the above-mentioned method for hot updating the configuration of the load balancer when executed by a processor.

[0079] The above-mentioned technical solution provided by the embodiment of the present application has the following advantages over the prior art: in the embodiment of the present application, a first configuration file and a second configuration file are obtained, the first configuration file includes all configuration parameters of each listener, and the second configuration file includes relevant data of the initial back-end server; the Nginx service in the load balancer is started, and the first configuration file and the second configuration file are loaded into the memory of the load balancer to obtain an initial dynamic configuration table; a configuration change request is received through a preset interface to change the configuration data in the initial dynamic configuration table based on the configuration change request to obtain a target dynamic configuration table; in the process of using the listener template configuration in the Nginx service to listen to the pre-listening port, a connection request sent by the client through the pre-listening port is received, and the connection request carries the target IP address, port number and server name indication SNI domain name information; based on the target IP address and port number, it is determined whether to release the connection request. When the connection request is released, the TLS handshake phase is entered, the target domain name configuration data corresponding to the SNI domain name information is determined, and the target domain name configuration data is dynamically injected into the new connection established based on the connection request. This application can realize real-time changes to the configuration data in the initial dynamic configuration table by calling the preset interface, and there is no need to execute the reload command to restart the balancer after the change, which ensures the continuous availability and business continuity of the service from the underlying mechanism. BRIEF DESCRIPTION OF THE DRAWINGS

[0080] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0081] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0082] One or more embodiments are exemplarily illustrated by pictures in the corresponding drawings. These exemplifications do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings are represented as similar elements. Unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0083] Figure 1 A flow chart of a method for hot updating a load balancing device configuration provided in an embodiment of the present application;

[0084] Figure 2 A flowchart of a method for determining a target dynamic configuration table provided in an embodiment of the present application;

[0085] Figure 3 A flowchart of a data modification method provided in an embodiment of the present application;

[0086] Figure 4 A flowchart of a data query method provided in an embodiment of the present application;

[0087] Figure 5 A flowchart of a target data detection method provided in an embodiment of the present application;

[0088] Figure 6 A flowchart of a method for determining target domain name configuration data provided in an embodiment of the present application;

[0089] Figure 7 A schematic diagram of a configuration hot update method for a load balancing device provided in an embodiment of the present application;

[0090] Figure 8 A schematic diagram of a process flow of a configuration hot update device for a load balancing device provided in an embodiment of the present application;

[0091] Figure 9 A schematic diagram of a configuration hot update device for a load balancing device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0092] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0093] The disclosure below provides many different embodiments or examples for implementing different configurations of the present invention. To simplify the disclosure of the present invention, the components and configurations of specific examples are described below. Of course, these are merely examples and are not intended to limit the present invention. In addition, the present invention may repeat reference numerals and / or letters in different examples. Such repetition is for the purpose of simplicity and clarity and does not in itself indicate the relationship between the various embodiments and / or configurations discussed.

[0094] In a network service architecture, port configuration is a key element in ensuring that services can provide normal external access. It determines which service instance client requests should be forwarded to, directly impacting the availability and stability of the service. Traditional Nginx port configuration is often hardcoded into files, such as explicitly specifying listening ports such as listen 80 or listen443ssl in the nginx.conf file. This configuration method strongly binds port information to the configuration file, and all port rules exist in the form of static text, lacking flexibility. Once a service is running, if the port needs to be modified, whether adding a new port or modifying an existing port configuration, the corresponding content in the configuration file must be manually modified. After the modification is complete, the service must be restarted using commands such as nginx reload for the new port configuration to take effect. This process can cause a brief service interruption, affecting service continuity.

[0095] In summary, the embodiment of the present application provides a method for hot updating the configuration of a load balancer. This method can realize real-time changes to the configuration data in the initial dynamic configuration table by calling a preset interface, and there is no need to execute the reload command to restart the load balancer after the change, thereby ensuring the continuous availability and business continuity of the service from the underlying mechanism. Figure 1 As shown, the specific steps include:

[0096] Step 101: Obtain a first configuration file and a second configuration file.

[0097] The first configuration file is stream_dysrv.json, which uses JSON format to describe the core configuration of the Nginx service, including all configuration parameters for each TCP / SSL listener (such as the listening port, certificate, private key, cipher suite, two-way authentication rules, and backend server group name). The second configuration file is stream_upstream.conf, which contains data related to the initial backend server, such as the initial backend server list and health check rules.

[0098] In this step, the first configuration file and the second configuration file are set in the load balancer, and when the method described in the present application needs to be executed, the first configuration file and the second configuration file are obtained.

[0099] Step 102: Start the Nginx service in the load balancer, load the first configuration file and the second configuration file into the memory of the load balancer, and obtain an initial dynamic configuration table.

[0100] Among them, the Nginx service provides the core service of reverse proxy and load balancing capabilities for the load balancer. It generates dynamic routing rules by loading configuration files to realize the distribution and processing of client requests.

[0101] In this step, the Nginx service in the load balancer is started, the stream_dysrv.json configuration file is loaded into memory, and its corresponding initial dynamic configuration table is formed using the Lua shared dict shared memory dictionary. Simultaneously, the stream_upstream.conf configuration file is loaded into shared memory, forming its corresponding initial dynamic configuration table. After the dynamic configuration table for shared memory is set, multiple worker processes in the load balancer can read data from shared memory, enabling multiple threads to share this data.

[0102] Step 103: receiving a configuration change request through a preset interface, and changing the configuration data in the initial dynamic configuration table based on the configuration change request to obtain a target dynamic configuration table.

[0103] In this step, the preset interface can be a Restful HTTP API interface, which can be used to dynamically modify, add, or delete configuration data in the initial dynamic configuration table corresponding to the first configuration file, thereby affecting the behavior of the listener. The Restful HTTP API interface can also be used to dynamically modify, add, or delete configuration data in the initial dynamic configuration table corresponding to the second configuration file, thereby implementing functions such as backend server online and offline, and forwarding weight adjustment.

[0104] The embodiment of the present application changes the dynamic configuration table in real time by calling a preset interface, thereby realizing the change of configuration data. At the same time, after changing the dynamic configuration table, the configuration file can also be modified according to the dynamic configuration table to ensure the consistency of the configuration data.

[0105] Step 104 , in the process of using the listener template configuration in the Nginx service to listen to the pre-listening port, receives a connection request sent by the client through the pre-listening port.

[0106] Among them, the connection request carries the target IP address, port number and SNI (Server Name Indication) domain name information. The target IP address is the IP address of the backend server that the client wants to access, and the port number is used to determine the service used. The SNI domain name information is the domain name information to be accessed. In practice, the connection request also includes other information, such as the client's own IP address, source port number, etc. The pre-listening port is a network port that the load balancer opens in advance and continuously listens to in the listener. In practice, the pre-listening port will pre-create a socket and bind it to the specified port, waiting for the client connection request. The listener is a component used to detect and respond to specific events, and the listener template configuration is a templated solution that standardizes the behavior, triggering conditions, processing logic, etc. of such components.

[0107] Step 105: Determine whether to allow the connection request based on the target IP address and port number. If the connection request is allowed, enter the TLS handshake phase, determine the target domain name configuration data corresponding to the SNI domain name information, and dynamically inject the target domain name configuration data into the new connection established based on the connection request.

[0108] Domain name configuration data includes, but is not limited to, certificates, private keys, encryption suites, two-way authentication rules, and backend server group names. These data are used to complete server authentication, negotiate encrypted communication parameters, and verify client identity during communication connections, ensuring the security and compliance of communication connections. Specifically, certificates and private keys are used to verify the legitimacy of server identities, encryption suites determine the encryption algorithm combination used for data transmission, and two-way authentication rules are used to require clients to provide certificates and verify their identities, thereby establishing a two-way trusted encrypted communication link.

[0109] In this step, since the load balancer needs to monitor all ports in real time, it will inevitably receive various connection requests. To accurately identify valid connections, the connection request can be verified based on the target IP address and port number: if the target IP address and port number exist in the memory configuration table, it is considered a valid request; if not, it is considered an invalid request, thus achieving efficient filtering of illegal connections.

[0110] If the connection request is approved, it's considered valid and the TLS handshake phase begins. To complete the authentication process, the target domain configuration data corresponding to the SNI domain information is determined. This data is used to verify the server's identity and load security configurations for the communication connection, ensuring the legitimacy and security of the connection.

[0111] Furthermore, this step can search for the corresponding domain name configuration data in the dynamic configuration table based on the SNI domain name information, the target IP address, and the port number. If no domain name configuration data is found, the default configuration data is determined as the target domain name configuration data. Otherwise, the searched domain name configuration data is determined as the target domain name configuration data.

[0112] After finding the target domain name configuration data, the target domain name configuration data (including but not limited to certificates, private keys, encryption suites, two-way authentication rules, and back-end server group names, etc.) is dynamically injected into the new connection established based on the connection request. Specifically, based on the certificate in the target domain name configuration data, the load balancer sends a handshake message containing the certificate to the client, and the client verifies the validity of the certificate. If the verification is successful, it continues, otherwise the connection is terminated. Based on the encryption suite in the target domain name configuration data, the encryption algorithm, key exchange algorithm and other parameters are negotiated with the client to establish a secure encrypted communication channel. Based on the two-way authentication rules in the target domain name configuration data, the server requests a certificate from the client, verifies the legitimacy of the client certificate, and completes the two-way identity authentication.

[0113] In order to achieve the goal of not triggering the Nginx reload process when adding or deleting listeners, this application uses the listen portM-portN syntax in a service template to pre-listen multiple ports (or port ranges), and implements 0-reload capabilities through the Lua module. When a new connection arrives through the pre-listening port, the Lua code first queries the dynamic configuration table in the memory based on the target IP:Port to determine whether the IP:Port exists, and then decides whether to release it. In the case of release, the SNI domain name information is further obtained, and the domain name level configuration is searched under the configuration item of the corresponding IP:Port (if there is no match, the default configuration is used). Finally, the queried configuration (including certificates, private keys, encryption suites, two-way authentication rules, etc.) is dynamically injected into the new connection to achieve differentiated processing at the request level.

[0114] In an embodiment of the present application, a first configuration file and a second configuration file are obtained, the first configuration file includes all configuration parameters of each listener, and the second configuration file includes relevant data of the initial backend server; the Nginx service in the load balancer is started, and the first configuration file and the second configuration file are loaded into the memory of the load balancer to obtain an initial dynamic configuration table; a configuration change request is received through a preset interface to change the configuration data in the initial dynamic configuration table based on the configuration change request to obtain a target dynamic configuration table; in the process of using the listener template configuration in the Nginx service to listen to the pre-listening port, a connection request sent by the client through the pre-listening port is received, and the connection request carries the target IP address, port number and server name indication SNI domain name information; based on the target IP address and port number, it is determined whether to release the connection request. When the connection request is released, the TLS handshake phase is entered, the target domain name configuration data corresponding to the SNI domain name information is determined, and the target domain name configuration data is dynamically injected into the new connection established based on the connection request. This application can realize real-time changes to the configuration data in the initial dynamic configuration table by calling the preset interface, and there is no need to execute the reload command to restart the load balancer after the change, which ensures the continuous availability and business continuity of the service from the underlying mechanism.

[0115] In an embodiment of the present application, the initial dynamic configuration table of the present application includes a shared memory dictionary corresponding to a first configuration file. When a configuration change request is received via a first interface, the request can be used to change data in the shared memory dictionary. Based on the changes in the configuration change request, the data in the shared memory dictionary is then directly changed, thereby obtaining a changed shared memory dictionary. Specifically, the steps include: changing the data in the shared memory dictionary according to the configuration change request, thereby obtaining a changed shared memory dictionary.

[0116] In addition, the present application can also determine whether the request changes the data in the shared memory dictionary by parsing the configuration change request, and then when the data in the shared memory dictionary is changed, the data in the shared memory dictionary is changed according to the request.

[0117] In an embodiment of the present application, the initial dynamic configuration table includes upstream (backend server group logic, Upstream Server Group Logic Data) data obtained based on the second configuration file. When a configuration change request for updating upstream data is received through the second interface, the upstream data corresponding to the current working process can be modified first. After the modification is completed, the process identifier of the current working process is added to the process list corresponding to the change message, the operation count of the change message is increased by 1, and a change message is generated based on the change content, process list and operation count in the configuration change request, and the change message is hung in a bidirectional linked list in the form of a target. In this way, other working processes can synchronously update their respective upstream data based on the change message in the bidirectional linked list, and finally complete the change of the initial dynamic configuration table. Therefore, an embodiment of the present application provides a method for determining a target dynamic configuration table, such as Figure 2 As shown, the specific steps include:

[0118] Step 201: Change the upstream data corresponding to the current working process according to the configuration change request.

[0119] Configuration change requests are used to update upstream data. The upstream data corresponding to the current work process is the upstream data that the current work process needs to maintain.

[0120] In this step, after the second configuration file is loaded into memory, the upstream data in the second configuration file is distributed to each worker process, ensuring that each worker process has its own upstream data to maintain. When the current worker process receives a configuration change request, it modifies the upstream data it maintains based on the request.

[0121] Step 202: After changing the upstream data corresponding to the current working process, add the process ID of the current working process to the process list corresponding to the change message, increase the operation count of the change message by 1, generate a change message based on the change content, process list and operation count in the configuration change request, and hang the change message in the bidirectional linked list in the form of a target, so that other working processes can change the corresponding upstream data according to the change message on the bidirectional linked list.

[0122] The process list stores the identifiers of the work processes that have performed the change operation. The operation count indicates the number of changes. When the operation count equals the total number of processes, all processes have completed the data change. The target format is a doubly linked list containing the change message, which can be in the ngx_dyups_msg_t format or other formats, not limited here. The configuration change request includes the change content, and the configuration data can be modified based on the change content.

[0123] The process identifier is the PID (Process ID) of the worker process, which is a unique numeric identifier assigned to each worker process by the load balancer. A doubly linked list is set up in the shared memory space, which is primarily used to cache change messages awaiting synchronization. When upstream data needs to be changed, the current worker process mounts the change message into this doubly linked list, allowing other worker processes to periodically poll the doubly linked list to retrieve the change message. This doubly linked list-based message passing mechanism ensures the orderliness of configuration updates between multiple processes and avoids concurrent access conflicts through atomic operations on linked list nodes, achieving efficient distribution of configuration changes and process-level synchronization.

[0124] In this step, after the current worker process successfully completes the upstream data change (as the first process to perform the change), it performs the following operations: obtains an empty process list and adds the current process's identifier to it; obtains the initial operation count (which is initially 0) and increments it to 1. Then, based on the change content, process list, and operation count in the configuration change request, a change message is generated. The generated change message is mounted in a global doubly linked list as an ngx_dyups_msg_t structure, so that other worker processes can poll the linked list to obtain the change message and update their upstream data accordingly.

[0125] In the embodiment of the present application, the other process IDs of other working processes are obtained, and it is detected whether the other process IDs exist in the process list of the change message. If not, the corresponding upstream data is updated according to the content of the change message, the other process IDs are added to the process list, and the operation count is increased by 1. Therefore, the embodiment of the present application provides a data change method, which is as follows: Figure 3 As shown, the specific steps include:

[0126] Step 301: Obtain other process identifiers of other working processes.

[0127] In this step, when it is necessary to execute the method described in the embodiment of the present application, the process identifier of the other work process is obtained and determined as the other process identifier.

[0128] Step 302: Check whether there are other process identifiers in the process list of the change message.

[0129] In this step, each time other working processes read a change message, they obtain the process list of the change message and compare the process identifier in the process list with other process identifiers. If there is a compared process identifier in the process list, it is determined that there are other process identifiers in the process list; otherwise, there are no other process identifiers in the process list.

[0130] Step 303: When no other process ID exists in the process list of the change message, the corresponding upstream data is changed according to the change content in the change message, the other process ID is added to the process list of the change message, and the operation count of the change message is increased by 1.

[0131] In this step, if the other process ID does not exist in the change message's process list, the change content in the change message is obtained and the corresponding upstream data is modified based on the change content. If the change is successful, the other process ID is added to the change message's process list, and the change message's operation count is increased by 1.

[0132] In this embodiment of the present application, after other work processes receive a change message, they check whether the operation count in the message is equal to the total number of work processes. If so, this indicates that all work processes have completed the data change, and the change message is destroyed to free up memory. If not, this indicates that some work processes have not yet completed the change and must continue to update data based on the message. The specific steps are: checking whether the operation count is equal to the total number of work processes; if so, destroying the change message to free up memory.

[0133] In this step, the operation count is checked to see if it is equal to the total number of working processes. When the operation count is equal to the total number of working processes, the change message is automatically deleted to ensure that the configuration change is cleaned up in time after the full process synchronization is completed, avoiding invalid data residue.

[0134] In this embodiment of the present application, since the load balancer must maintain real-time monitoring of all required ports, it is inevitable that invalid connection requests will be received. If the target IP address and port number do not exist in the target dynamic configuration table, this indicates that the request cannot establish a valid connection. In this case, the connection request must be immediately rejected to block illegal access and reduce system resource consumption. The specific steps are as follows: When the target IP address and port number do not exist in the target dynamic configuration table, perform a network layer blocking operation on the connection request.

[0135] In this step, when the target IP address and port number do not exist in the target dynamic configuration table, it is necessary to perform a network layer blocking operation on the connection request to reject the connection request. For example, a reset connection packet can be sent directly to the client to forcibly terminate the unfinished three-way handshake or established connection, or a status code such as 403 Forbidden or 404 Not Found can be returned to the client to clearly inform the client that the request is rejected.

[0136] In the embodiment of the present application, since the target IP address and port number may exist in the LRU cache of the current working process, in order to improve the query efficiency, it is possible to first detect whether the target IP address and port number exist in the LRU cache of the current working process. If they exist, the subsequent steps can be executed. If they do not exist, the target IP address and port number are queried from the shared memory dictionary. Therefore, the embodiment of the present application provides a data query method, such as Figure 4 As shown, the specific steps include:

[0137] Step 401: Check whether the target data exists in the LRU cache of the current working process.

[0138] For ease of description, the target IP address and port number are referred to as target data. The LRU cache includes frequently accessed data closely related to the corresponding work process, such as listener configuration data, domain name configuration data, connection context information, and other information.

[0139] In this step, the LRU cache of the current working process is checked to see whether the target IP address and port number exist.

[0140] Step 402: When the target data exists in the LRU cache of the current working process, it is determined whether to release the connection request based on the cache entry corresponding to the target data in the LRU cache.

[0141] In this step, when the target data exists in the LRU cache of the current working process, the cache item corresponding to the target data in the LRU cache is obtained, and based on the cache item, it is determined whether to release the connection request.

[0142] Step 403: When the target data does not exist in the LRU cache of the current working process, the shared memory dictionary is queried to determine whether the target data exists. If the target data exists in the shared memory dictionary, the connection request is released; if the target data does not exist in the shared memory dictionary, the connection request is not released.

[0143] In this step, if the target IP address and port number are not found in the current worker process's LRU cache, the shared memory dictionary is checked to see if the combination exists. If a matching record exists in the shared memory dictionary, the connection request is allowed; if not, the connection is rejected.

[0144] After the target data is found in the LRU cache, it is detected whether the cache item corresponding to the target data is expired. When the cache item is not expired, it is determined to release the connection request. When the cache item expires, the first version number of the cache item and the second version number of the shared memory dictionary are obtained. If the two version numbers are consistent, the cache expiration time is reset, and the connection request is determined to be released; if they are inconsistent, the target data is re-queried from the shared memory dictionary, and then it is determined whether to release the connection request based on the query result. Therefore, an embodiment of the present application provides a target data detection method, which is as follows: Figure 5 As shown, the specific steps include:

[0145] Step 501: Check whether the cache item is expired.

[0146] Each cache item has a cache timestamp, validity period, and version number. The cache timestamp is the time the data was stored in the cache, and the validity period is the validity period of the data. The version package is used to determine whether the data has been updated.

[0147] In this step, the current time and the cache timestamp corresponding to the cache item are obtained, and the interval between the current time and the cache timestamp is calculated. If the interval is greater than the valid duration, the cache item is determined to be expired. If the interval is not greater than the valid duration, the cache item is determined to be not expired.

[0148] Step 502: When the cache entry has not expired, determine to release the connection request.

[0149] In this step, if the cache entry has not expired, it means that the target IP address and port number are found in the dynamic configuration table, and the connection request is allowed.

[0150] Step 503: When the cache item expires, obtain the first version number corresponding to the cache item and the second version number corresponding to the shared memory dictionary.

[0151] In this step, when the cache item corresponding to the target data expires, the version number corresponding to the cache item is obtained and determined as the first version number. At the same time, the version number corresponding to the shared memory dictionary is obtained and determined as the second version number.

[0152] Step 504: When the first version number and the second version number are consistent, the cache expiration time corresponding to the cache item is reset, and the connection request is released.

[0153] In this step, the first version number is compared with the second version number to determine whether they are consistent. If the version numbers are consistent, it indicates that the cached data and the data in the shared memory dictionary have not changed. At this time, the expiration time of the cached item is reset. At the same time, because the target IP address and port number are found, the connection request is allowed.

[0154] Step 505: When the first version number and the second version number are inconsistent, the target data is queried from the shared memory dictionary. When the target data is found from the shared memory dictionary, the data item and version number corresponding to the target data are loaded into the LRU cache, and it is determined to release the connection request. When the target data is not found from the shared memory dictionary, it is determined not to release the connection request.

[0155] In this step, when the first version number and the second version number are inconsistent, the target data is queried in the shared memory dictionary. When the target data is queried from the shared memory dictionary, the data item and version number corresponding to the target data are obtained, the data item and version number corresponding to the target data are loaded into the LRU cache, and it is determined to release the connection request. When the target data is not queried from the shared memory dictionary, it means that the dynamic configuration table does not have the target IP address and port number, and it is determined not to release the connection request.

[0156] In an embodiment of the present application, based on the target listener configuration data queried based on the target IP address and port number, the target listener configuration data may contain domain name configuration data that matches the SNI domain name, or may not contain corresponding configuration data. When the domain name configuration data corresponding to the SNI domain name information does not exist in the target listener configuration data, the default configuration data can be determined as the target domain name configuration data to ensure that the communication connection can still be established through the default security policy when there is no precise matching rule, avoiding request failures due to missing configuration. When the domain name configuration corresponding to the SNI domain name information exists in the target listener configuration data, the domain name configuration is determined as the target domain name configuration data. Therefore, an embodiment of the present application provides a method for determining target domain name configuration data, such as Figure 6 As shown, the specific steps include:

[0157] Step 601 : Detect whether there is domain name configuration data associated with the SNI domain name information in the target listener configuration data queried based on the target IP address and port number.

[0158] In this step, the corresponding data item is queried according to the target IP address and port number, and is determined as the target listener configuration data. Subsequently, in the target listener configuration data, it is detected whether there is domain name configuration data associated with the SNI domain name information.

[0159] Step 602: When the target listener configuration data includes domain name configuration data associated with the SNI domain name information, the domain name configuration data is determined as target domain name configuration data.

[0160] In this step, when the domain name configuration data associated with the SNI domain name information is found in the target listener configuration data, the found domain name configuration data is determined as the target domain name configuration data.

[0161] Step 603: When the domain name configuration data associated with the SNI domain name information does not exist in the target listener configuration data, the default configuration data is determined as the target domain name configuration data.

[0162] In this step, the load balancer also stores a default configuration. This default configuration is the default configuration data for the listener corresponding to the IP address and port when the SNI domain name information is not specified. If the domain name configuration data associated with the SNI domain name information is not found in the target listener configuration data, the default configuration data is obtained and determined as the target domain name configuration data.

[0163] like Figure 7 As shown, an embodiment of the present application provides a schematic diagram of a configuration hot update method for a load balancing device, which shows a configuration update and process interaction process architecture diagram based on the collaboration between the Nginx service and the Neutron working process. In this architecture diagram, in the load balancing device, configuration files such as nginx.conf, stream_dyups.json, and stream_upstream.conf are arranged, and when Neutron is started, these configuration files are loaded into the content storage, data initialization is completed, and an initial dynamic configuration table is formed. Among them, during the data initialization process, the data in the stream_dyups.json configuration file is stored in the Lua shared dict shared dictionary of the Shared Memory shared memory, and the stream_upstream.conf configuration file is also stored in the shared memory. Afterwards, the ngx_stream_dyups_module and ngx_stream_upstream_check modules are controlled through the dyups http API to update the upstream data. Through the dyups http API, the data in the Lua shared dict shared dictionary is directly updated. At the same time, LRUCache (ngx_stream_lua) implements the caching logic, and a cache miss or timeout triggers a specific process.

[0164] Among them, Neutron is the management and control terminal, responsible for initialization and synchronization of configuration to the Nginx system.

[0165] like Figure 8 As shown, an embodiment of the present application provides a configuration hot update device for a load balancer, which corresponds to the method embodiment and specifically includes:

[0166] An acquiring unit 801 is configured to acquire a first configuration file and a second configuration file, wherein the first configuration file includes all configuration parameters of each listener, and the second configuration file includes relevant data of an initial backend server;

[0167] A starting unit 802 is configured to start the Nginx service in the load balancer, load the first configuration file and the second configuration file into the memory of the load balancer, and obtain an initial dynamic configuration table;

[0168] The changing unit 803 is configured to receive a configuration change request through a preset interface, and to change the configuration data in the initial dynamic configuration table based on the configuration change request to obtain a target dynamic configuration table;

[0169] The receiving unit 804 is configured to receive, during the process of monitoring the pre-listening port using the listener template configuration in the Nginx service, a connection request sent by a client through the pre-listening port, the connection request carrying the target IP address, port number, and server name indication (SNI) domain name information;

[0170] The determination unit 805 is used to determine whether to release the connection request based on the target IP address and port number. When the connection request is released, the TLS handshake phase is entered, the target domain name configuration data corresponding to the SNI domain name information is determined, and the target domain name configuration data is dynamically injected into the new connection established based on the connection request.

[0171] Optionally, the initial dynamic configuration table includes a shared memory dictionary corresponding to the first configuration file. When the configuration change request is received through the first interface, the configuration change request is used to change data in the shared memory dictionary. The changing unit 803 is configured to:

[0172] According to the configuration change request, data in the shared memory dictionary is changed to obtain a changed shared memory dictionary.

[0173] Optionally, the initial dynamic configuration table includes logical upstream data of the backend server group obtained based on the second configuration file. When the configuration change request is received through the second interface, the configuration change request is used to update the upstream data. The changing unit 803 is used to:

[0174] According to the configuration change request, change the upstream data corresponding to the current working process;

[0175] After changing the upstream data corresponding to the current working process, the process identifier of the current working process is added to the process list corresponding to the change message, the operation count of the change message is increased by 1, and a change message is generated based on the change content in the configuration change request, the process list, and the operation count. The change message is attached to a bidirectional linked list in the form of a target, so that other working processes change the corresponding upstream data according to the change message on the bidirectional linked list;

[0176] The process list is used to store identifiers of working processes that have executed change operations.

[0177] Optionally, the changing unit 803 is configured to:

[0178] Obtain other process identifiers of the other working processes;

[0179] Detecting whether the other process identifier exists in the process list of the change message;

[0180] When the other process identifier does not exist in the process list of the change message, the corresponding upstream data is changed according to the change content in the change message, the other process identifier is added to the process list of the change message, and the operation count of the change message is increased by 1.

[0181] Optionally, the apparatus further includes a detection unit 806, wherein the detection unit 806 is configured to:

[0182] Checking whether the operation count is equal to the total number of working processes;

[0183] When the operation count is equal to the total number of working processes, the change message is destroyed to release memory.

[0184] Optionally, the determining unit 805 is configured to:

[0185] In the LRU cache of the current working process, query whether the target data exists, wherein the target data is the target IP address and port number;

[0186] When the target data exists in the LRU cache of the current working process, determining whether to release the connection request according to the cache entry corresponding to the target data in the LRU cache;

[0187] When the target data does not exist in the LRU cache of the current working process, the shared memory dictionary is queried to determine whether the target data exists, and when the target data exists in the shared memory dictionary, it is determined to release the connection request; when the target data does not exist in the shared memory dictionary, it is determined not to release the connection request.

[0188] Optionally, the determining unit 805 is configured to:

[0189] Detecting whether the cache item is expired;

[0190] When the cache item has not expired, determining to release the connection request;

[0191] When the cache item expires, obtaining a first version number corresponding to the cache item and a second version number corresponding to the shared memory dictionary;

[0192] When the first version number and the second version number are consistent, resetting the cache expiration time corresponding to the cache item and determining to release the connection request;

[0193] When the first version number and the second version number are inconsistent, the target data is queried from the shared memory dictionary. When the target data is found from the shared memory dictionary, the data item and version number corresponding to the target data are loaded into the LRU cache, and it is determined to release the connection request. When the target data is not found from the shared memory dictionary, it is determined not to release the connection request.

[0194] Optionally, the determining unit 805 is configured to:

[0195] In the target listener configuration data queried based on the target IP address and port number, detecting whether there is domain name configuration data associated with the SNI domain name information;

[0196] When domain name configuration data associated with the SNI domain name information exists in the target listener configuration data, determining the domain name configuration data as target domain name configuration data;

[0197] When the domain name configuration data associated with the SNI domain name information does not exist in the target listener configuration data, the default configuration data is determined as the target domain name configuration data.

[0198] like Figure 9 As shown, the embodiment of the present application provides a configuration hot update device for a load balancer, including a processor 901, a communication interface 902, a memory 903 and a communication bus 904, wherein the processor 901, the communication interface 902, and the memory 903 communicate with each other through the communication bus 904.

[0199] Memory 903, used for storing computer programs;

[0200] In one embodiment of the present application, the processor 901 is configured to execute a program stored in the memory 903 to implement the load balancer configuration hot update method provided by any of the aforementioned method embodiments, including:

[0201] Obtain a first configuration file and a second configuration file, wherein the first configuration file includes all configuration parameters of each listener, and the second configuration file includes relevant data of the initial backend server;

[0202] Starting the Nginx service in the load balancer, loading the first configuration file and the second configuration file into the memory of the load balancer, and obtaining an initial dynamic configuration table;

[0203] receiving a configuration change request through a preset interface, and changing the configuration data in the initial dynamic configuration table based on the configuration change request to obtain a target dynamic configuration table;

[0204] In the process of using the listener template configuration in the Nginx service to listen to the pre-listening port, receiving a connection request sent by the client through the pre-listening port, the connection request carrying the target IP address, port number and server name indication (SNI) domain name information;

[0205] Based on the target IP address and port number, determine whether to release the connection request. When the connection request is released, enter the TLS handshake phase, determine the target domain name configuration data corresponding to the SNI domain name information, and dynamically inject the target domain name configuration data into the new connection established based on the connection request.

[0206] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps performed by the method for hot updating the configuration of a load balancing device provided in any of the aforementioned method embodiments are implemented.

[0207] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one place or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of this embodiment.

[0208] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a general hardware platform, or of course, by hardware. Based on this understanding, the above technical solution, in essence, or the part that contributes to the relevant technology, can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or certain parts of the embodiment.

[0209] It should be understood that the terms used herein are for the purpose of describing specific example embodiments only and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "comprise", "include", "contain" and "have" are inclusive and therefore specify the presence of stated features, steps, operations, elements and / or parts, but do not exclude the presence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not to be construed as necessarily requiring them to be performed in the specific order described or illustrated, unless the order of execution is clearly indicated. It should also be understood that additional or alternative steps may be used.

[0210] The foregoing description is intended only to provide specific embodiments of the present invention, which will enable those skilled in the art to understand and implement the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not intended to be limited to the embodiments shown herein, but is intended to be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for hot updating configuration of a load balancer, characterized in that: The method comprises: Obtain a first configuration file and a second configuration file, wherein the first configuration file includes all configuration parameters of each listener, and the second configuration file includes relevant data of the initial backend server; Starting the Nginx service in the load balancer, loading the first configuration file and the second configuration file into the memory of the load balancer, and obtaining an initial dynamic configuration table; receiving a configuration change request through a preset interface, and changing the configuration data in the initial dynamic configuration table based on the configuration change request to obtain a target dynamic configuration table; In the process of using the listener template configuration in the Nginx service to listen to the pre-listening port, receiving a connection request sent by the client through the pre-listening port, the connection request carrying the target IP address, port number and server name indication (SNI) domain name information; Based on the target IP address and port number, determine whether to release the connection request. When the connection request is released, enter the TLS handshake phase, determine the target domain name configuration data corresponding to the SNI domain name information, and dynamically inject the target domain name configuration data into the new connection established based on the connection request.

2. The method according to claim 1, characterized in that The initial dynamic configuration table includes a shared memory dictionary corresponding to the first configuration file. When the configuration change request is received through the first interface, the configuration change request is used to change data in the shared memory dictionary. The configuration data in the initial dynamic configuration table is changed based on the configuration change request to obtain a target dynamic configuration table, including: According to the configuration change request, data in the shared memory dictionary is changed to obtain a changed shared memory dictionary.

3. The method according to claim 1, characterized in that The initial dynamic configuration table includes logical upstream data of the backend server group obtained based on the second configuration file. When the configuration change request is received through the second interface, the configuration change request is used to update the upstream data. The configuration data in the initial dynamic configuration table is changed based on the configuration change request to obtain a target dynamic configuration table, including: According to the configuration change request, change the upstream data corresponding to the current working process; After changing the upstream data corresponding to the current working process, the process identifier of the current working process is added to the process list corresponding to the change message, the operation count of the change message is increased by 1, and a change message is generated based on the change content in the configuration change request, the process list, and the operation count. The change message is attached to a bidirectional linked list in the form of a target, so that other working processes change the corresponding upstream data according to the change message on the bidirectional linked list; The process list is used to store identifiers of working processes that have executed change operations.

4. The method according to claim 3, characterized in that Changing the corresponding upstream data according to the change message on the bidirectional linked list includes: Obtain other process identifiers of the other working processes; Detecting whether the other process identifier exists in the process list of the change message; When the other process identifier does not exist in the process list of the change message, the corresponding upstream data is changed according to the change content in the change message, the other process identifier is added to the process list of the change message, and the operation count of the change message is increased by 1.

5. The method according to claim 4, characterized in that: The method further comprises: Checking whether the operation count is equal to the total number of working processes; When the operation count is equal to the total number of working processes, the change message is destroyed to release memory.

6. The method according to claim 2, characterized in that: The determining whether to allow the connection request based on the target IP address and port number includes: In the LRU cache of the current working process, query whether the target data exists, wherein the target data is the target IP address and port number; When the target data exists in the LRU cache of the current working process, determining whether to release the connection request according to the cache entry corresponding to the target data in the LRU cache; When the target data does not exist in the LRU cache of the current working process, the shared memory dictionary is queried to determine whether the target data exists, and when the target data exists in the shared memory dictionary, it is determined to release the connection request; when the target data does not exist in the shared memory dictionary, it is determined not to release the connection request.

7. The method according to claim 6, characterized in that The determining whether to release the connection request according to a cache entry corresponding to the target data in the LRU cache includes: Detecting whether the cache item is expired; When the cache item has not expired, determining to release the connection request; When the cache item expires, obtaining a first version number corresponding to the cache item and a second version number corresponding to the shared memory dictionary; When the first version number and the second version number are consistent, resetting the cache expiration time corresponding to the cache item and determining to release the connection request; When the first version number and the second version number are inconsistent, the target data is queried from the shared memory dictionary. When the target data is found from the shared memory dictionary, the data item and version number corresponding to the target data are loaded into the LRU cache, and it is determined to release the connection request. When the target data is not found from the shared memory dictionary, it is determined not to release the connection request.

8. The method according to claim 1, characterized in that: The determining of the target domain name configuration data corresponding to the SNI domain name information includes: In the target listener configuration data queried based on the target IP address and port number, detecting whether there is domain name configuration data associated with the SNI domain name information; When domain name configuration data associated with the SNI domain name information exists in the target listener configuration data, determining the domain name configuration data as target domain name configuration data; When the domain name configuration data associated with the SNI domain name information does not exist in the target listener configuration data, the default configuration data is determined as the target domain name configuration data.

9. A configuration hot update device for a load balancer, characterized in that: The device comprises: an acquiring unit, configured to acquire a first configuration file and a second configuration file, wherein the first configuration file includes all configuration parameters of each listener, and the second configuration file includes relevant data of the initial backend server; A starting unit, configured to start the Nginx service in the load balancing device, load the first configuration file and the second configuration file into the memory of the load balancing device, and obtain an initial dynamic configuration table; a changing unit, configured to receive a configuration change request through a preset interface, and to change the configuration data in the initial dynamic configuration table based on the configuration change request to obtain a target dynamic configuration table; A receiving unit is configured to receive a connection request sent by a client through the pre-listening port during a process of listening to the pre-listening port using the listener template configuration in the Nginx service, wherein the connection request carries the target IP address, port number, and server name indication (SNI) domain name information; A determination unit is used to determine whether to release the connection request based on the target IP address and port number. When the connection request is released, the TLS handshake phase is entered, the target domain name configuration data corresponding to the SNI domain name information is determined, and the target domain name configuration data is dynamically injected into the new connection established based on the connection request.

10. A configuration hot update device for a load balancer, characterized in that: include: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; at least one memory connected to the at least one bus, wherein the processor is configured to: Obtain a first configuration file and a second configuration file, wherein the first configuration file includes all configuration parameters of each listener, and the second configuration file includes relevant data of the initial backend server; Starting the Nginx service in the load balancer, loading the first configuration file and the second configuration file into the memory of the load balancer, and obtaining an initial dynamic configuration table; receiving a configuration change request through a preset interface, and changing the configuration data in the initial dynamic configuration table based on the configuration change request to obtain a target dynamic configuration table; In the process of using the listener template configuration in the Nginx service to listen to the pre-listening port, receiving a connection request sent by the client through the pre-listening port, the connection request carrying the target IP address, port number and server name indication (SNI) domain name information; Based on the target IP address and port number, determine whether to release the connection request. When the connection request is released, enter the TLS handshake phase, determine the target domain name configuration data corresponding to the SNI domain name information, and dynamically inject the target domain name configuration data into the new connection established based on the connection request.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the configuration hot update method of the load balancer according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Realization method and device of safe acceleration middleware based on NGINX+LUA

    CN106657258A

  • Request processing method and device, electronic equipment and storage medium

    CN113014683A

  • Configuration updating method and device and electronic equipment

    CN114785686A

  • Dynamic load balancing method and device, medium and electronic equipment

    CN116436921A

  • Method, system and device for dynamically modifying nginx configuration parameters, and storage medium

    WO2021082081A1