A microservice deployment method, device, equipment and medium

By deploying servers that call APIs and provide services in microservices, and polling paths and IP addresses, the high operation and security costs caused by the complexity of the microservice deployment model is solved, and fast and secure microservice deployment is achieved.

CN115396449BActive Publication Date: 2025-03-04INSPUR GENERSOFT CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211012644.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-23
Publication Date
2025-03-04
Estimated Expiration
2042-08-23

AI Technical Summary

Technical Problem

Due to the complexity of the establishment, the microservice deployment model has high operation and maintenance and security costs, making it difficult to effectively deploy in low-cost development, testing and production environments.

Method used

The deployment and service are completed by deploying the first server that calls the API and the second server that provides the service in the microservice, and polling the path and IP address according to the preset service name and cycle.

Benefits of technology

Fast microservice discovery and survival checks are implemented, reducing deployment complexity and security risks, and avoiding the problem of introducing too many complex components.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115396449B_ABST
    Figure CN115396449B_ABST
Patent Text Reader

Abstract

The embodiments of this specification disclose a method, apparatus, device and medium for deploying a microservice, including: deploying a first server that calls an API and a second server that provides a service in a microservice; setting a path for a product in the microservice according to a preset service name; polling the path for the product in the microservice through the first server according to a preset period; if there is no abnormality in the path of the product in the microservice in the polling result, completing the deployment of the first server and the second server in the microservice, and providing the corresponding service through the second server.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method, device, equipment and medium for deploying microservices. Background Art

[0002] With the rise of microservice deployment mode, monolithic applications can no longer meet the update speed and deployment mode of production environments under new technologies. However, the components required for microservice deployment are too complex, which may lead to high operation and maintenance costs and security costs. Based on this, in some low-cost development, testing and production environments, deploying a microservice environment has become an urgent problem to be solved. Summary of the invention

[0003] One or more embodiments of this specification provide a microservice deployment method, apparatus, device, and medium for solving the technical problems raised by the background technology.

[0004] One or more embodiments of this specification adopt the following technical solutions:

[0005] One or more embodiments of this specification provide a method for deploying a microservice, including:

[0006] Deploy a first server that calls the API and a second server that provides services in the microservice;

[0007] According to the preset service name, set the path of the product in the microservice;

[0008] According to a preset period, polling the path of the product in the microservice through the first server;

[0009] If there is no abnormality in the path of the product in the microservice in the polling result, the deployment of the first server and the second server in the microservice is completed, and the corresponding service is provided through the second server.

[0010] Furthermore, before completing the deployment of the first server and the second server in the microservice, the method further includes:

[0011] Set the IP address of the product in the microservice;

[0012] Poll the IP addresses of the products in the microservice according to a preset period;

[0013] If there is no abnormality in the IP address of the product in the microservice in the polling result, the deployment of the microservice is completed.

[0014] Further, after completing the deployment of the first server and the second server in the microservice, the method further includes:

[0015] Record the IP address and path of the product in the microservice into the configuration file of the first server, and record the timestamp in the configuration file;

[0016] If the path and IP address of the product in the microservice are polled through the first server at the next moment of the timestamp, it is determined whether the path and IP address of the product in the microservice are recorded in the configuration file;

[0017] If the path and IP address of the product in the microservice are recorded in the configuration file, the polling is terminated.

[0018] Furthermore, if the path and IP address record of the product in the microservice are not in the configuration file, the method further includes:

[0019] The first server is used to poll the path and IP address of the product in the microservice.

[0020] Furthermore, if the path of the product in the microservice described in the polling result is abnormal, the service of the product is terminated.

[0021] Further, after completing the deployment of the first server and the second server in the microservice, the method further includes:

[0022] The IP address and path of the product are dynamically registered in the load balancing server so that the load of the product can be dynamically adjusted through the load balancing server.

[0023] Further, after completing the deployment of the first server and the second server in the microservice, the method further includes:

[0024] Monitor and diagnose access to said products.

[0025] One or more embodiments of this specification provide a microservice deployment device, the device comprising:

[0026] A preliminary deployment unit deploys a first server for calling the API and a second server for providing services in the microservice;

[0027] A setting unit, which sets the path of the product in the microservice according to a preset service name;

[0028] A polling unit, polling the path of the product in the microservice through the first server according to a preset period;

[0029] The deployment result unit completes the deployment of the first server and the second server in the microservice if there is no abnormality in the path of the product in the microservice in the polling result, and provides the corresponding service through the second server.

[0030] One or more embodiments of this specification provide a microservice deployment device, including:

[0031] at least one processor; and,

[0032] a memory communicatively connected to the at least one processor; wherein,

[0033] The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:

[0034] Deploy a first server that calls the API and a second server that provides services in the microservice;

[0035] According to the preset service name, set the path of the product in the microservice;

[0036] According to a preset period, polling the path of the product in the microservice through the first server;

[0037] If there is no abnormality in the path of the product in the microservice in the polling result, the deployment of the first server and the second server in the microservice is completed, and the corresponding service is provided through the second server.

[0038] One or more embodiments of this specification provide a non-volatile computer storage medium storing computer executable instructions, wherein the computer executable instructions are configured to:

[0039] Deploy a first server that calls the API and a second server that provides services in the microservice;

[0040] According to the preset service name, set the path of the product in the microservice;

[0041] According to a preset period, polling the path of the product in the microservice through the first server;

[0042] If there is no abnormality in the path of the product in the microservice in the polling result, the deployment of the first server and the second server in the microservice is completed, and the corresponding service is provided through the second server.

[0043] At least one of the above technical solutions adopted in the embodiments of this specification can achieve the following beneficial effects:

[0044] The embodiments of this specification can achieve fast microservice discovery and survival check based on basic files and network request commands, avoid introducing too much complexity, and avoid security issues caused by overly complex deployment and components. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the technical solutions in the embodiments of this specification or the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art description. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. In the drawings:

[0046] Figure 1 A flowchart of a microservice deployment method provided for one or more embodiments of this specification;

[0047] Figure 2 A schematic diagram of a microservice deployment device provided for one or more embodiments of this specification;

[0048] Figure 3 A schematic diagram of the structure of a microservice deployment device provided for one or more embodiments of this specification. DETAILED DESCRIPTION

[0049] The embodiments of this specification provide a method, apparatus, device and medium for deploying a microservice.

[0050] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments of this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.

[0051] Figure 1 A schematic diagram of a process flow of a microservice deployment method provided in one or more embodiments of this specification, which can be executed by a microservice deployment system, can deploy a microservice environment for low-cost development and testing. Certain input parameters or intermediate results in the process allow manual intervention and adjustment to help improve accuracy.

[0052] The method steps of the embodiment of this specification are as follows:

[0053] S102, deploying a first server for calling an API and a second server for providing services in a microservice.

[0054] In the embodiments of this specification, multiple first servers and second servers can be deployed according to actual needs. The first server needs to be able to access the second server, the first server also needs to be able to identify the startup file and other information inside the second server, and be able to perform network connectivity checks.

[0055] S104, setting the path of the product in the microservice according to the preset service name.

[0056] In the embodiment of this specification, for verification in subsequent steps, the service name and port number of the product can be set as the path of the product by writing a file.

[0057] S106: According to a preset period, the first server polls the paths of the products in the microservice.

[0058] In the embodiments of the present specification, when polling the path of a product in the server, the format of the path may be verified, or the path of the product may be pre-set, and when polling, it may be checked whether the current path is the same as the pre-set path.

[0059] S108: If there is no abnormality in the path of the product in the microservice in the polling result, the deployment of the first server and the second server in the microservice is completed, and the corresponding service is provided through the second server.

[0060] Furthermore, before completing the deployment of the first server and the second server in the microservice, the embodiment of the present specification can also set the IP address of the product in the microservice; poll the IP address of the product in the microservice according to a preset period, and poll the IP address of the product here in the same way as polling the path of the product; if there is no abnormality in the IP address of the product in the microservice in the polling result, the deployment of the microservice is completed. The embodiment of the present specification can simultaneously poll the IP address and path of the product, so that the product of the microservice can provide more stable services.

[0061] Furthermore, after completing the deployment of the first server and the second server in the microservice, the embodiments of this specification can record the IP address and path of the product in the microservice into the configuration file of the first server, and record the timestamp in the configuration file; if the path and IP address of the product in the microservice are polled through the first server at the next moment of the timestamp, it is determined whether the path and IP address of the product in the microservice are recorded in the configuration file; if the path and IP address of the product in the microservice are recorded in the configuration file, the polling is terminated. If the path and IP address of the product in the microservice are not recorded in the configuration file, the path and IP address of the product in the microservice can be polled through the first server.

[0062] Furthermore, in the embodiments of the present specification, if the path of the product in the microservice described in the polling result is abnormal, the service of the product can be terminated to avoid errors in the product when providing services and causing unnecessary losses to users.

[0063] Furthermore, after the embodiment of this specification completes the deployment of the first server and the second server in the microservice, the IP address and path of the product can be dynamically registered in the load balancing server so that the load of the product can be dynamically adjusted through the load balancing server.

[0064] Furthermore, after the deployment of the first server and the second server in the microservice is completed in the embodiment of this specification, the access to the product can be monitored and diagnosed, and abnormal servers can be eliminated, and the number of accesses to servers with high pressure can be reduced to reduce the load.

[0065] Furthermore, with the rise of Internet e-commerce, live broadcasting, and mobile apps, the development model has shifted from the previous large version release to the microservice rapid iteration model. Monolithic applications cannot meet the needs of rapid product iteration and adding new features, so microservice deployment is required. The splitting of applications will lead to the introduction of more components, such as zookeeper to implement service registration, or nacos for service registration and discovery, and tools such as consul for related business processing.

[0066] The embodiments of this specification can achieve fast microservice discovery and survival check based on basic files and network request commands, avoid introducing too much complexity, and avoid security issues caused by overly complex deployment and components.

[0067] The embodiments of this specification are directed to the above technical solution and can be implemented through the following specific contents:

[0068] 1. The embodiments of this specification can realize the deployment discovery and survival check of microservices based on multiple Linux servers. When calling, only the path setting needs to be performed on the front-end server, and no other open source component processing is required.

[0069] 2. The embodiments of this specification require at least two groups of servers, one group of servers is used to call the API, and the other group of servers is used to provide specific services. It should be noted that the server that calls the API needs to be able to access the server that provides the specific service, be able to identify the startup files and other information inside the server, and be able to perform network connectivity checks.

[0070] 3. The embodiments of this specification require a certain degree of modification to the product. After the service is successfully started, the service name and exposed port number of the product need to be written to the specific path of this server by writing a file. For example, under the / app path of this server, the specific path can be the service name + process number + port number information. In addition, the embodiments of this specification require constraints on the IP address of the product. The IP address can be exposed and used in the format of http: / / ip address:port number / service name / xxxx. The embodiments of this specification can use consistent ports for the same service to facilitate routing. Different services use different ports to reduce the waste of server resources and ensure the accuracy of routing.

[0071] 4. The server that calls the API needs to add all servers that provide services to the list and poll them regularly.

[0072] 4.1 You need to poll the files under the / app path of each server. Then record the specific path and IP address in the configuration file that calls the API server for backup.

[0073] 4.2 After the previous step is completed, a timestamp operation needs to be recorded. The next check will no longer check files before the timestamp.

[0074] 4.3 According to the specific path and IP address recorded in 4.1, a call check function can be set to poll the port every 5 seconds. If the port does not exist after three consecutive checks, the specific path and IP address information in the list of 4.1 can be deleted.

[0075] 4.4 While deleting the non-existent specific paths and IP addresses, you need to try to start the service on the IP address of the server providing the service, and delete the old files that prompt success under the / app directory and back them up for use.

[0076] 5. You can add a kernel-based interceptor to the server that calls the API. Call the IP address of this server. Then use the configuration file generated in step 4.1 to configure the route. For example, if the call is http: / / calling the API server ip / service A / xxxx, it needs to be changed to: http: / / server A's IP address: service A's corresponding port / service A / xxxx for transmission.

[0077] 6. Based on the active checks in 4.3 and 4.4, it is ensured that the wrong service will not be called.

[0078] In addition, the embodiments of this specification can also be implemented by the following implementation scheme:

[0079] S1 product optimization and adjustment, server resource settings. The product needs to be optimized. When splitting services for deployment, the API must be distinguished according to the prefix of the service. For example, financial accounting is / api / cw and fund management is / api / zj. Then modify the information on the machine discovered by the service registration so that it can be connected.

[0080] The environment in which the S2 service runs needs to be dynamically registered to the load balancing server, and the IP address and specific path must be dynamically registered. For example, IP1:CW IP2:CW, so that the load can find the specified machine through the specific path.

[0081] If there is an abnormality in the S3 service, the service registration and discovery mechanism of hosts etc. will be dynamically cancelled to avoid abnormalities when the load is transferred to the abnormal machine.

[0082] S4 monitors and diagnoses access situations, can eliminate abnormal servers, and reduce the number of accesses routed to servers with high pressure, thereby reducing the load.

[0083] Figure 2 A schematic diagram of the structure of a microservice deployment device provided for one or more embodiments of this specification, wherein the device includes: a preliminary deployment unit 202, a setting unit 204, a polling unit 206 and a deployment result unit 208.

[0084] A preliminary deployment unit 202 deploys a first server for calling an API and a second server for providing services in a microservice;

[0085] The setting unit 204 sets the path of the product in the microservice according to the preset service name;

[0086] A polling unit 206, polling the path of the product in the microservice through the first server according to a preset period;

[0087] The deployment result unit 208 completes the deployment of the first server and the second server in the microservice if there is no abnormality in the path of the product in the microservice in the polling result, and provides the corresponding service through the second server.

[0088] Figure 3 A schematic diagram of a microservice deployment device provided for one or more embodiments of this specification includes:

[0089] at least one processor; and,

[0090] a memory communicatively connected to the at least one processor; wherein,

[0091] The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:

[0092] Deploy a first server that calls the API and a second server that provides services in the microservice;

[0093] According to the preset service name, set the path of the product in the microservice;

[0094] According to a preset period, polling the path of the product in the microservice through the first server;

[0095] If there is no abnormality in the path of the product in the microservice in the polling result, the deployment of the first server and the second server in the microservice is completed, and the corresponding service is provided through the second server.

[0096] One or more embodiments of this specification provide a non-volatile computer storage medium storing computer executable instructions, wherein the computer executable instructions are configured to:

[0097] Deploy a first server that calls the API and a second server that provides services in the microservice;

[0098] According to the preset service name, set the path of the product in the microservice;

[0099] According to a preset period, polling the path of the product in the microservice through the first server;

[0100] If there is no abnormality in the path of the product in the microservice in the polling result, the deployment of the first server and the second server in the microservice is completed, and the corresponding service is provided through the second server.

[0101] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment, and non-volatile computer storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0102] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0103] The above description is only one or more embodiments of this specification and is not intended to limit this specification. For those skilled in the art, one or more embodiments of this specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of one or more embodiments of this specification shall be included in the scope of the claims of this specification.

Claims

1. A method for deploying microservices, characterized in that: The method comprises: Deploy a first server that calls the API and a second server that provides services in the microservice; According to the preset service name, set the path of the product in the microservice; According to a preset period, polling the path of the product in the microservice through the first server; If there is no abnormality in the path of the product in the microservice in the polling result, the deployment of the first server and the second server in the microservice is completed, and the corresponding service is provided through the second server; Before completing the deployment of the first server and the second server in the microservice, the method further includes: Set the IP address of the product in the microservice; Poll the IP addresses of the products in the microservice according to a preset period; If there is no abnormality in the IP address of the product in the microservice in the polling result, the deployment of the microservice is completed; After completing the deployment of the first server and the second server in the microservice, the method further includes: Record the IP address and path of the product in the microservice into the configuration file of the first server, and record the timestamp in the configuration file; If the path and IP address of the product in the microservice are polled through the first server at the next moment of the timestamp, it is determined whether the path and IP address of the product in the microservice are recorded in the configuration file; If the path and IP address of the product in the microservice are recorded in the configuration file, terminate the polling; If the path and IP address record of the product in the microservice are not in the configuration file, the method further includes: Polling the path and IP address of the product in the microservice through the first server; If the path of the product in the microservice described in the polling result is abnormal, the service of the product will be terminated; After completing the deployment of the first server and the second server in the microservice, the method further includes: Dynamically register the IP address and path of the product into the load balancing server so as to dynamically adjust the load of the product through the load balancing server; After completing the deployment of the first server and the second server in the microservice, the method further includes: Monitor and diagnose access to said products.

2. A microservice deployment device, characterized in that: The device comprises: A preliminary deployment unit deploys a first server for calling the API and a second server for providing services in the microservice; A setting unit, which sets the path of the product in the microservice according to a preset service name; A polling unit, polling the path of the product in the microservice through the first server according to a preset period; A deployment result unit, if there is no abnormality in the path of the product in the microservice in the polling result, completes the deployment of the first server and the second server in the microservice, and provides the corresponding service through the second server; Before completing the deployment of the first server and the second server in the microservice, the device is further used to: Set the IP address of the product in the microservice; Poll the IP addresses of the products in the microservice according to a preset period; If there is no abnormality in the IP address of the product in the microservice in the polling result, the deployment of the microservice is completed; After completing the deployment of the first server and the second server in the microservice, the device is further used to: Record the IP address and path of the product in the microservice into the configuration file of the first server, and record the timestamp in the configuration file; If the path and IP address of the product in the microservice are polled through the first server at the next moment of the timestamp, it is determined whether the path and IP address of the product in the microservice are recorded in the configuration file; If the path and IP address of the product in the microservice are recorded in the configuration file, terminate the polling; If the path and IP address record of the product in the microservice is not in the configuration file, it also includes: Polling the path and IP address of the product in the microservice through the first server; If the path of the product in the microservice described in the polling result is abnormal, the service of the product will be terminated; After the deployment of the first server and the second server in the microservice is completed, the method further includes: Dynamically register the IP address and path of the product into the load balancing server so as to dynamically adjust the load of the product through the load balancing server; After the deployment of the first server and the second server in the microservice is completed, the method further includes: Monitor and diagnose access to said products.

3. A microservice deployment device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: Deploy a first server that calls the API and a second server that provides services in the microservice; According to the preset service name, set the path of the product in the microservice; According to a preset period, polling the path of the product in the microservice through the first server; If there is no abnormality in the path of the product in the microservice in the polling result, the deployment of the first server and the second server in the microservice is completed, and the corresponding service is provided through the second server; Before completing the deployment of the first server and the second server in the microservice, the method further includes: Set the IP address of the product in the microservice; Poll the IP addresses of the products in the microservice according to a preset period; If there is no abnormality in the IP address of the product in the microservice in the polling result, the deployment of the microservice is completed; After the deployment of the first server and the second server in the microservice is completed, the method further includes: Record the IP address and path of the product in the microservice into the configuration file of the first server, and record the timestamp in the configuration file; If the path and IP address of the product in the microservice are polled through the first server at the next moment of the timestamp, it is determined whether the path and IP address of the product in the microservice are recorded in the configuration file; If the path and IP address of the product in the microservice are recorded in the configuration file, terminate the polling; If the path and IP address record of the product in the microservice is not in the configuration file, it also includes: Polling the path and IP address of the product in the microservice through the first server; If the path of the product in the microservice described in the polling result is abnormal, the service of the product will be terminated; After the deployment of the first server and the second server in the microservice is completed, the method further includes: Dynamically register the IP address and path of the product into the load balancing server so as to dynamically adjust the load of the product through the load balancing server; After the deployment of the first server and the second server in the microservice is completed, the method further includes: Monitor and diagnose access to said products.

4. A non-volatile computer storage medium, characterized in that: A computer executable instruction is stored, wherein the computer executable instruction is configured to: Deploy a first server that calls the API and a second server that provides services in the microservice; According to the preset service name, set the path of the product in the microservice; According to a preset period, polling the path of the product in the microservice through the first server; If there is no abnormality in the path of the product in the microservice in the polling result, the deployment of the first server and the second server in the microservice is completed, and the corresponding service is provided through the second server; Before completing the deployment of the first server and the second server in the microservice, the method further includes: Set the IP address of the product in the microservice; Poll the IP addresses of the products in the microservice according to a preset period; If there is no abnormality in the IP address of the product in the microservice in the polling result, the deployment of the microservice is completed; After the deployment of the first server and the second server in the microservice is completed, the method further includes: Record the IP address and path of the product in the microservice into the configuration file of the first server, and record the timestamp in the configuration file; If the path and IP address of the product in the microservice are polled through the first server at the next moment of the timestamp, it is determined whether the path and IP address of the product in the microservice are recorded in the configuration file; If the path and IP address of the product in the microservice are recorded in the configuration file, terminate the polling; If the path and IP address record of the product in the microservice is not in the configuration file, it also includes: Polling the path and IP address of the product in the microservice through the first server; If the path of the product in the microservice described in the polling result is abnormal, the service of the product will be terminated; After the deployment of the first server and the second server in the microservice is completed, the method further includes: Dynamically register the IP address and path of the product into the load balancing server so as to dynamically adjust the load of the product through the load balancing server; After the deployment of the first server and the second server in the microservice is completed, the method further includes: Monitor and diagnose access to said products.

Citation Information

Patent Citations

  • Micro-service deployment method, equipment and medium

    CN113760311A