A feedback method and device based on ring deployment
The ring-shaped deployment of Java applications across Docker containers with Nginx routing addresses the instability of single-process Java deployments, ensuring load balancing and high availability.
Patent Information
- Application Number
- CN202211395407.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-09
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2042-11-09
AI Technical Summary
During the deployment process, load balancing cannot be achieved due to the operation of a single process. Single process is prone to downtime and cannot be managed and allocated by multiple processes.
Using a feedback method based on ring deployment, the appropriate Docker container IP address is selected from multiple Docker containers in the server cluster through Nginx configuration files, and multiple JAVA programs are deployed in different orders in each container, and load balancing and high availability are achieved using the interaction between the load balancer and the server cluster.
It realizes load balancing and high availability of Java programs, avoids downtime caused by exceptions in a single process, can dynamically expand capacity and perform container heartbeat detection through the monitoring platform, ensuring the smooth operation of the service.
Smart Images

Figure CN115865927B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a feedback method and device based on ring deployment. Background Art
[0002] There are two main ways to deploy a Java project: one way is to package the Java project into a xxx.jar package through a tool, upload the packaged xxx.jar package to the server, start the project through the command java-jar xxx.jar, and the project provides external access services after startup; the other way is to package the Java project into a war package through a tool, build a tomcat service on the server, place the generated war package in the web apps directory of tomcat, and start the tomcat program to provide external access services.
[0003] The above two deployment methods have the following problems: Java projects are all run as a single process, so all access requests will fall on a single process, and a single process program is prone to downtime when handling high-concurrency programs; in addition, a single process is prone to exiting due to program exceptions; further, when a single process is running, even if multiple processes are started, it is impossible to manage and allocate multiple processes because there is no tool for managing multiple processes. Summary of the invention
[0004] The embodiment of the present invention provides a feedback method and device based on ring deployment, which is used to solve the problem that the Java program cannot achieve load balancing due to running in a single process mode during the actual deployment process and the Java program cannot be highly available using a single node deployment.
[0005] The embodiment of the present invention provides a feedback method based on ring deployment, which is applied to a load balancing server side, including:
[0006] In response to a first message carrying a request sent by a client, selecting a first Docker container IP address that matches a first source IP address included in the first message from multiple Docker container IP addresses included in the server cluster according to rule matching in an Nginx configuration file, and using the first Docker container IP address as a second destination IP address to replace the first destination IP address to form a second message;
[0007] Send the second message carrying the said request to the first Docker container corresponding to the second destination IP address, so that the load balancer selects the first JAVA program that is currently available from the multiple JAVA programs included in the first Docker container to run the request, and obtains a data packet corresponding to the request; replace the second destination IP address with the first source IP address as the third destination IP address to form a third message, and feedback the third message carrying the data packet to the load balancer; wherein, the multiple JAVA programs are deployed in each Docker container in different orders;
[0008] In response to the third message carrying the data packet feedback by the server cluster, replace the first destination IP address with the third source IP address as the fourth source IP address to obtain a fourth message, and feedback the fourth message carrying the data packet to the client.
[0009] Preferably, before the matching rule according to the Nginx configuration file, it further includes:
[0010] Determine the name of the server cluster, set multiple Docker containers in the server cluster, and determine the Docker container IP address corresponding to each Docker container;
[0011] Add the API address accessible to each Docker container to the Nginx configuration file, and the API address corresponds to the Docker container IP address.
[0012] Preferably, it further includes:
[0013] Deploy N different JAVA programs in each Docker container in sequence, so that the N different JAVA programs are arranged in different orders in each Docker container, and N is a positive integer.
[0014] Preferably, it further includes:
[0015] Add a newly created Docker container in the server cluster, and determine the newly created Docker container IP address corresponding to the newly created Docker container;
[0016] Add the N different JAVA programs running in the Docker container to the newly created Docker container, and the arrangement order of the N different JAVA programs in the newly created Docker container is different from the arrangement order of the N different JAVA programs in each Docker container;
[0017] Add the API address accessible to the newly created Docker container to the Nginx configuration file, where the API address corresponds to the IP address of the newly created Docker container;
[0018] Add a newly created Docker container to the monitoring platform so that the monitoring platform monitors the heartbeat of the newly created Docker container.
[0019] An embodiment of the present invention provides a feedback method based on circular deployment, which is applied to the server cluster side and includes:
[0020] In response to a second message carrying a request sent by a load balancer server, determine a first Docker container capable of executing the request according to a second destination IP address included in the second message, and select a first JAVA program currently available from multiple JAVA programs included in the first Docker container to run the request, obtaining a data packet corresponding to the request; wherein, the second destination IP address included in the second message is the IP address of the first Docker container, and the multiple JAVA programs are deployed in different Docker containers in different orders;
[0021] Replace the second destination IP address with a first source IP address included in the second message as a third destination IP address to form a third message;
[0022] Send the third message carrying the data packet to the load balancer server so that the load balancer server replaces the third source IP address with a first destination IP address as a fourth source IP address, obtaining a fourth message, and feeds back the fourth message carrying the data packet to the client.
[0023] Preferably, before the step of responding to the second message carrying a request sent by the load balancer server, it further includes:
[0024] Deploy N different JAVA programs in multiple Docker containers included in the server cluster in sequence, and determine that the N different JAVA programs are arranged in different orders in each Docker container, where N is a positive integer.
[0025] An embodiment of the present invention provides a feedback device based on circular deployment, including:
[0026] The first response unit is configured to respond to a first message carrying a request sent by a client, match according to rules in the Nginx configuration file, select a first Docker container IP address that matches the first source IP address included in the first message from multiple Docker container IP addresses included in the server cluster, use the first Docker container IP address as the second destination IP address, and replace the first destination IP address to form a second message;
[0027] The feedback unit is configured to send the second message carrying the request to the first Docker container corresponding to the second destination IP address, so that the load balancer runs the request from multiple JAVA programs included in the first Docker container to select a currently available first JAVA program, and obtain a data packet corresponding to the request; use the first source IP address to replace the second destination IP address as the third destination IP address to form a third message, and feedback the third message carrying the data packet to the load balancer; wherein, the multiple JAVA programs are deployed in each Docker container in different orders;
[0028] The second response unit is configured to respond to the third message carrying the data packet feedback by the server cluster, replace the third source IP address with the first destination IP address as the fourth source IP address to obtain a fourth message, and feedback the fourth message carrying the data packet to the client.
[0029] An embodiment of the present invention provides a feedback device based on circular deployment, including:
[0030] The first response unit is configured to respond to a second message carrying a request sent by a load balancing server, determine a first Docker container capable of executing the request according to the second destination IP address included in the second message, and select a currently available first JAVA program from multiple JAVA programs included in the first Docker container to run the request, and obtain a data packet corresponding to the request; wherein, the second destination IP address included in the second message is the first Docker container IP address, and the multiple JAVA programs are deployed in different Docker containers in different orders;
[0031] The forming unit is configured to use the first source IP address included in the second message to replace the second destination IP address as the third destination IP address to form a third message;
[0032] A feedback unit, configured to send the third message carrying the data packet to a load balancing server, so that the load balancing server replaces the third source IP address with a first destination IP address as a fourth source IP address, obtains a fourth message, and feeds back the fourth message carrying the data packet to a client.
[0033] An embodiment of the present invention provides a computer device, which includes: a processor and a memory; the memory is used to store computer program code, and the computer program code includes computer instructions; when the processor executes the computer instructions, the computer device executes the above-mentioned feedback method based on ring deployment.
[0034] An embodiment of the present invention provides a computer-readable storage medium, including computer instructions, which, when running on a computer device, cause the computer device to execute the above-mentioned feedback method based on ring deployment.
[0035] An embodiment of the present invention provides a feedback method and device based on circular deployment. The method is applied to the load balancing server side and includes: in response to a first packet carrying a request sent by a client, according to rules matching in the Nginx configuration file, select a first Docker container IP address that matches the first source IP address included in the first packet from the multiple Docker container IP addresses included in the server cluster, use the first Docker container IP address as the second destination IP address, and replace the first destination IP address to form a second packet; send the second packet carrying the request to the first Docker container corresponding to the second destination IP address, so that the load balancer runs the request from the multiple JAVA programs included in the first Docker container to select the currently available first JAVA program, and obtain a data packet corresponding to the request; use the first source IP address to replace the second destination IP address as the third destination IP address to form a third packet, and feedback the third packet carrying the data packet to the load balancer; wherein, the multiple JAVA programs are deployed in each Docker container in different orders; in response to the third packet carrying the data packet feedback by the server cluster, use the first destination IP address to replace the third source IP address as the fourth source IP address to obtain a fourth packet, and feedback the fourth packet carrying the data packet to the client. In this method, the server cluster includes multiple Docker containers, each Docker container deploys multiple JAVA programs, and the multiple JAVA programs included in each Docker container have different deployment order methods, so as to realize the circular deployment of JAVA programs in Docker containers; by combining the IP address and port, find the first Docker container and the specific Java program from the multiple Docker containers included in the server cluster, which can solve the problem that the existing technology is prone to exceptions when running individually. Furthermore, through the interaction between the server cluster and the load balancer, the problem of unable to manage JAVA programs simultaneously can be solved. Brief Description of the Drawings
[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0037] Figure 1 It is one of the structural schematic diagrams of the feedback device based on circular deployment provided by the embodiment of the present invention;
[0038] Figure 2 Schematic flow diagram of the feedback method on the load - balancing server side based on ring deployment provided by an embodiment of the present invention;
[0039] Figure 3 Schematic diagram of the ring deployment structure of a JAVA program in a Docker container provided by an embodiment of the present invention;
[0040] Figure 4 Schematic flow diagram of the feedback method on the server cluster side based on ring deployment provided by an embodiment of the present invention;
[0041] Figure 5 Schematic diagram of the structure of the feedback device on the load - balancing server side based on ring deployment provided by an embodiment of the present invention;
[0042] Figure 6 Schematic diagram of the structure of the feedback device on the server cluster side based on ring deployment provided by an embodiment of the present invention. Detailed implementation manners
[0043] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without making creative efforts belong to the scope of protection of the present invention.
[0044] Hereinafter, the terms "first" and "second" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of the embodiments of the present disclosure, unless otherwise stated, the meaning of "a plurality" is two or more. Additionally, the use of "based on" or "according to" is meant to be open and inclusive, because a process, step, calculation, or other action "based on" or "according to" one or more of the stated conditions or values may in practice be based on additional conditions or values beyond those stated.
[0045] Terms involved in this application document:
[0046] Reverse Proxy: The reverse proxy method means that a proxy server accepts connection requests on the Internet, then forwards the requests to the servers on the internal network, and returns the results obtained from the servers to the clients on the Internet that requested the connection. At this time, the proxy server appears as a reverse proxy server to the outside;
[0047] Nginx is a high-performance HTTP and reverse proxy server, characterized by low memory occupancy and strong concurrency capabilities. Nginx's concurrency performance is relatively good among web servers of the same type. It is developed specifically for performance optimization, with performance being an important consideration. In implementation, it highly emphasizes efficiency and can withstand high loads. Reports show that it can support up to 50,000 concurrent connections.
[0048] Load balancing, whose English name is LoadBalance, means balancing and distributing the load (tasks) across multiple operating units for operation. Generally, it has two aspects of meaning: on the one hand, it distributes a single heavy load across multiple network nodes for parallel processing, and after each node finishes processing, the results are aggregated and returned to the user, which can significantly improve the processing capacity of the network system; the second aspect of meaning is that it distributes a large number of concurrent front-end accesses or data traffic across multiple back-end network nodes for separate processing, which can effectively reduce the waiting time for front-end users to receive responses.
[0049] In view of the problems that in the actual deployment process of existing Java programs, due to running in a single-process mode, a single-process program is prone to crashing when dealing with high-concurrency programs, and it is impossible to manage and allocate multiple processes through multi-process management tools during single-process operation, the embodiments of the present invention provide a feedback method and device based on circular deployment. Through this method, circular deployment of Java programs can be achieved. By cooperating with Nginx based on the circular deployment of Java programs, it can ensure that Java programs can continuously provide services externally in the production environment and ensure the stable operation of back-end services. Thus, it solves the problem that existing Java projects cannot achieve load balancing due to running in a single-process mode during the actual deployment process.
[0050] Figure 1 Exemplarily shows one of the structural schematic diagrams of the feedback device based on circular deployment provided by the embodiments of the present invention, as Figure 1 shown, the feedback device based on circular deployment may include: a processor 11, a memory 12, a communication interface 13, and a bus 14. The processor 11, the memory 12, and the communication interface 13 can be connected through the communication bus 14.
[0051] The processor 11 is the control center of the feedback device based on circular deployment. It can be a single processor 11 or a collective term for multiple processing elements. For example, the processor 11 can be a general central processing unit (CPU), or other general processors 11, etc. Among them, the general processor 11 can be a microprocessor 11 or any conventional processor 11, etc.
[0052] As an example, the processor 11 may include one or more CPUs. For example, Figure 1 the illustrated CPU0 and CPU1.
[0053] The memory 12 may be a read-only memory 12 (ROM) or other type of static storage device that can store static information and instructions, a random access memory 12 (RAM) or other type of dynamic storage device that can store information and instructions, or may also be an electrically erasable programmable read-only memory 12 (EEPROM), a magnetic disk storage medium, or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto.
[0054] In a possible implementation, the memory 12 may exist independently of the processor 11. The memory 12 may be connected to the processor 11 through the bus 14 for storing instructions or program code. When the processor 11 calls and executes the instructions or program code stored in the memory 12, the method for constructing a threat tree provided in the following embodiments of the present invention can be implemented.
[0055] In another possible implementation, the memory 12 may also be integrated with the processor 11.
[0056] The communication interface 13 is used for the threat tree construction device to be connected to other devices through a communication network. The communication network may be an Ethernet, a radio access network (RAN), a wireless local area network (WLAN), etc. The communication interface 13 may include a receiving unit for receiving data and a sending unit for sending data.
[0057] The bus 14 may be an Industry Standard Architecture (ISA) bus 14, a Peripheral Component Interconnect (PCI) bus 14, or an Extended Industry Standard Architecture (EISA) bus 14, etc. The bus 14 may be divided into an address bus 14, a data bus 14, a control bus 14, etc. For ease of representation, Figure 1It is represented by only a thick line in the figure, but it does not mean that there is only one bus 14 or one type of bus 14.
[0058] It should be noted that Figure 1 the structure shown in the figure does not constitute a limitation on the feedback device based on ring deployment. Except Figure 1 for the components shown, the feedback device based on ring deployment may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0059] The execution subject of the feedback method based on ring deployment provided by the embodiments of the present invention is a feedback device based on ring deployment. The feedback device based on ring deployment may be a terminal device, or a CPU in the terminal device, or a control module in the terminal device for feedback based on ring deployment, or a client in the terminal device for feedback based on ring deployment. In the embodiments of the present invention, taking the terminal device executing the feedback method based on ring deployment as an example, the feedback based on ring deployment provided by the present invention is described.
[0060] Further, based on the above system architecture, the embodiments of the present invention provide a schematic flow chart of the feedback method on the load balancer server side based on ring deployment. Refer to Figure 2 as shown in the figure, which mainly includes the following steps:
[0061] Step 101, in response to the first message carrying a request sent by the client, according to the rule matching in the Nginx configuration file, select the first Docker container IP address that matches the first source IP address included in the first message from the multiple Docker container IP addresses included in the server cluster, use the first Docker container IP address as the second destination IP address, and replace the first destination IP address to form a second message;
[0062] Step 102, send the second message carrying the request to the first Docker container corresponding to the second destination IP address, so that the load balancer runs the request from the multiple JAVA programs included in the first Docker container to select the currently available first JAVA program, and obtain a data packet corresponding to the request; use the first source IP address to replace the second destination IP address as the third destination IP address, form a third message, and feedback the third message carrying the data packet to the load balancer; among them, the multiple JAVA programs are deployed in each Docker container in different orders;
[0063] Step 103: In response to the third message carrying the data packet feedback by the server cluster, replace the first destination IP address with the third source IP address as the fourth source IP address to obtain a fourth message, and feedback the fourth message carrying the data packet to the client.
[0064] Specifically, before executing step 101, the load balancing server needs to first determine the name of the server cluster, set multiple Docker containers in the server cluster, and determine the Docker container IP address corresponding to each Docker container. That is, first configure the cluster server. Specifically, the name of the server cluster and each server included in the server cluster and the port corresponding to the server can be defined through the following programming languages:
[0065]
[0066] Among them, "upstream web_server" means using upstream to define the server cluster. In actual applications, the server cluster name can be arbitrary; "server 127.0.0.1:8001" means using server to define each server included in the server cluster and the port corresponding to each server.
[0067] Furthermore, add the API address accessible to each Docker container in the Nginx configuration file included in the server cluster. Here, the API address corresponds to the Docker container IP address. Specifically, it can be determined through the following programming languages:
[0068]
[0069]
[0070] In this way, every time the url http: / / 8000 / backend_api is accessed, Nginx will automatically forward the request to one of the programs at 127.0.0.1:8001 or 127.0.0.2:8002 for processing.
[0071] In step 101, the load balancing server receives the first message carrying the first request sent by the client, matches according to the rules in the Nginx configuration file, and selects the first Docker container IP address that matches the first source IP address included in the first message from the multiple Docker container IP addresses included in the load balancing server.
[0072] It should be noted that each Docker container included in the server cluster has a unique IP address, that is, each Docker container has its corresponding Docker container IP address. Therefore, the first Docker container IP address that matches the first source IP address can be selected from multiple Docker container IP addresses. The first Docker container IP address here is one of the multiple Docker container IP addresses. It is called the first Docker container IP address only to avoid confusion with other Docker container IP addresses in subsequent introductions.
[0073] In this embodiment, after the load balancing server determines the first Docker container IP address corresponding to the first request according to the first message, it is also necessary to modify the content of the first message to form a second message that can be forwarded. The load balancing server modifies the first destination IP address included in the first message to the first Docker container IP address, that is, the first Docker container IP address replaces the first destination IP address as the second destination IP address, so as to modify the first message to the second message.
[0074] It should be noted that the only difference between the above-mentioned first message and the second message is the difference between the first destination IP address and the second destination IP address. Among them, the first destination IP address is the IP address of the load balancing server itself, and the second destination IP address is the first Docker container IP address.
[0075] In step 102, the load balancing server sends the second message carrying the request to the first Docker container corresponding to the second destination IP address. Since multiple JAVA programs are deployed inside the first Docker container, in actual applications, each JAVA program has a set port number, and the second message carries the port number. Therefore, the server cluster can select the first JAVA program with a matching port number from the multiple JAVA programs included in the first Docker container to run the request carried by the second message. It should be noted that in order to distinguish from the multiple JAVA programs deployed in the Docker container, the JAVA program that runs the request is called the first JAVA program.
[0076] In the embodiment of the present invention, by combining the IP address and the port, the first Docker container and the specific Java program can be found from multiple Docker containers included in the server cluster, which can solve the problem that the existing technology is prone to exceptions when running individually.
[0077] In practical applications, a server cluster includes multiple Docker containers, and multiple JAVA programs are deployed in each Docker container. In the embodiment of the present invention, the number of JAVA programs deployed in each Docker container is equal, but the multiple JAVA programs are deployed in different orders within each Docker container. The schematic diagram of the deployment structure is as follows Figure 3 shown.
[0078] It should be noted that when deploying JAVA programs, the startup file or JAR package is copied to a certain set folder inside each Docker container. The path of this set folder can be specified by the operation and maintenance personnel, generally placed in the / opt directory of the Docker container, and then the startup command is edited through a bash script for batch startup. The specific path of the set folder is not limited here, as long as it ensures that the JAVA program can be started normally in the Docker container.
[0079] Further, after the first JAVA program runs the request carried in the second message, a data packet corresponding to the request can be obtained.
[0080] Further, while obtaining the data packet corresponding to the request through the first JAVA program, the server cluster needs to modify the second message to obtain a third message that can be used to forward the data packet. Specifically, the second destination IP address is replaced with the first source IP address to form the third destination IP address of the third message. The server cluster sends the data packet obtained by running the first JAVA program and the third message to the load balancer.
[0081] In step 103, when the load balancer receives the third message carrying the data packet sent by the server cluster, the third source IP address is replaced with the first destination IP address included in the third message to form the fourth source IP address of the fourth message, and then the fourth message carrying the data packet is fed back to the client, thereby completing the feedback on the first message carrying the request sent by the client.
[0082] In this method, the server cluster includes multiple Docker containers, and multiple JAVA programs are deployed inside each Docker container, and the multiple JAVA programs included in each Docker container have different deployment orders, so that the circular deployment of JAVA programs in the Docker container can be realized, thereby solving the problem that a single JAVA program is prone to exceptions during operation; furthermore, through the interaction between the server cluster and the load balancer, the problem of being unable to manage JAVA programs simultaneously can be solved.
[0083] Exemplarily, for the feedback method based on circular deployment provided by the embodiments of the present invention, when the access pressure of the client is too high, dynamic expansion can also be performed by adding newly created Docker containers within the server cluster. Specifically, when adding newly created Docker containers within the server cluster, it is necessary to determine the IP address of the newly created Docker container corresponding to the newly created Docker container; further, add N different JAVA programs running within the Docker container to the newly created Docker container, and the arrangement order of the N different JAVA programs within the newly created Docker container is different from the arrangement order of the N different JAVA programs within other Docker containers; then, add the API address accessible by the newly created Docker container to the Nginx configuration file, and the API address corresponds to the IP address of the newly created Docker container.
[0084] It should be noted that in the embodiments of the present invention, a monitoring platform is also provided. The monitoring platform mainly monitors each Docker container to achieve operations such as heartbeat detection and abnormal startup of the container. Therefore, after a newly created Docker container is added within the server cluster, it is also necessary to add the newly created Docker container to the monitoring platform to facilitate the monitoring platform to monitor the heartbeat of the newly created Docker container.
[0085] Further, the main function of the Docker container is to perform circular deployment of Java programs, deploy the same Java programs in different Docker containers according to rules, and form an effect of mutual backup between Docker containers.
[0086] In the embodiments of the present invention, by deploying the same Java program on multiple Docker containers and implementing a circular backup deployment method to ensure the highly available operation of the Java program, even if a certain Java program or a certain Docker container stops abnormally, it will not affect the use of the overall service. At the same time, the Docker container matches the monitoring platform, and the monitoring platform can detect the heartbeat of the Docker container in a timely manner, and can pull up and run the Docker container in a timely manner when it is found that a Docker container exits abnormally.
[0087] Based on the same inventive concept, the embodiments of the present invention also provide a schematic diagram of the process of the feedback method on the server cluster side based on circular deployment. Refer to Figure 4 As shown, it mainly includes the following steps:
[0088] Step 201: In response to the second message carrying a request sent by the load balancer server, determine the first Docker container capable of executing the request according to the second destination IP address included in the second message. Select the first JAVA program that matches the port number included in the second message from among the multiple JAVA programs included in the first Docker container to run the request, and obtain a data packet corresponding to the request; wherein, the second destination IP address included in the second message is the IP address of the first Docker container, and the multiple JAVA programs are deployed in different Docker containers in different orders;
[0089] Step 202: Replace the second destination IP address with the first source IP address included in the second message as the third destination IP address to form a third message;
[0090] Step 203: Send the third message carrying the data packet to the load balancer server, so that the load balancer server replaces the third source IP address with the first destination IP address as the fourth source IP address to obtain a fourth message, and feeds back the fourth message carrying the data packet to the client.
[0091] Before step 201, it is necessary to first determine the name of the server cluster, set multiple Docker containers in the server cluster, and determine the Docker container IP address corresponding to each Docker container. That is, the cluster server needs to be configured first. The specific configuration method can refer to the description in the above embodiments and will not be elaborated here.
[0092] The load balancer server first receives the first message carrying a request sent by the client. The load balancer matches according to the rules in the Nginx configuration file and selects the first Docker container IP address that matches the first source IP address included in the first message from among the multiple Docker container IP addresses included in the load balancer server. It should be noted that each Docker container included in the server cluster has a unique IP address, that is, each Docker container has its corresponding Docker container IP address. Therefore, the first Docker container IP address can be selected from the multiple Docker container IP addresses through the first source IP address. The first Docker container IP address here is one of the multiple Docker container IP addresses. It is called the first Docker container IP address only to avoid confusion with other Docker container IP addresses in subsequent introductions.
[0093] After determining the first Docker container IP address corresponding to the first request based on the first message, the load balancing server also needs to modify the content of the first message to form a second message that can be forwarded. The load balancing server modifies the first destination IP address included in the first message to the first Docker container IP address, that is, the first Docker container IP address is used as the second destination IP address to replace the first destination IP address, thereby modifying the first message to the second message.
[0094] In step 201, when the server cluster receives the second message carrying the request sent by the load balancing server, the first Docker container IP address is included in the second message. Therefore, it can be determined that the request carried by the second message needs to be run within the first Docker container corresponding to the first Docker container IP address; further, since multiple JAVA programs are deployed inside the first Docker container, one JAVA program that can run the request needs to be selected from the multiple JAVA programs. In the embodiment of the present invention, each JAVA program deployed in the first Docker container has a unique port number, and the second message includes a port. Therefore, the first JAVA program that can uniquely run the request is selected from the multiple JAVA programs through the port included in the second message.
[0095] The first JAVA program here is one of the multiple JAVA programs that can run the request. To avoid confusion in subsequent descriptions, the JAVA program that can run the request is referred to as the first JAVA program.
[0096] In the embodiment of the present invention, the server cluster includes multiple Docker containers, and multiple JAVA programs are deployed in each Docker container. In the embodiment of the present invention, the number of JAVA programs deployed in each Docker container is equal, but the multiple JAVA programs are deployed in different orders inside each Docker container, and the effect of mutual backup between Docker containers is formed.
[0097] Furthermore, by combining the IP address and the port, the first Docker container and the specific Java program can be found from the multiple Docker containers included in the server cluster, which can solve the problem that the existing technology is prone to exceptions when running individually.
[0098] Furthermore, after the first JAVA program runs the request and obtains the data packet corresponding to the request, the data packet needs to be fed back to the client. In the embodiment of the present invention, the server cluster needs to modify the second destination IP address included in the second message to obtain a third message.
[0099] Specifically, in step 202, the server cluster uses the first source IP address included in the second message to replace the second destination IP address, so as to form a third message with the first source IP address as the third destination IP address.
[0100] In step 203, after the load balancer server receives the third message carrying the data packet, it replaces the third source IP address with the first destination IP address, so as to form a fourth message with the first destination IP address as the fourth source IP address, and then feeds back the fourth message carrying the data packet to the client, thereby completing the feedback of the first message carrying the request sent by the client.
[0101] Exemplarily, for the feedback method based on ring deployment provided in the embodiments of the present invention, when the access pressure of the client is too high, dynamic expansion can also be performed by adding newly created Docker containers in the server cluster. Specifically, when adding newly created Docker containers in the server cluster, it is necessary to determine the IP address of the newly created Docker container corresponding to the newly created Docker container; further, add N different JAVA programs running in the Docker container to the newly created Docker container, and the arrangement order of the N different JAVA programs in the newly created Docker container is different from the arrangement order of the N different JAVA programs in other Docker containers; then, add the API address accessible to the newly created Docker container to the Nginx configuration file, and the API address corresponds to the IP address of the newly created Docker container.
[0102] It should be noted that in the embodiments of the present invention, a monitoring platform is also provided. The monitoring platform mainly monitors each Docker container to implement operations such as heartbeat detection and abnormal restart of the container. Therefore, after a newly created Docker container is added to the server cluster, it is also necessary to add the newly created Docker container to the monitoring platform, so as to facilitate the monitoring platform to monitor the heartbeat of the newly created Docker container.
[0103] Furthermore, the main function of the Docker container is to perform ring deployment of Java programs. The same Java programs are deployed in different Docker containers according to rules, and a backup effect of mutual cooperation between Docker containers is formed.
[0104] In the embodiments of the present invention, the same Java program is deployed on multiple Docker containers, and a ring backup deployment method is implemented to ensure the highly available operation of the Java program. Even if a certain Java program or a certain Docker container stops abnormally, it will not affect the use of the overall service. At the same time, the Docker container matches the monitoring platform. Through the monitoring platform, the heartbeat of the Docker container can be detected in a timely manner. When it is found that a Docker container exits abnormally, the Docker container can be pulled up and run in a timely manner.
[0105] Based on the same inventive concept, the embodiments of the present invention provide a schematic structural diagram of a feedback device load balancer server side based on ring deployment. Since the principle of the device for solving technical problems is similar to the ring deployment-based feedback method on the load balancer server side, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.
[0106] See Figure 5 , the device includes: a first response unit 301, a feedback unit 302, and a second response unit 303.
[0107] The first response unit 301 is configured to respond to a first message carrying a request sent by a client, match according to rules in the Nginx configuration file, select a first Docker container IP address that matches the first source IP address included in the first message from the multiple Docker container IP addresses included in the server cluster, use the first Docker container IP address as the second destination IP address, and replace the first destination IP address to form a second message;
[0108] The feedback unit 302 is configured to send the second message carrying the request to the first Docker container corresponding to the second destination IP address, so that the server cluster runs the request by selecting a first JAVA program that matches the port number included in the second message from the multiple JAVA programs included in the first Docker container, and obtain a data packet corresponding to the request; use the first source IP address to replace the second destination IP address as the third destination IP address to form a third message, and feedback the third message carrying the data packet to the load balancer; wherein, the multiple JAVA programs are deployed in each Docker container in different orders;
[0109] The second response unit 303 is configured to respond to the third message carrying the data packet fed back by the server cluster, replace the first destination IP address with the third source IP address as the fourth source IP address to obtain a fourth message, and feedback the fourth message carrying the data packet to the client.
[0110] Preferably, the first response unit 301 is configured to:
[0111] Determine the name of the server cluster, set a plurality of the Docker containers in the server cluster, and determine the Docker container IP address corresponding to each Docker container;
[0112] Add the API address accessible to each Docker container to the Nginx configuration file, where the API address corresponds to the Docker container IP address.
[0113] Preferably, the feedback unit 302 is further configured to:
[0114] Deploy N different JAVA programs in each Docker container in sequence, so that the N different JAVA programs are arranged in different orders in each Docker container, where N is a positive integer.
[0115] Preferably, the first response unit 301 is configured to:
[0116] Add a newly created Docker container to the server cluster, and determine the newly created Docker container IP address corresponding to the newly created Docker container;
[0117] Add the N different JAVA programs running in the Docker container to the newly created Docker container, and the arrangement order of the N different JAVA programs in the newly created Docker container is different from the arrangement order of the N different JAVA programs in each Docker container;
[0118] Add the API address accessible to the newly created Docker container to the Nginx configuration file, where the API address corresponds to the newly created Docker container IP address;
[0119] Add the newly created Docker container to the monitoring platform, so that the monitoring platform monitors the heartbeat of the newly created Docker container.
[0120] Based on the same inventive concept, an embodiment of the present invention provides a schematic structural diagram of the server cluster side of a feedback device based on circular deployment. Since the principle of the device for solving technical problems is similar to that of the feedback method based on circular deployment on the server cluster side, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.
[0121] See Figure 6 , the device includes: a first response unit 401, a forming unit 402, and a feedback unit 403.
[0122] The first response unit 401 is configured to respond to a second message carrying a request sent by a load balancing server, determine a first Docker container capable of executing the request according to a second destination IP address included in the second message, select a first JAVA program that matches a port number included in the second message from multiple JAVA programs included in the first Docker container to run the request, and obtain a data packet corresponding to the request; wherein, the second destination IP address included in the second message is the IP address of the first Docker container, and the multiple JAVA programs are deployed in different Docker containers in different orders;
[0123] The forming unit 402 is configured to replace the second destination IP address with a first source IP address included in the second message as a third destination IP address to form a third message;
[0124] The feedback unit 403 is configured to send the third message carrying the data packet to the load balancing server, so that the load balancing server replaces a third source IP address with a first destination IP address as a fourth source IP address to obtain a fourth message, and feedback the fourth message carrying the data packet to the client.
[0125] Preferably, the first response unit 401 is further configured to:
[0126] Deploy N different JAVA programs in sequence in multiple Docker containers included in the server cluster, and determine that the N different JAVA programs are arranged in different orders in each of the Docker containers, where N is a positive integer.
[0127] It should be understood that the units included in the above feedback device based on circular deployment are only logical divisions according to the functions implemented by the device. In actual applications, the above units can be superimposed or split. And the functions implemented by the feedback device based on circular deployment provided in this embodiment correspond one by one to the feedback method based on circular deployment provided in the above embodiment. For the more detailed processing flow implemented by this device, it has been described in detail in the first method embodiment above, and will not be described in detail here.
[0128] Another embodiment of the present invention further provides an electronic device, which includes: a processor and a memory; the memory is used to store computer program code, and the computer program code includes computer instructions; when the processor executes the computer instructions, the electronic device executes each step of the feedback method based on circular deployment in the method flow shown in the above method embodiment.
[0129] Another embodiment of the present invention further provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are run on a computer device, the computer device is caused to execute the steps of the feedback method based on ring deployment in the method flow shown in the above method embodiment.
[0130] Another embodiment of the present invention further provides a chip system, which is applied to a feedback device based on ring deployment. The chip system includes one or more interface circuits and one or more processors 11. The interface circuits and the processor 11 are interconnected by lines. The interface circuit is configured to receive a signal from the memory 12 of the feedback device based on ring deployment and send the signal to the processor 11, and the signal includes computer instructions stored in the memory 12. When the processor 11 executes the computer instructions, the feedback device based on ring deployment executes the method flow shown in the above method embodiment and the steps executed by the feedback device based on ring deployment.
[0131] In another embodiment of the present invention, there is also provided a computer program product, which includes instructions. When the instructions are run on a feedback device based on ring deployment, the feedback device based on ring deployment is caused to execute the method flow shown in the above method embodiment and the steps executed by the feedback device based on ring deployment.
[0132] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using a software program, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer execution instructions are loaded and run on a computer, the process or function according to the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from a website, a computer, a server, or a data center to another website, computer, server, or data center in a wired manner (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or a wireless manner (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more integrated media. The available medium can be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.
[0133] As described above, it is only the specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the said claims.
Claims
1. A feedback method based on circular deployment, characterized in that, Applied to the load balancer server side, including: In response to the first message carrying a request sent by the client, match according to the rules in the Nginx configuration file, select the first Docker container IP address that matches the first source IP address included in the first message from the multiple Docker container IP addresses included in the server cluster, use the first Docker container IP address as the second destination IP address, and replace the first destination IP address to form a second message; Send the second message carrying the request to the first Docker container corresponding to the second destination IP address, so that the server cluster runs the request by selecting the first JAVA program that matches the port number included in the second message from the multiple JAVA programs included in the first Docker container, and obtain a data packet corresponding to the request; replace the second destination IP address with the first source IP address as the third destination IP address to form a third message, and feedback the third message carrying the data packet to the load balancer; wherein, the multiple JAVA programs are deployed in each Docker container in different orders; In response to the third message carrying the data packet fed back by the server cluster, replace the first destination IP address with the third source IP address as the fourth source IP address to obtain a fourth message, and feedback the fourth message carrying the data packet to the client.
2. The feedback method based on ring deployment according to claim 1, wherein, Before the matching rule according to the Nginx configuration file, it further includes: Determine the name of the server cluster, set multiple Docker containers in the server cluster, and determine the Docker container IP address corresponding to each Docker container; Add the API address accessible to each Docker container in the Nginx configuration file, and the API address corresponds to the Docker container IP address.
3. The feedback method based on circular deployment according to claim 2, wherein It further includes: Deploy N different JAVA programs in each Docker container in sequence, so that the N different JAVA programs are arranged in different orders in each Docker container, and N is a positive integer.
4. The feedback method based on ring deployment according to claim 2, wherein It further includes: Add a newly created Docker container in the server cluster, and determine the newly created Docker container IP address corresponding to the newly created Docker container; Add the N different JAVA programs running in the Docker container to the newly created Docker container, and the arrangement order of the N different JAVA programs in the newly created Docker container is different from the arrangement order of the N different JAVA programs in each Docker container; Add the API address accessible to the newly created Docker container in the Nginx configuration file, and the API address corresponds to the newly created Docker container IP address; Add a newly created Docker container to the monitoring platform, so that the monitoring platform monitors the heartbeat of the newly created Docker container.
5. A feedback method based on circular deployment, characterized in that, Applied to the server cluster side, including: In response to the second message carrying a request sent by the load balancer server, determine the first Docker container that can execute the request according to the second destination IP address included in the second message, select the first JAVA program that matches the port number included in the second message from the multiple JAVA programs included in the first Docker container, run the request, and obtain a data packet corresponding to the request; wherein, the second destination IP address included in the second message is the IP address of the first Docker container, and the multiple JAVA programs are deployed in different Docker containers in different orders; Replace the second destination IP address with the first source IP address included in the second message as the third destination IP address to form a third message; Send the third message carrying the data packet to the load balancer server, so that the load balancer server replaces the third source IP address with the first destination IP address as the fourth source IP address to obtain a fourth message, and feedback the fourth message carrying the data packet to the client.
6. The feedback method based on ring deployment according to claim 5, wherein Before the response to the second message carrying a request sent by the load balancer server, it further includes: Deploy N different JAVA programs in sequence in multiple Docker containers included in the server cluster, and determine that the N different JAVA programs are arranged in different orders in each of the Docker containers, where N is a positive integer.
7. A feedback device based on circular deployment, characterized in that, Including: The first response unit is used to respond to the first message carrying a request sent by the client, match according to the rules in the Nginx configuration file, select the first Docker container IP address that matches the first source IP address included in the first message from the multiple Docker container IP addresses included in the server cluster, use the first Docker container IP address as the second destination IP address, and replace the first destination IP address to form a second message; The feedback unit is used to send the second message carrying the request to the first Docker container corresponding to the second destination IP address, so that the server cluster selects the first JAVA program that matches the port number included in the second message from the multiple JAVA programs included in the first Docker container to run the request, obtain a data packet corresponding to the request; replace the second destination IP address with the first source IP address as the third destination IP address to form a third message, and feedback the third message carrying the data packet to the load balancer; wherein, the multiple JAVA programs are deployed in different orders in each of the Docker containers; The second response unit is used to respond to the third message carrying the data packet fed back by the server cluster, replace the first destination IP address with the third source IP address as the fourth source IP address to obtain a fourth message, and feedback the fourth message carrying the data packet to the client.
8. A feedback device based on ring deployment, characterized in that, Including: A first response unit, configured to respond to a second message carrying a request sent by a load balancing server, determine a first Docker container capable of executing the request according to a second destination IP address included in the second message, select a first JAVA program that matches a port number included in the second message from multiple JAVA programs included in the first Docker container, run the request, and obtain a data packet corresponding to the request; wherein the second destination IP address included in the second message is the first Docker container IP address, and the multiple JAVA programs are deployed in different Docker containers in different orders; A forming unit, configured to replace the second destination IP address with a first source IP address included in the second message as a third destination IP address to form a third message; A feedback unit, configured to send the third message carrying the data packet to the load balancing server, so that the load balancing server replaces a third source IP address with a first destination IP address as a fourth source IP address to obtain a fourth message, and feedback the fourth message carrying the data packet to a client.
9. A computer device, characterized in that, The computer device includes: a processor and a memory; the memory is used to store computer program code, and the computer program code includes computer instructions; when the processor executes the computer instructions, the computer device executes the feedback method based on circular deployment according to any one of claims 1 to 4.
10. A computer-readable storage medium, characterized in that, Includes computer instructions, when the computer instructions run on a computer device, causing the computer device to execute the feedback method based on circular deployment according to any one of claims 1 to 4.