Disclosure of Invention
In order to solve the above problems, it is necessary to provide a system and method for a nsiinx configured hot update based on the DPDK technique.
The first aspect of the present invention provides a DPDK-based Nginx configured hot update system, including: user mode, kernel mode and bottom hardware module; the bottom hardware module is used for storing an Nginx configuration file; the user mode comprises an Nginx application layer, a user mode protocol stack and a DPDK drive layer; the Nginx application layer provides web service and reverse proxy service according to the Nginx configuration file; the user mode protocol stack is used for carrying out protocol analysis or protocol encapsulation processing on the receiving and sending packets; the DPDK driving layer bypasses a kernel mode protocol stack by adopting a data plane library provided by the DPDK driving layer so as to perform packet receiving and sending processing; the kernel mode is used for replacing and accessing the Nginx configuration file stored in the bottom layer hardware module according to the requirement of the user mode;
when the system receives a modification instruction of a user on the Nginx original configuration file, generating a Nginx updating configuration file and generating a corresponding Nginx configuration file updating instruction;
receiving the Nginx configuration file updating instruction by a main process of a user mode, and informing all work processes managed by the main process of the Nginx configuration file updating instruction;
rereading the Nginx updating configuration file and the Nginx original configuration file by each working process according to the Nginx configuration file updating instruction;
each working process respectively compares the Nginx updating configuration file with the Nginx original configuration file and determines difference information;
and the Nginx application layer closes an invalid monitoring port according to the difference information and/or opens a newly added monitoring port.
Further, the difference information is characterized by:
the Nginx updated configuration file is compared with the newly added partial configuration information of the Nginx original configuration file; or
A reduced portion of configuration information for the Nginx update profile as compared to the Nginx original profile; or
The Nginx update configuration file updates a portion of the configuration information that is changed compared to the Nginx original configuration file.
Further, the Nginx application layer and the DPDK driver layer share a process of a kernel state.
Further, the bottom hardware module is a hard disk and/or a memory.
Further, the number of the working processes is at least two.
The second aspect of the present invention further provides a method for thermal update of Nginx configuration based on the DPDK technique, where the method includes:
configuring a user mode, a kernel mode and a bottom hardware module; wherein the bottom layer hardware module is used for storing a Nginx configuration file; the user mode comprises an Nginx application layer, a user mode protocol stack and a DPDK drive layer; the Nginx application layer provides web service and reverse proxy service according to the Nginx configuration file; the user mode protocol stack is used for carrying out protocol analysis or protocol encapsulation processing on the receiving and sending packets; the DPDK driving layer bypasses a kernel mode protocol stack by adopting a data plane library provided by the DPDK driving layer so as to perform packet receiving and sending processing; the kernel mode is used for replacing and accessing the Nginx configuration file stored in the bottom layer hardware module according to the requirement of the user mode;
receiving a modification instruction of a user on the Nginx original configuration file, generating a Nginx updating configuration file, and generating a corresponding Nginx configuration file updating instruction;
receiving the Nginx configuration file updating instruction by the main process, and informing all the working processes managed by the main process of the Nginx configuration file updating instruction;
rereading the Nginx updating configuration file and the Nginx original configuration file by each working process according to the Nginx configuration file updating instruction;
each working process respectively compares the Nginx updating configuration file with the Nginx original configuration file and determines difference information;
and closing the invalid monitoring port according to the difference information, and/or opening a newly added monitoring port.
Further, the difference information is characterized by:
the Nginx updated configuration file is compared with the newly added partial configuration information of the Nginx original configuration file; or
A reduced portion of configuration information for the Nginx update profile as compared to the Nginx original profile; or
The Nginx update configuration file updates a portion of the configuration information that is changed compared to the Nginx original configuration file.
Further, the Nginx application layer and the DPDK driver layer share a process of a kernel state.
Further, the bottom hardware module is a hard disk and/or a memory.
Further, the number of the working processes is at least two.
The system and the method for Nginx configuration hot update based on the DPDK technology can enable the Nginx update configuration file to take effect by using the current working process without starting a new working process, and corresponding services can not be interrupted because the working process is not restarted, thereby realizing high-performance web service and reverse proxy service. Meanwhile, the DPDK driving layer and the user mode protocol stack provide high-performance network throughput capability, save hardware resources and network resources, reduce networking difficulty and generate certain economic benefit and social benefit.
Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention.
Detailed Description
In order that the above objects, features and advantages of the present invention can be more clearly understood, a more particular description of the invention will be rendered by reference to the appended drawings. It should be noted that the embodiments and features of the embodiments of the present application may be combined with each other without conflict.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention, however, the present invention may be practiced in other ways than those specifically described herein, and therefore the scope of the present invention is not limited by the specific embodiments disclosed below.
Fig. 2 shows a block diagram of an Nginx configured hot update system based on DPDK technology according to the present invention.
As shown in fig. 2, a first aspect of the present invention provides a system for a nsinx configured hot-update based on a DPDK technique, where the system includes: user mode, kernel mode and bottom hardware module; the bottom hardware module is used for storing an Nginx configuration file; the user mode comprises an Nginx application layer, a user mode protocol stack and a DPDK drive layer; the Nginx application layer provides web service and reverse proxy service according to the Nginx configuration file; the user mode protocol stack is used for carrying out protocol analysis or protocol encapsulation processing on the receiving and sending packets; the DPDK driving layer bypasses a kernel mode protocol stack by adopting a data plane library provided by the DPDK driving layer so as to perform packet receiving and sending processing; the kernel mode is used for replacing and accessing the Nginx configuration file stored in the bottom layer hardware module according to the requirement of the user mode;
when the system receives a modification instruction of a user on the Nginx original configuration file, generating a Nginx updating configuration file and generating a corresponding Nginx configuration file updating instruction;
receiving the Nginx configuration file updating instruction by a main process of a user mode, and informing all work processes managed by the main process of the Nginx configuration file updating instruction;
rereading the Nginx updating configuration file and the Nginx original configuration file by each working process according to the Nginx configuration file updating instruction;
each working process respectively compares the Nginx updating configuration file with the Nginx original configuration file and determines difference information;
and the Nginx application layer closes an invalid monitoring port according to the difference information and/or opens a newly added monitoring port.
Preferably, the system of the present invention can run on a terminal device based on the Linux operating system, but is not limited thereto.
It should be noted that, the main process (master) is used to create a work in/thread such as a Manager process and a Reactor thread, and the Reactor thread is used to accept the link of the application program and the sent request; the Manager process is a management process used to create and manage all work processes. And all business logics are carried out in the process, and when the Reactor thread receives data from the application program, the data are packaged and sent to a certain work process through a pipeline.
It should be noted that the DPDK driver layer operates in a user mode of the Linux operating system, performs packet receiving and sending processing by using a data plane library provided by the DPDK driver layer, and bypasses a Linux kernel mode protocol stack to improve the processing efficiency of a packet. The DPDK driving layer is a set of lib libraries and toolkits, and the main components comprise:
PMD drive module (Pool Mode Driver, polling Mode drive): the efficiency of sending/receiving the data frame is improved through a non-interruption and zero-copy mechanism of the data frame entering and exiting the application buffer memory;
flow Classification processing module (Flow Classification): providing an optimized search algorithm for N-tuple matching and LPM (longest prefix matching);
lock Ring-free Queue module (Ring Queue): a lock-free mechanism is provided for the access queues of a single or a plurality of data packet producers and a single data packet consumer, so that the system overhead is effectively reduced;
MBUF buffer management Module: allocating a memory to create a buffer area, and encapsulating an actual data frame by establishing an MBUF object for an application program to use;
environment abstraction Layer (Environment Abstract Layer): the method is used for system initialization such as PMD initialization, CPU kernel and DPDK thread configuration/binding, Huge Page large-Page memory setting and the like.
The user protocol stack is the sum of all layers of protocols in the network, which vividly reflects the process of file transmission in the network, from an upper layer protocol to a bottom layer protocol, and then from the bottom layer protocol to the upper layer protocol.
Further, the difference information is characterized by:
the Nginx updated configuration file is compared with the newly added partial configuration information of the Nginx original configuration file; or
A reduced portion of configuration information for the Nginx update profile as compared to the Nginx original profile; or
The Nginx update configuration file updates a portion of the configuration information that is changed compared to the Nginx original configuration file.
It can be understood that, if the difference information is newly added partial configuration information, the nginnx application layer opens a newly added monitoring port according to the newly added partial configuration information; if the difference information is reduced partial configuration information, the Nginx application layer closes a reduced (namely invalid) monitoring port according to the reduced partial configuration information; and if the difference information is changed partial configuration information, the Nginx application layer opens the changed monitoring port according to the changed partial configuration information and closes the monitoring port before the change.
According to an embodiment of the present invention, the Nginx application layer and the DPDK driver layer share one process of a kernel state.
According to the embodiment of the invention, the bottom hardware module is a hard disk and/or a memory.
Specifically, the number of the work processes is at least two.
Fig. 3 shows a flowchart of a method for thermal update of a nginnx configuration based on DPDK technique according to the present invention.
As shown in fig. 3, the second aspect of the present invention further provides a method for Nginx configuration thermal update based on DPDK technique, where the method includes:
receiving a modification instruction of a user on the Nginx original configuration file, generating a Nginx updating configuration file, and generating a corresponding Nginx configuration file updating instruction;
receiving the Nginx configuration file updating instruction by the main process, and informing all the working processes managed by the main process of the Nginx configuration file updating instruction;
rereading the Nginx updating configuration file and the Nginx original configuration file by each working process according to the Nginx configuration file updating instruction;
each working process respectively compares the Nginx updating configuration file with the Nginx original configuration file and determines difference information;
and closing the invalid monitoring port according to the difference information, and/or opening a newly added monitoring port.
Further, the difference information is characterized by:
the Nginx updated configuration file is compared with the newly added partial configuration information of the Nginx original configuration file; or
A reduced portion of configuration information for the Nginx update profile as compared to the Nginx original profile; or
The Nginx update configuration file updates a portion of the configuration information that is changed compared to the Nginx original configuration file.
Further, the Nginx application layer and the DPDK driver layer share a process of a kernel state.
Further, the bottom hardware module is a hard disk and/or a memory.
Further, the number of the working processes is at least two.
The system and the method for Nginx configuration hot update based on the DPDK technology can enable the Nginx update configuration file to take effect by using the current working process without starting a new working process, and corresponding services can not be interrupted because the working process is not restarted, thereby realizing high-performance web service and reverse proxy service. Meanwhile, the DPDK driving layer and the user mode protocol stack provide high-performance network throughput capability, save hardware resources and network resources, reduce networking difficulty and generate certain economic benefit and social benefit.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.