A service update method, device, equipment and storage medium
By obtaining and updating the registration service information of the intranet server and using Lua scripts to regularly update the upstream list of the reverse proxy server, the problems of update delay and low efficiency in service scenarios are solved, and efficient zero-downline updates and dynamics are achieved Routing update.
Patent Information
- Application Number
- CN202010761979.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-31
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2040-07-31
AI Technical Summary
When the prior art updates in service-oriented scenarios, there are problems of delay and low operation efficiency, especially in the case of frequent updates, the method of updating services through updating and offline is not conducive to operation.
By obtaining the registration service information of the intranet server, it is updated to the preset shared memory, and obtaining the registration service information from the shared memory at the preset time interval through the preloaded Lua script to update the upstream list of the reverse proxy server.
It realizes zero-down-line updates to the service without delay and efficiently, dynamically updates routing, and improves operational efficiency.
Smart Images

Figure CN111984289B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a service updating method, device, equipment and storage medium. Background Art
[0002] At present, with the development of network information technology, the service-oriented development in the web field has gradually become the mainstream, and the updates in the service-oriented scenarios are becoming more and more frequent. Generally, when updating the services that have been launched, it is necessary to set the services to be updated to be offline, that is, to call the offline interface of Ngnix (a high-performance HTTP and reverse proxy web server), set the IP of the specified server to be offline, and update the service site in the offline state. After the update is completed, the updated service is launched online. In the case of frequent updates, the method of updating the service by going online and offline is not conducive to operation. However, when it comes to zero-downline updates of services without delay and high efficiency, the current existing methods have some limitations.
[0003] The current service zero-downtime update usually uses the Nginx reload command to load the newly generated Upstream file without downtime. However, the switching efficiency between the old and new processes may be low because the requests received in the old process may take a long time to be processed. You can also use the CURL command to query, update, delete Upstream and other operations to achieve non-downtime updates, but the development efficiency of C language is far less than that of Lua language, making the update operation cumbersome. You can also use the internal DNS to resolve the internally defined domain name to achieve dynamic routing updates, but the DNS resolution and caching take time, making the update untimely. Summary of the invention
[0004] In view of the above problems, embodiments of the present invention are proposed to provide a service updating method, apparatus, device and storage medium that overcome the above problems or at least partially solve the above problems.
[0005] In order to solve the above problem, an embodiment of the present invention discloses a service update method, which is applied to a reverse proxy server, wherein the reverse proxy server is connected to an intranet server, and the method comprises:
[0006] Obtaining registration service information of the intranet server;
[0007] Updating the registration service information to a preset shared memory;
[0008] The registration service information is obtained from the preset shared memory at a preset time interval through a pre-loaded Lua script, and the registration service information is used to update the preset upstream list.
[0009] The embodiment of the present invention further discloses a service update device, which is applied to a reverse proxy server, wherein the reverse proxy server is connected to an intranet server, and the device comprises:
[0010] A registration service information acquisition module, used to acquire the registration service information of the intranet server;
[0011] A shared memory update module, used to update the registration service information to a preset shared memory;
[0012] The upstream list updating module is used to obtain the registration service information from the preset shared memory at a preset time interval through a pre-loaded Lua script, and update the preset upstream list with the registration service information.
[0013] An embodiment of the present invention further discloses a device, comprising: a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements any step of the service updating method when executed by the processor.
[0014] The embodiment of the present invention further discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of any one of the service updating methods are implemented.
[0015] The embodiments of the present invention include the following advantages:
[0016] In an embodiment of the present invention, the upstream list of the reverse proxy server is updated. After determining the registration service information of the intranet server and updating the registration service information to the shared memory, the Lua script is used to update the upstream list at a preset time interval, so that the service can be updated without delay and efficiently without going offline, thereby realizing dynamic update of routing. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 is a flow chart of the steps of a first embodiment of a service updating method of the present invention;
[0018] Figure 2 is a flow chart of the steps of Embodiment 2 of a service updating method of the present invention;
[0019] Figure 3 is a process diagram of a service updating method according to an embodiment of the present invention;
[0020] Figure 4 is a schematic diagram of data heterogeneity in an embodiment of the present invention;
[0021] Figure 5 It is a structural block diagram of an embodiment of a service updating device of the present invention. DETAILED DESCRIPTION
[0022] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0023] In the related art, there are mainly three solutions for implementing dynamic routing updates, that is, implementing zero-downline service updates.
[0024] First, you can configure the Upstream (referring to the reverse proxy service configured in the Nginx server, which is used to forward external network requests to internal network services) template through Nginx, then load the configuration to generate the Upstream file, and finally use the Nginx reload command to load the new Upstream solution without downtime.
[0025] This solution can have two processes. When the new Upstream is loaded without downtime through the Nginx reload command, the old process will no longer receive new requests until the current request is processed. If the current request received by the old process is not processed, the old process will exist for a long time. When the old and new processes are switched, the in-process cache will also become invalid, causing a lot of inconvenience.
[0026] The second method is to dynamically update routes through Nginx's ngx_http_dyups_module module (a dynamic upstream configuration module). This module is written in C language and provides an Http protocol management interface. Users can query, update, delete Upstream and other operations through CURL commands, and achieve updates without downtime.
[0027] However, this solution has great limitations. Since the development efficiency of C is far lower than that of Lua, the subsequent maintenance and update of the load balancing algorithm are very cumbersome.
[0028] The third method is to implement dynamic routing updates through internal DNS. In this solution, the Upstream configuration will no longer fill in the IP address of the backend service, but the internally defined domain name, so as to implement dynamic updates by updating the DNS service.
[0029] However, this solution will cause extra time consumption due to DNS resolution, and DNS only provides conversion from IP address to domain name. The port of the backend service will be restricted, and DNS will update the cache for a certain period of time, resulting in untimely updates.
[0030] However, the above three methods cannot effectively realize dynamic routing updates without delay and with high efficiency. Without considering the use of Nginx reload command, CURL command and internal DNS resolution, the service update method of the embodiment of the present invention can be used to realize zero-downline service updates.
[0031] The service updating method of the present invention is described below through specific embodiments.
[0032] Reference Figure 1 , shows a flow chart of the steps of a first embodiment of a service update method of the present invention, which is applied to a reverse proxy server, and the reverse proxy server is connected to an intranet server;
[0033] In an embodiment of the present invention, the reverse proxy Nginx has an Openresty framework, which can implement the reverse proxy service Upstream, wherein the reverse proxy Nginx is a high-performance Http and reverse proxy Web server; Openresty is a high-performance Web platform based on Ngnix and Lua; Lua is an embedded lightweight scripting language that can achieve efficient secondary development.
[0034] The specific steps may include:
[0035] Step 101, obtaining the registration service information of the intranet server;
[0036] In actual applications, the reverse proxy server can implement the reverse proxy service Upstream. The reverse proxy service Upstream here refers to the forwarding of external network requests to internal network services. Among them, the external network server may be responsible for initiating external network requests, and the internal network server may be responsible for providing internal network services. The reverse proxy server serves as an intermediate proxy server for request forwarding and service forwarding between the external network server and the internal network server.
[0037] Since the reverse proxy server can forward the services provided by the intranet server, when the backend service goes online or offline, the route needs to be changed dynamically. At this time, the reverse proxy server can obtain the registration service information of the intranet server based on the Openresty framework to update the reverse proxy server's own Upstream list.
[0038] Step 102, updating the registration service information to a preset shared memory;
[0039] In an embodiment of the present invention, after obtaining the registration service information of the intranet server, the obtained registration service information can be updated and stored in a preset shared memory. The preset shared memory here can be a registration center or service discovery component that records the registration service information, and a memory for sharing data with the reverse proxy server, so as to update the shared registration service information in the shared memory to the Upstream list of the reverse proxy server itself.
[0040] Step 103: Obtain the registration service information from the preset shared memory at a preset time interval through a pre-loaded Lua script, and use the registration service information to update the preset upstream list.
[0041] The reverse proxy server has a preset upstream list, where the preset upstream list refers to the reverse proxy's own Upstream list.
[0042] In an embodiment of the present invention, the reverse proxy server can also load a Lua script to perform reverse proxy Upstream based on the Openresty framework. The Lua script loaded here can use registration service information to update the Upstream list of the reverse proxy server.
[0043] In actual applications, after obtaining the registration service information of the intranet server and updating and storing the registration service information in the shared memory, the loaded Lua script can obtain the available registration service information from the shared memory at a preset time interval and use the available registration service information to update its own Upstream list.
[0044] In an embodiment of the present invention, by obtaining the registration service information of the intranet server and using a pre-loaded Lua script, the Upstream list of the reverse proxy itself is updated using the registration service information at preset time intervals. Since the lightweight Lua language can achieve efficient secondary development, the service can be updated without delay and with high efficiency without downtime, that is, dynamic update of the routing is achieved.
[0045] Reference Figure 2 , shows a flow chart of the steps of a second embodiment of a service update method of the present invention, which is applied to a reverse proxy server, and the reverse proxy server is connected to an intranet server, and specifically may include the following steps:
[0046] Step 201, when the preset service component is started, load the Lua script;
[0047] In the embodiment of the present invention, a Lua script may be loaded simultaneously when a preset service component is started. Here, the preset service component may be responsible for starting the service, and the loaded Lua script may implement a timed update of the Upstream list.
[0048] It should be noted that the loaded Lua script always exists during the process of the service updating method implemented by the embodiment of the present invention, and can implement any process in the service updating method.
[0049] Step 202, obtaining the registration service information of the intranet server through the Lua script;
[0050] In actual applications, the registration service information of the intranet server can first be obtained through the loaded Lua script, so as to update the Upstream list according to the obtained registration service information.
[0051] In the embodiment of the present invention, step 202 may include the following sub-steps:
[0052] Sub-step S11, calling a preset service discovery component to obtain registration service information of the intranet server;
[0053] In an embodiment of the present invention, the registration service information of the intranet server is obtained through a Lua script. Specifically, a preset service discovery component can be called to pull the registration service information, wherein the preset service discovery component here can be a registration center for recording registration service information.
[0054] It should be noted that the registration service information acquisition method can not only be pulled by the registration center, but also cached registration service information can be temporarily used when the registration center fails to provide registration service information. It should be noted that the embodiment of the present invention does not limit the registration service information acquisition method.
[0055] In the embodiment of the present invention, sub-step S11 may include the following sub-steps:
[0056] Sub-step S111, calling a preset service discovery component to obtain an upstream list corresponding to the registration service information of the intranet server.
[0057] Call the preset service discovery component, that is, obtain the registration service information of the intranet server through the registration center. The registration service information obtained at this time can be the specific data information of the registered service, or it can be a list of registration service information, that is, an upstream list that records the registered service information in a list form.
[0058] In an embodiment of the present invention, a preset service discovery component is called. Since the reverse proxy server can serve as an intermediate proxy server for request forwarding and service forwarding between the external network server and the internal network server, for the preset discovery component, the reverse proxy server can be equivalent to a client. At this time, the client discovery mode can be used to pull the registration service information.
[0059] Step 203, updating the registration service information of the intranet server to the preset shared memory;
[0060] After obtaining the registration service information of the intranet server, the registration service information can be updated to the shared memory for data sharing between the preset service discovery component and the reverse proxy, so that the shared data, here the registration service information, can be obtained through the shared memory.
[0061] In the embodiment of the present invention, step 203 may include the following sub-steps:
[0062] Sub-step S21, monitoring the registered service information through a preset Lua blocking library, and determining whether the registered service information is the same as the service information in the preset upstream list;
[0063] In an embodiment of the present invention, since the Upstream list in the service discovery component may not be updated, the Lua network blocking library can be used to monitor the obtained registration service information and determine whether the obtained registration service information is the same as the Upstream list of the reverse proxy server itself.
[0064] In practical applications, the method of determining whether the Upstream list is updated can be implemented through hash verification. Specifically, the reverse proxy server can obtain service information from its own Upstream list, and perform hash processing on its own service information to obtain a first hash value, and also perform hash processing on the obtained registration service information to obtain a second hash value; the first hash value and the second hash value are verified, and a judgment is made based on the verification result.
[0065] Sub-step S22: If the registered service information is different from the service information in the preset upstream list, the registered service information is updated to the preset shared memory.
[0066] In an embodiment of the present invention, it is determined whether the acquired registration service information is the same as the service information of the reverse proxy server itself. If the acquired registration service information is not the same as the service information of the reverse proxy server itself, it indicates that the registration service information pulled from the service discovery component is updated. At this time, the pulled registration service information can be updated to the shared memory so as to obtain the updated registration service information from the shared memory.
[0067] Specifically, a hash check is performed on the first hash value and the second hash value. If the check result is inconsistent, it means that the pulled registration service information is changed compared to its own service information, that is, the pulled registration service information is updated.
[0068] In the embodiment of the present invention, sub-step S22 may include the following sub-steps:
[0069] Sub-step S221, calling a preset management port to update the registration service information to a preset shared memory.
[0070] In an embodiment of the present invention, the acquired registration service information is monitored through the Lua network blocking library. When the verification result of the hash check indicates a change, a request can be submitted to the management port to call the management port and update the shared memory through the management port.
[0071] In practical applications, a service server of the reverse proxy service Nginx can be used as the management port, and the management port can be used to monitor and control shared memory; the call to the management port can be implemented through the Lua socket library or through a special stage timer of Openresty.
[0072] Specifically, Lua's socker library can provide a module for accessing Http, and at this time, the http request of the socker library can be used to complete the call to the management port. When the verification result of the hash check indicates a change, first, a management request can be generated to request the network address corresponding to the management port, and the registration service information can be submitted to the management port according to the corresponding network address; after the management port receives the registration service information, an update request can be generated through the management port, and the update request and the received registration service information can be sent to the shared memory, so that the shared memory can be updated according to the update request using the received registration service information.
[0073] Step 204: Obtain the registration service information of the intranet server from the preset shared memory through the Lua script at a preset time interval, and update the Upstream list with the registration service information of the intranet server;
[0074] After the registration service information is updated to the shared memory through the management port, the available registration service information can be obtained from the shared memory at a preset time interval through the loaded Lua script, and the Upstream list of the reverse proxy itself can be updated using the available registration service information.
[0075] In actual applications, the scripting language feature of OpenResty can be used to load the Lua script for executing Upstream updates in the balancer_by_lua phase, update it to its own Upstream list through a timer and make it take effect dynamically. In the balancer_by_lua_block phase, the registered service information can be read from the shared memory at a certain time interval, updated to its own Upstream list and take effect immediately.
[0076] Step 205, distributing the service request received according to a preset distribution strategy to the service port corresponding to the registered service information;
[0077] In the embodiment of the present invention, after updating the upstream list of the self, the registration service information corresponding to the upstream list can be obtained, where the registration service information can include each service and the service port corresponding to the service, and the distribution strategy for request distribution can be customized for the service port. Among them, updating the upstream list of the self indicates that the dynamic routing is updated at this time, and the dynamic routing can forward the request without going offline.
[0078] In actual applications, suppose there is a request for a certain service, such as the reverse proxy server Nginx receives a normal http request. At this time, the reverse server Nginx can be used to update its own Upstream list, and the distribution strategy of the service port can be customized through the hook mechanism to achieve the desired distribution effect.
[0079] Requests to the service port are distributed. In one case, if load balancing is required, the distribution strategy can be modulo or randomly assigned according to the network address IP of the service port. In another case, if it is in AB grayscale testing, the distribution strategy can be assigned to the corresponding backend service according to the client user ID. That is, no matter in the case of load balancing or AB grayscale testing, the distribution strategy of the service port can be customized to achieve the distribution effect of dynamically allocating different request amounts to the backend service.
[0080] In order to achieve the distribution effect of dynamically allocating different request amounts to backend services, specifically, you can obtain relevant data such as the backend load from the balancer_by_lua_block module, and generate corresponding distribution ratios for the backend services according to a certain distribution ratio. Assuming that the total number of service requests is 100, you can generate a random number within 100 for each request and allocate it to the specified backend service according to the number.
[0081] Step 206: Perform a health check on the service port.
[0082] In the embodiment of the present invention, after updating the Upstream list of the Upstream itself, not only can the distribution strategy for request distribution be customized for the service port in the Upstream list, but also the health check of the service port can be performed to ensure the availability of the backend service. It should be noted that the process of customizing the distribution strategy and performing the health check on the service are two independent processes that do not interfere with each other.
[0083] In actual applications, health checks are performed on service ports. The health checks here can include passive health checks and active health checks. Among them, passive health checks refer to the judgment of the max_fails / fail_timeout threshold of the reverse proxy Nginx to determine whether the current service can provide services externally; active health checks can also be performed by sending heartbeat packets by the backend service at regular intervals. In this health check method, when the backend service does not send heartbeat packets for a long time, it can be determined that the service has crashed, and the service that has been confirmed to be down can be taken offline.
[0084] In the embodiment of the present invention, the Upstream list is updated regularly through the lightweight Lua language, and after the dynamic routing is updated, the request distribution strategy of the service port in the updated Upstream list is customized through the hook mechanism, and the port health check is performed to ensure the availability of the backend service. Not only is the service updated without delay and high efficiency without offline, that is, the dynamic update of the routing is realized, but also different request amounts can be dynamically allocated to the backend service, and the high availability of the backend service can be ensured.
[0085] See also Figure 3 , which shows a process diagram of a service updating method according to an embodiment of the present invention, comprising: Figure 3 It can be seen that the process of implementing the service update method may include:
[0086] 1) Pull the latest Upstream list from the service discovery when the service starts; 2) Listen to the latest Upstream available list from the service discovery through Lua's network blocking library; 3) Determine whether there is the latest Upstream available list from the service discovery. If there is an update, update it to the shared memory; 4) Then use the scripting language features of OpenResty to write a Lua script that executes Upstream updates, load it in the balancer_by_lua stage, update it to the Upstream through a timer and make it take effect dynamically.
[0087] In the embodiment of the present invention, the OpenResty framework of the reverse proxy Nginix can be used for development, which has very high development efficiency and reduces maintenance costs.
[0088] See also Figure 4 , which shows a schematic diagram of data heterogeneity in an embodiment of the present invention, such as Figure 4 It can be seen that in the entire process of implementing service updates, the data heterogeneity process can include the following:
[0089] 1) Listen to the management port through the Lua network blocking library, and update the shared memory when the external data is updated; the external data here can refer to the latest Upstream available list pulled from the service discovery; 2) Update the latest Upstream available list from the shared memory to the original Upstream list through the timer; 3) Through the OpenResty framework, and use the Hook mechanism to customize the behavior of the service port in the Upstream; the behavior of the service port here can refer to request distribution; 4) Self-management of Upstream data is achieved through active and passive health checks.
[0090] In the embodiment of the present invention, the solution provides a list of currently available services through the data source of service discovery, and can achieve quasi-real-time updates. When the backend performs service online and offline or port changes, it can immediately provide feedback to the router to ensure the availability of the service.
[0091] Among them, by performing active and passive health checks on the service ports and customizing the distribution strategy of request distribution of the service ports, different request volumes can be dynamically allocated to the backend services based on load balancing algorithms such as polling, IP hashing, speed priority, and nearby access, ensuring the efficiency and high availability of the entire system.
[0092] In the process of data heterogeneity in the embodiment of the present invention, the input data (here, it can refer to the latest Upstream available list pulled from the service discovery) can be self-updated. Figure 4 In the loop shown, it can be said that when a piece of data enters, a cycle can be completed. Among them, the hook mechanism mainly uses the execution phase of nginx to customize the upstream in it, so as to achieve the desired distribution effect.
[0093] It should be noted that when developing dynamic routing through Nginx, you can also use C language to develop Nginx modules and implement similar functions. However, C language development is inefficient, and each update needs to be compiled and launched. With Lua development, you can easily modify and launch it directly.
[0094] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0095] Reference Figure 5 , shows a structural block diagram of an embodiment of a service update device of the present invention, which is applied to a reverse proxy server, and the reverse proxy server is connected to an intranet server, and specifically may include the following modules:
[0096] The Lua script loading module 501 is used to load the Lua script when the preset service component is started;
[0097] A registration service information acquisition module 502 is used to acquire the registration service information of the intranet server;
[0098] A shared memory update module 503, used to update the registration service information to a preset shared memory;
[0099] The upstream list updating module 504 is used to obtain the registration service information from the preset shared memory at a preset time interval through a pre-loaded Lua script, and update the preset upstream list with the registration service information;
[0100] The service request distribution module 505 is used to distribute the received service request to the service port corresponding to the registered service information according to a preset distribution strategy;
[0101] The service port checking module 506 is used to perform a health check on the service port.
[0102] In the embodiment of the present invention, the registration service information acquisition module 502 may include the following submodules:
[0103] The registration service information acquisition submodule is used to call a preset service discovery component to obtain the registration service information of the intranet server.
[0104] In an embodiment of the present invention, the registration service information acquisition submodule may include the following units:
[0105] The registration service information acquisition unit is used to call a preset service discovery component to obtain an upstream list corresponding to the registration service information of the intranet server.
[0106] In the embodiment of the present invention, the shared memory update module 503 may include the following submodules:
[0107] A registration service information monitoring submodule, used to monitor the registration service information through a preset Lua blocking library, and determine whether the registration service information is the same as the service information in the preset upstream list;
[0108] The shared memory update submodule is used to update the registered service information to the preset shared memory if the registered service information is different from the service information in the preset upstream list.
[0109] In an embodiment of the present invention, the shared memory update submodule may include the following units:
[0110] The shared memory updating unit is used to call a preset management port to update the registered service information to the preset shared memory.
[0111] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0112] An embodiment of the present invention also provides a device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned service update method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0113] An embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various processes of the above-mentioned service update method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0114] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0115] It will be appreciated by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0116] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0117] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0118] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0119] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A service update method, characterized in that: Applied to a reverse proxy server, the reverse proxy server is connected to an intranet server, the method comprises: Obtaining registration service information of the intranet server; The registration service information is monitored through a preset Lua blocking library, and a first hash value corresponding to the registration service information and a second hash value corresponding to the service information in a preset upstream list are verified. If the verification result is inconsistent, a management request is generated to submit the registration service information to a management port, and then an update request is generated through the management port, and the update request and the registration service information are sent to a preset shared memory, so that the preset shared memory is updated with the registration service information according to the update request; the inconsistent verification result is used to indicate that the registration service information has been updated, and the management port is used to monitor and control the shared memory; The registration service information is obtained from the preset shared memory at a preset time interval through a pre-loaded Lua script, and the registration service information is used to update the preset upstream list.
2. The method according to claim 1, characterized in that Before obtaining the registration service information of the intranet server, the method further includes: When the default service component starts, the Lua script is loaded.
3. The method according to claim 1, characterized in that The obtaining of the registration service information of the intranet server includes: Call the preset service discovery component to obtain the registration service information of the intranet server.
4. The method according to claim 3, characterized in that The calling of a preset service discovery component to obtain registration service information of the intranet server includes: The preset service discovery component is called to obtain an upstream list corresponding to the registration service information of the intranet server.
5. The method according to claim 1, characterized in that: Also includes: Distributing the received service request to the service port corresponding to the registered service information according to a preset distribution strategy; The registration service information includes the corresponding service port and also includes: Perform a health check on the service port.
6. A service updating device, characterized in that: Applied to a reverse proxy server, the reverse proxy server is connected to an intranet server, and the device comprises: A registration service information acquisition module, used to acquire the registration service information of the intranet server; A shared memory update module, used to monitor the registration service information through a preset Lua blocking library, verify the first hash value corresponding to the registration service information and the second hash value corresponding to the service information in the preset upstream list, and if the verification result is inconsistent, generate a management request to submit the registration service information to a management port, and then generate an update request through the management port, and send the update request and the registration service information to a preset shared memory, so that the preset shared memory is updated with the registration service information according to the update request; the inconsistent verification result is used to indicate that the registration service information has been updated, and the management port is used to monitor and control the shared memory; The upstream list updating module is used to obtain the registration service information from the preset shared memory at a preset time interval through a pre-loaded Lua script, and update the preset upstream list with the registration service information.
7. A device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the steps of the service updating method according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the service updating method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Shared-memory-based service discovery method, apparatus and system, server
CN106506703A