Service calling method based on micro-service system and server
By using the sidecar pattern component to proxy service governance capabilities in the Spring Cloud microservice system, business services and service governance are decoupled, solving the intrusiveness and complexity issues caused by developers integrating service governance into applications and improving development efficiency.
Patent Information
- Application Number
- CN202211151852.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-21
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2042-09-21
AI Technical Summary
When building applications using the Spring Cloud microservices ecosystem, service developers need to integrate service governance capabilities into the application, which leads to intrusion and additional complexity, affecting development efficiency.
The sidecar pattern component proxies all service governance capabilities in a Spring Cloud-based microservice system and communicates via Hypertext Transfer Protocol, decoupling business services from service governance capabilities and avoiding the integration of Spring Cloud service governance capabilities into the application.
It improves the efficiency of application development, allowing service developers to focus on business service development without additional complexity and intrusion, and supports native Spring Cloud features, reducing the difficulty of migration.
Smart Images

Figure CN115567604B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to microservice governance technology, and in particular to a service calling method based on a microservice system and a server. BACKGROUND
[0002] A microservice is a small application that can be independently deployed. In a microservice architecture mode, a complete application system can be composed of multiple microservices.
[0003] In the prior art, Spring Cloud is a commonly used microservice framework that provides configuration management, service discovery, circuit breaker, intelligent routing, microagent, control bus and other components required for microservice development.
[0004] However, when building an application using the Spring Cloud microservice ecosystem, service developers often need to integrate the service governance capabilities of Spring Cloud in the application, thus bringing invasiveness and additional complexity, which in turn affects the efficiency of developing the application. SUMMARY
[0005] The present disclosure provides a service calling method based on a microservice system and a server to solve the problem that in the prior art, when building an application using the Spring Cloud microservice ecosystem, service developers often need to integrate the service governance capabilities of Spring Cloud in the application, thus bringing invasiveness and additional complexity, which in turn affects the efficiency of developing the application.
[0006] According to a first aspect of the present disclosure, a service calling method based on a microservice system is provided, which internally uses the Hypertext Transfer Protocol (HTTP) for communication, and includes:
[0007] receiving an interface calling request of a user terminal;
[0008] According to the interface calling request, and using a sidecar mode component corresponding to a first service pre-configured in the microservice system, a target service is determined and called, and a return value is obtained; wherein the microservice system includes multiple first services; the sidecar mode component is used to proxy the service governance capabilities of the first service corresponding to the sidecar mode component;
[0009] returning the return value to the user terminal.
[0010] According to a second aspect of the present disclosure, a service calling device based on a microservice system is provided, which internally uses the Hypertext Transfer Protocol (HTTP) for communication, and includes:
[0011] An obtaining unit is configured to receive an interface calling request of a user terminal;
[0012] The invocation unit is used to determine and invoke the target service based on the interface invocation request and by utilizing the pre-configured sidecar mode component corresponding to the first service in the microservice system, and to obtain the return value; wherein, the microservice system includes multiple first services; the sidecar mode component is used to proxy the service governance capabilities of the first service corresponding to the sidecar mode component;
[0013] A return unit is used to return the return value to the user terminal.
[0014] According to a third aspect of this disclosure, a server is provided, including a memory and a processor; wherein,
[0015] The memory is used to store computer programs;
[0016] The processor is configured to read the computer program stored in the memory and execute the service invocation method for a microservice-based system as described in the first aspect, based on the computer program in the memory.
[0017] According to a fourth aspect of this disclosure, a computer-readable storage medium is provided, wherein computer-executable instructions are stored therein, and when a processor executes the computer-executable instructions, the service invocation method based on a microservice system as described in the first aspect is implemented.
[0018] According to a fifth aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the service invocation method for a microservice-based system as described in the first aspect.
[0019] The service calling method based on a micro-service system and the server provided by the present disclosure internally communicate by using a hypertext transfer protocol, and include: receiving an interface calling request of a user terminal; determining and calling a target service according to the interface calling request and by using a sidecar mode component corresponding to the first service and pre-configured in the micro-service system, and obtaining a return value; wherein the micro-service system includes a plurality of first services; the sidecar mode component is used for proxying service management capabilities of the first service corresponding to the sidecar mode component; and the return value is returned to the user terminal. In the service calling method based on a micro-service system and the server provided by the present disclosure, the sidecar mode component is used for proxying all service management capabilities in the micro-service system based on a Spring Cloud architecture, and the internal communication is performed by using a hypertext transfer protocol of the Spring Cloud, so that the business service and the service management capability of the micro-service system based on the Spring Cloud architecture are decoupled, and when the application program is constructed by using the SpringCloud micro-service ecological system, the service developer no longer needs to integrate the service management capability of the SpringCloud in the application program, and the invasiveness and the additional complexity are eliminated, so that the service developer can focus on developing the business service, and the efficiency of developing the application program is improved. BRIEF DESCRIPTION OF DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present disclosure, and other drawings can be obtained by those skilled in the art without any creative effort on the basis of these drawings.
[0021] Figure 1 A flowchart of a service calling method based on a micro-service system according to an example embodiment of the present disclosure is shown.
[0022] Figure 2 A flowchart of a service calling method based on a micro-service system according to another example embodiment of the present disclosure is shown.
[0023] Figure 3 A service calling process diagram based on a micro-service system according to an example embodiment of the present disclosure is shown.
[0024] Figure 4 A service registration and discovery process diagram according to an example embodiment of the present disclosure is shown.
[0025] Figure 5 A configuration update process diagram according to an example embodiment of the present disclosure is shown.
[0026] Figure 6A process diagram of acquiring observability capability of a service, shown for an exemplary embodiment of the present disclosure;
[0027] Figure 7 A structural diagram of a service calling apparatus based on a micro-service system, shown for an exemplary embodiment of the present disclosure;
[0028] Figure 8 A structural diagram of a service calling apparatus based on a micro-service system, shown for another exemplary embodiment of the present disclosure;
[0029] Figure 9 A structural diagram of a server, shown for an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0030] A micro-service is a small application that can be independently deployed. In a micro-service architecture mode, a complete application system can be composed of multiple micro-services. In the prior art, Spring Cloud is a commonly used micro-service framework that provides configuration management, service discovery, circuit breaker, intelligent routing, micro-agent, control bus and other components required for micro-service development.
[0031] However, Spring Cloud is an application layer service governance solution that has great invasiveness to business services. When building an application using the Spring Cloud micro-service ecosystem, service developers often need to integrate the service governance capabilities of Spring Cloud in the application, thus bringing invasiveness and additional complexity to the business services, and further affecting the efficiency of developing the application.
[0032] Service Mesh architecture mode was born in this background. It sinks the service governance capability to the network layer and separates it from the service. The most famous framework in the Service Mesh architecture mode is istio, which uses Envoy as the “data plane”, and istio provides the “control plane”. They communicate with each other using the xDS protocol. The service governance capability is run and managed separately.
[0033] However, although such open source frameworks as istio have rich functions, they are very cumbersome and have high learning and use costs. Istio and Linkerd in the Service Mesh architecture mode do not support the native functions of Spring Cloud. Due to the prevalence of Spring Cloud, many users are unwilling to migrate and do not have the ability and resources to complete this task. Therefore, the use cost of istio and Linkerd is too high, and the migration cost is too high. If you want to introduce istio or Linkerd for service governance, the challenge to research and development and operation and maintenance is considerable, and it is impossible to achieve in a short time.
[0034] To solve the above technical problems, in the scheme provided by the present disclosure, a pre-set sidecar mode component is used to proxy all service governance capabilities in a micro-service system based on a Spring Cloud architecture, and the internal communication is carried out by using a Hyper Text Transfer Protocol (HTTP) protocol native to Spring Cloud, so that the business service and the service governance capability of the micro-service system based on the Spring Cloud architecture are decoupled, and thus when an application is built using a Spring Cloud micro-service ecosystem, a service developer no longer needs to integrate the service governance capability of Spring Cloud in the application, and there is no invasiveness and additional complexity, so that the service developer can focus on developing the business service, and thus the efficiency of developing the application is improved; moreover, the method provided by the present disclosure supports the native function of Spring Cloud, and no migration is needed, and the sidecar mode component is configured in the Spring Cloud architecture, which is easier to master than introducing istio and Linkerd.
[0035] The technical scheme of the present disclosure and how the technical scheme of the present disclosure solves the above technical problems will be described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes can not be described in detail in some embodiments. The embodiments of the present disclosure will be described below with reference to the accompanying drawings.
[0036] Figure 1 A flowchart of a service calling method based on a micro-service system according to an example embodiment of the present disclosure is shown.
[0037] As shown in Figure 1 , the service calling method based on a micro-service system provided by the present embodiment includes:
[0038] Step 101, receiving an interface calling request of a user terminal.
[0039] The method provided by the present disclosure can be executed by an electronic device with computing capability, such as a computer or the like.
[0040] The electronic device is provided with a micro-service system based on a Spring Cloud architecture, and the interface calling request of the user terminal can be received through a gateway in the micro-service system.
[0041] Specifically, the user terminal can call the required service in the micro-service system by sending an interface calling request to the micro-service system.
[0042] The micro-service system is a system based on a Spring Cloud architecture, and the micro-service system is a distributed system.
[0043] Specifically, the micro-service system and the user terminal can communicate through the Hyper Text Transfer Protocol (HTTP) of Spring Cloud.
[0044] In step 102, according to the interface calling request, a target service is determined and called by using a sidecar mode component corresponding to the first service pre-configured in the micro-service system, and a return value is obtained; the micro-service system includes a plurality of first services; the sidecar mode component is used to proxy the service management capability of the first service corresponding to the sidecar mode component; and the internal communication is performed through the Hyper Text Transfer Protocol.
[0045] The sidecar mode is a common mode in the Service Mesh. The division of the functions of an application into separate processes can be regarded as the sidecar mode. The sidecar mode allows more functions to be added to the application without additional third-party component configuration or modification of the application code.
[0046] Specifically, the micro-service system includes a plurality of first services, and each first service refers to a micro-service.
[0047] Specifically, a corresponding sidecar mode component can be pre-configured for each first service in the micro-service system, and the sidecar mode component is used to proxy the service management capability of the first service corresponding to the sidecar mode component. In this way, all the service management capabilities of the micro-service system are concentrated in the sidecar mode component. Further, the business logic and the service management capability are decoupled.
[0048] Specifically, according to the interface calling request, a target service can be determined and called by using the sidecar mode component corresponding to the first service, and a return value is obtained.
[0049] Specifically, the micro-service system and the user terminal can communicate through the Hyper Text Transfer Protocol (HTTP) of Spring Cloud.
[0050] In step 103, the return value is returned to the user terminal.
[0051] Specifically, the micro-service system can send the obtained return value to the user terminal through the gateway.
[0052] The service calling method based on the micro-service system provided by the present disclosure internally uses the hypertext transfer protocol for communication, and comprises the following steps: receiving an interface calling request of a user terminal; determining and calling a target service according to the interface calling request and by using a sidecar mode component corresponding to the first service and pre-configured in the micro-service system, and obtaining a return value; wherein the micro-service system comprises a plurality of first services; the sidecar mode component is used to proxy the service management capability of the first service corresponding to the sidecar mode component; and the return value is returned to the user terminal. In the method adopted by the present disclosure, the sidecar mode component is used to proxy all service management capabilities in the micro-service system based on the Spring Cloud architecture, and the hypertext transfer protocol is used for internal communication, so that the business service and the service management capability of the micro-service system based on the Spring Cloud architecture are decoupled, and thus when the Spring Cloud micro-service ecological application program is constructed, the service developer no longer needs to integrate the service management capability of the Spring Cloud in the application program, and there is no invasiveness and additional complexity, so that the service developer can focus on developing the business service, and thus the efficiency of developing the application program is improved. Moreover, the method adopted by the present disclosure supports the SpringCloud native function, and no migration is needed, and the sidecar mode component is configured in the Spring Cloud architecture, which is relatively easier to master than the introduction of istio and Linkerd, so the method adopted by the present disclosure is easier to use.
[0053] Figure 2 The flowchart of the service calling method based on the micro-service system shown for another exemplary embodiment of the present disclosure.
[0054] As Figure 2 shown, the service calling method based on the micro-service system provided by the present embodiment comprises the following steps:
[0055] Step 201, receiving an interface calling request of a user terminal.
[0056] Specifically, the principle and implementation manner of step 201 are similar to those of step 101, and will not be repeated here.
[0057] In step 202, according to the interface call request, a sidecar mode component corresponding to the first service in the micro-service system is used to determine and call the target service, and a return value is obtained; wherein the micro-service system comprises a plurality of first services; the sidecar mode component is used to proxy the service management capability of the first service corresponding to the sidecar mode component; wherein internal communication is performed by using the hypertext transfer protocol; the sidecar mode component comprises one or a combination of the following: a service registration and discovery module, a configuration update module, a monitoring module, a traffic proxy module, and a traffic management module; wherein the service registration and discovery module is used to interact with a preset service registry component and interact with the first service proxied by the sidecar mode component; the configuration update module is used to interact with a preset configuration center component and manage the configuration of the first service; the monitoring module is used to collect logs and preset indicators of the first service, implement link tracking, and obtain link information; the traffic proxy module is used to implement north-south traffic between the target service and the user terminal by using the hypertext transfer protocol, implement east-west traffic between the first service and other first services by using the hypertext transfer protocol, perform load balancing operations, and perform message conversion operations; and the traffic management module is used to manage the traffic of the first service.
[0058] Specifically, the sidecar mode component is used to proxy the service management capability of the first service corresponding to the sidecar mode component. The sidecar mode component can comprise one or a combination of the following: a service registration and discovery module, a configuration update module, a monitoring module, a traffic proxy module, and a traffic management module.
[0059] The service registry component can be a service discovery framework in Spring Cloud, and the service registry component can be preset as needed, for example, Eureka in Spring Cloud can be preset as the service registry component, or Nacos in Spring Cloud can be preset as the service registry component.
[0060] Specifically, the service registration and discovery module can be used to interact with the preset service registry component, or can be used to interact with the first service proxied by the sidecar mode component.
[0061] The configuration center component can be used to manage the configuration of the micro-service system. The configuration center component can be preset as needed. The configuration center component can use Apollo, which is a distributed configuration center.
[0062] Specifically, the configuration update module can be used to interact with the preset configuration center component, and can be used to manage the configuration of the first service.
[0063] The preset index is an index preset according to actual needs, and can include, for example, a query per second (QPS) of the first service, a total number of calls, an average response time, a maximum response time, a minimum response time, a number of occurrences of a business index, and a fluctuation of the business.
[0064] Specifically, the preset monitoring module can be configured to collect logs of the first service and the preset index, and to implement link tracking and obtain link information according to the link tracking.
[0065] Specifically, the monitoring module can implement link tracking by integrating an OpenTelemetry (OTEL) software development kit (SDK).
[0066] The north-south traffic refers to traffic between a user terminal and a target service via a gateway in the microservice system.
[0067] The east-west traffic refers to traffic between first services in the microservice system.
[0068] Specifically, each first service in the microservice system can be a consumer service or a provider service. When a service is called according to an interface call request, the consumer service can be used to call the provider service. The consumer service can use a load balancing operation to select a provider service, i.e., a target service, to be called.
[0069] Specifically, the message conversion refers to converting the format of a return value into a preset format.
[0070] Specifically, the traffic proxy module can be configured to implement north-south traffic between a target service and a user terminal via a Spring Cloud native hypertext transfer protocol, implement east-west traffic between a first service that is a sidecar mode component proxy and other first services via a Spring Cloud native hypertext transfer protocol, perform a load balancing operation, and perform a message conversion operation.
[0071] Specifically, the traffic management module can be configured to manage traffic of the first service to achieve better data transmission effect.
[0072] In an implementation, the service registration and discovery module is configured to: perform heartbeat connection with a preset service registry component to realize data interaction and health check with the service registry component, and complete service registration and discovery of the service registration and discovery module; perform heartbeat connection with the first service to realize state synchronization and health check with the first service; obtain and save a service registry from the preset service registry component; and perform graceful online or graceful offline of the first service.
[0073] Specifically, the service registration and discovery module can be configured to perform heartbeat connection with a preset service registry component, to realize data interaction with the service registry component through the heartbeat connection, and to realize health check of the service registry component on the sidecar mode component through the heartbeat connection, and to complete service registration and discovery of the sidecar mode component itself through the heartbeat connection.
[0074] Specifically, the service registration and discovery module can also perform heartbeat connection with the first service that is proxied by the sidecar mode component, to realize state synchronization of the sidecar mode component and the proxied first service through the heartbeat connection, and to realize health check of the sidecar mode component on the proxied first service through the heartbeat connection. Here, the state can be an available state, an unavailable state, etc. of the first service.
[0075] The service registry includes information of each first service in the microservice system.
[0076] Specifically, the service registration and discovery module can obtain the service registry from the preset service registry component and save the service registry. The target service can be invoked according to the service registry.
[0077] Specifically, if the first service is a provider service and it is determined that the first service has a problem, the service registration and discovery module can perform graceful offline of the first service that has been online. If it is determined that the first service is ready, the service registration and discovery module can perform graceful online of the first service again.
[0078] In an implementation, the configuration updating module is configured to: obtain an initial configuration through interaction with a preset configuration center component; and update a local configuration of the first service according to the initial configuration.
[0079] Specifically, configuration properties and distinguishing identifiers of each first service in the microservice system can be preset by using the preset configuration center component. The configuration updating module can subscribe to the configuration properties of the first service that is proxied by the sidecar mode component through interaction with the preset configuration center component, and thus obtain an initial configuration of the first service. The local configuration of the first service can be updated according to the initial configuration.
[0080] The remote configuration monitoring is performed through interaction with the preset configuration center component to obtain a monitoring result; if the monitoring result shows that the configuration corresponding to the first service changes, the remote configuration updating is performed; the remote configuration updating is used for updating the local configuration of the first service again through remote configuration analysis.
[0081] Specifically, the configuration updating module can perform remote configuration monitoring on the first service of the proxy through interaction with the preset configuration center component, and then obtain a monitoring result. If the monitoring result shows that the configuration corresponding to the first service changes, the remote configuration updating can be performed on the first service. The remote configuration updating can be used for obtaining the updated configuration of the first service from the preset configuration center component through remote configuration analysis, and updating the local configuration of the first service again with the updated configuration.
[0082] In an implementable manner, the monitoring module is further configured to send the obtained log, preset index and link information to a message queue, so as to analyze the running condition of the first service according to the log, preset index and link information.
[0083] Specifically, the monitoring module can send the obtained log, preset index and link information of the first service of the sidecar mode component proxy to a message queue. The Logstash or ElasticSearch component in Spring Cloud can obtain the log information from the message queue, analyze and process the log information, and infer the internal running condition of the first service according to the analysis result. The Prometheus component in Spring Cloud can obtain the preset index from the message queue, analyze and process the preset index, and infer the internal running condition of the first service according to the analysis result. The Jaeger, Zipkin and SkyWalking components in Spring Cloud can obtain the link information from the message queue, analyze and process the link information, and infer the internal running condition of the first service according to the analysis result.
[0084] The running condition of the first service can be analyzed to obtain the observability of the first service. The observability refers to the ability to measure the internal state of a system by checking the output indicators of the system. If the current running condition of the system can be inferred only by using the data information from the output, the system is considered to have the observability.
[0085] In an implementable manner, the traffic proxy module is specifically configured to select a service instance for a request between the first services according to a preset load balancing algorithm.
[0086] The preset load balancing algorithm can be one of the following algorithms: round robin algorithm, random algorithm, weight algorithm, and minimum response time algorithm.
[0087] Specifically, the load balancing algorithm can be preset as needed, and the consumer service in the micro-service system is selected to call the provider service according to the preset load balancing algorithm.
[0088] The traffic sent to the sidecar mode component is sent to the sidecar mode component corresponding to the other first service.
[0089] Specifically, the traffic proxy module can send the traffic sent to the sidecar mode component corresponding to the first service to the sidecar mode component corresponding to the other first service, thereby realizing the interaction between the internal services (i.e., the first services) in the micro-service system.
[0090] The format of the return value is converted into a preset format.
[0091] The preset format is a format preset as needed. For example, the preset format can be a json format.
[0092] Specifically, the traffic proxy module can also convert the format of the return value into a preset format.
[0093] In one implementation manner, the traffic management module is specifically configured to perform one or a combination of the following operations on the traffic of the first service: fuse, limit flow, gray release, traffic shaping, and traffic dyeing.
[0094] The gray release means that the first service can be exposed to only part of the users as needed, and then the first service can be improved by analyzing the use of the first service, and then the improved first service is exposed to all users.
[0095] The traffic dyeing means that a special mark preset in the interface call request is subjected to a special processing preset accordingly.
[0096] Specifically, the traffic management module can perform one or a combination of the following operations on the traffic of the first service: fuse, limit flow, gray release, traffic shaping, and traffic dyeing.
[0097] Figure 3 A service call process diagram based on a micro-service system is shown for an exemplary embodiment of the present disclosure.
[0098] As Figure 3As shown, the user terminal can send an interface call request to the micro-service system, the micro-service system can receive the interface call request through the gateway, and can obtain a consumer service in the micro-service system according to the interface call request, and interact with a pre-set sidecar mode component corresponding to a target service obtained through a pre-set load balancing algorithm, call the target service, and obtain a return value. The return value can be returned to the user terminal through the gateway. The user terminal and the gateway can communicate through the Spring Cloud native Hyper Text Transfer Protocol (HTTP) protocol. The sidecar mode components corresponding to the services in the micro-service system can also communicate through the Spring Cloud native Hyper Text Transfer Protocol (HTTP) protocol.
[0099] Specifically, the sidecar mode components corresponding to the services can include a service registration and discovery module, a configuration update module, a monitoring module, a traffic proxy module, and a traffic management module.
[0100] Specifically, the service registration and discovery module can be used to interact with a service registration center component such as Eureka or Nacos, and to perform health checks, and can obtain a service registration table through the interaction; can be used to interact with the first service of the proxy and to perform health checks; can be used to perform graceful online or graceful offline of the first service of the proxy.
[0101] As shown in Figure 4 When a request call between services occurs (east-west traffic), the original business service on the left directly calls the business service on the right, and after the Sidecar, the Sidecar can complete service registration and discovery. The whole process is: service A initiates a request to service B, first the traffic passes through Sidecar A corresponding to service A, Sidecar A obtains the service registration table from the service registration center component Eureka or Nacos according to the service name of service B, and then initiates a request to Sidecar B corresponding to service B, and Sidecar B transfers the request to service B.
[0102] Specifically, the configuration update module can interact with a configuration center component such as Apollo, and then perform remote configuration listening to obtain a listening result; if the listening result shows that the configuration corresponding to the first service has changed, remote configuration updating is performed; the remote configuration updating is used to update the local configuration of the first service through remote configuration analysis and hot updating.
[0103] As shown in Figure 5As shown, Sidecar A and Sidecar B integrate the SDK of Apollo configuration center, and the configuration information can be updated at any time on the management page of Apollo configuration center.
[0104] Specifically, the monitoring module can collect logs, preset indicators of the first service, and link information obtained through link tracking, and can send the logs, preset indicators, and link information to the message queue.
[0105] As shown, Figure 6 The Sidecar can collect logs, indicators, and link information of the services it proxies. It can send the logs, indicators, and link information to the message queue for subsequent processing and analysis, and obtain the observability capability of the services.
[0106] Specifically, the traffic proxy module can be used to implement north-south traffic between the target service and the user terminal through the hypertext transfer protocol, implement east-west traffic between the first services through the hypertext transfer protocol, perform load balancing operations, and perform message conversion operations.
[0107] Specifically, the traffic management module can perform one or a combination of the following operations on the traffic of the proxied first service: fuse, limit flow, gray release, traffic shaping, and traffic dyeing.
[0108] Figure 7 A structural diagram of a service calling device of a microservice system based on a Spring Cloud architecture according to an example embodiment of the present disclosure.
[0109] As shown, Figure 7 The microservice system-based service calling device 700 provided by the present disclosure includes:
[0110] The acquisition unit 710 is configured to receive an interface calling request of a user terminal.
[0111] The calling unit 720 is configured to determine and call a target service according to the interface calling request and using a sidecar mode component corresponding to the first service pre-configured in the microservice system, and obtain a return value. The microservice system includes a plurality of first services. The sidecar mode component is used to proxy the service management capability of the first service corresponding to the sidecar mode component.
[0112] The return unit 730 is configured to return the return value to the user terminal.
[0113] Figure 8 A structural diagram of a microservice system-based service calling device according to another example embodiment of the present disclosure.
[0114] As shown, Figure 8As shown, on the basis of the above embodiments, the service calling device 800 based on the micro-service system provided by the disclosure, the sidecar mode component in the calling unit 720 includes one or a combination of the following:
[0115] The service registration and discovery module 721, the configuration updating module 722, the monitoring module 723, the traffic proxy module 724, and the traffic management module 725.
[0116] The service registration and discovery module 721 is configured to interact with a preset service registry component and interact with a first service in the sidecar mode component. The configuration updating module 722 is configured to interact with a preset configuration center component and manage the configuration of the first service. The monitoring module 723 is configured to collect logs and preset indicators of the first service, implement link tracking, and obtain link information. The traffic proxy module 724 is configured to implement north-south traffic between a target service and a user terminal through the hypertext transfer protocol, implement east-west traffic between the first service and other first services through the hypertext transfer protocol, perform load balancing operations, and perform message conversion operations. The traffic management module 725 is configured to manage the traffic of the first service.
[0117] The service registration and discovery module 721 is specifically configured to: perform heartbeat connection with the preset service registry component to realize data interaction and health check with the service registry component and complete service registration and discovery of itself; perform heartbeat connection with the first service to realize state synchronization and health check with the first service; obtain and save a service registration table from the preset service registry component; and perform graceful online or graceful offline of the first service.
[0118] The configuration updating module 722 is specifically configured to: obtain an initial configuration through interaction with the preset configuration center component; and update the local configuration of the first service according to the initial configuration.
[0119] The configuration updating module 722 is specifically configured to: obtain a listening result through remote configuration listening by interacting with the preset configuration center component; if the listening result shows that the configuration corresponding to the first service has changed, perform remote configuration updating; and the remote configuration updating is configured to update the local configuration of the first service again through remote configuration analysis.
[0120] The monitoring module 723 is further configured to: send the obtained logs, preset indicators, and link information to a message queue; and analyze the running condition of the first service according to the logs, preset indicators, and link information.
[0121] The traffic proxy module 724 is specifically configured to: select service instances for requests between the first services according to a preset load balancing algorithm.
[0122] The traffic sent to the sidecar mode component is sent to a sidecar mode component corresponding to the other first service.
[0123] The format of the return value is converted into a preset format.
[0124] The traffic governance module 725 is specifically configured to perform one or a combination of the following operations on the traffic of the first service: fuse, limit flow, gray release, traffic shaping, and traffic dyeing.
[0125] Figure 9 A structural diagram of a server according to an example embodiment of the present disclosure.
[0126] As shown in Figure 9 The electronic device provided by the embodiment includes:
[0127] a memory 901;
[0128] a processor 902; and
[0129] a computer program;
[0130] The computer program is stored in the memory 901 and is configured to be executed by the processor 902 to implement any of the service calling methods based on the micro-service system as described above.
[0131] The embodiment also provides a computer-readable storage medium having a computer program stored thereon, and the computer program is executed by a processor to implement any of the service calling methods based on the micro-service system as described above.
[0132] The embodiment also provides a computer program product including a computer program, and the computer program is executed by a processor to implement any of the service calling methods based on the micro-service system as described above.
[0133] Those skilled in the art can understand that all or part of the steps of the above-mentioned method embodiments can be completed by program instructions related to hardware. The foregoing program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the foregoing storage medium includes: ROM, RAM, magnetic disk or optical disk and various media that can store program codes.
[0134] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A service calling method of a micro-service system based on a Spring Cloud architecture, characterized in that, The micro-service system internally communicates by using a Spring Cloud native hypertext transfer protocol, and the method comprises the following steps: An interface calling request of a user terminal is received; According to the interface calling request, a target service is determined and called by using a sidecar mode component corresponding to a first service in the micro-service system, and a return value is obtained; wherein the micro-service system comprises a plurality of first services; the sidecar mode component is used for proxying service governance capability of the first service corresponding to the sidecar mode component; the sidecar mode component comprises a service registration and discovery module, a configuration updating module, a monitoring module, a traffic proxy module and a traffic management module; The return value is returned to the user terminal; The service registration and discovery module is used for heart beat connection with a preset service registration center component to realize data interaction and health check with the service registration center component, and to complete service registration and discovery of itself; the service registration and discovery module is used for heart beat connection with the first service to realize state synchronization and health check with the first service; the service registration and discovery module is used for obtaining and saving a service registration table from the preset service registration center component; the service registration and discovery module is used for graceful online or graceful offline of the first service; The configuration updating module is used for obtaining an initial configuration by interacting with the preset configuration center component, and updating a local configuration of the first service according to the initial configuration; the configuration updating module is used for remote configuration listening by interacting with the preset configuration center component to obtain a listening result; if the listening result shows that the configuration corresponding to the first service changes, remote configuration updating is performed; the remote configuration updating is used for updating the local configuration of the first service again by remote configuration analysis; The monitoring module is used for collecting logs and preset indexes of the first service, and realizing link tracking and obtaining link information; the logs, the preset indexes and the link information are sent to a message queue to realize analysis of running conditions of the first service according to the logs, the preset indexes and the link information; The traffic proxy module is used for realizing north-south traffic between the target service and the user terminal by the hypertext transfer protocol, and realizing east-west traffic between the first service and other first services by the hypertext transfer protocol; the traffic sent to the sidecar mode component is sent to a sidecar mode component corresponding to other first services; the format of the return value is converted into a preset format; The traffic management module is used for managing the traffic of the first service.
2. The method of claim 1, wherein, The traffic proxy module is further used for: According to a preset load balancing algorithm, service instances are selected for requests between the first services.
3. The method of claim 1, wherein, The traffic management module is specifically used for performing one or a combination of the following operations on the traffic of the first service: Fusing, limiting, releasing in gray scale, traffic shaping and traffic dyeing.
4. A service calling apparatus based on a micro-service system, configured to implement the method according to any one of claims 1-3, characterized in that, Internally communicate by using a hypertext transfer protocol, comprising: An acquisition unit is configured to receive an interface calling request of a user terminal; The calling unit is configured to determine and call the target service according to the interface calling request and by using a sidecar mode component corresponding to the first service and pre-configured in the micro-service system, and obtain a return value; the micro-service system includes a plurality of first services; the sidecar mode component is configured to proxy service governance capabilities of the first service corresponding to the sidecar mode component; The returning unit is configured to return the return value to the user terminal.
5. A server, characterized by comprise a memory and a processor; wherein The memory is configured to store a computer program. The processor is configured to read the computer program stored in the memory, and execute the method according to any one of claims 1-3 according to the computer program in the memory.
6. A computer readable storage medium characterized by, The computer readable storage medium stores computer execution instructions, and when the processor executes the computer execution instructions, the method according to any one of claims 1-3 is implemented.
7. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor, and the method according to any one of claims 1-3 is implemented.
Citation Information
Patent Citations
Micro-service engine based on proxy mode
CN109981789A
Micro-service treatment system
CN110554856A
Micro-service-based processing method and device, storage medium and electronic device
CN111917838A
Service invocation request routing methods, service creation methods and devices
CN114938396A
Microservice invoking method and apparatus, device and medium
WO2021179841A1