A service detection system
Through the API gateway and unified service detection service, the decoupling of middleware services and service detection systems is realized, which solves the security risks and high joint debugging costs caused by Agent probes in the existing technology, and improves the flexibility of service detection. sex and safety.
Patent Information
- Application Number
- CN202211492500.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-25
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2042-11-25
AI Technical Summary
The existing service detection system has security risks and high joint debugging costs by deploying Agent probes on the Redis service. It is also inflexible and difficult to adapt to different needs and environments.
Design a service detection system to realize the decoupling of middleware services and service detection systems through application program interface gateway (API gateway) and unified service detection services. The middleware service can actively upload detection data through the API gateway to avoid in-between Deploy Agent probe on the software service.
It improves the security and flexibility of middleware services, reduces joint debugging and communication costs, supports diversified needs, and improves the security and real-time nature of detection data collection.
Smart Images

Figure CN115883405B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to a service detection system. Background Art
[0002] The current service detection system detects the Redis service mainly by deploying Agent probes on the Redis service, and then actively collects the detection data of the Redis service based on the Agent probes.
[0003] However, Agent probes deployed in an intrusive manner will bring security risks to the Redis service and create a strong connection between the Redis service and the service detection system. This strong connection will increase the coordination and communication costs between the two parties in many cases, resulting in a poor user experience. Summary of the invention
[0004] The embodiment of the present invention provides a service detection system to achieve decoupling between a middleware service and the service detection system, and ensure the security of the middleware service.
[0005] According to one aspect of the present invention, a service detection system is provided, which may include: an application program interface gateway and at least one service detection service, wherein the at least one service detection service includes at least one of a detection data upload service, a detection data query service, a detection index query service, and a detection index update service; wherein,
[0006] An application program interface gateway, used to receive a service call request sent by a middleware service, and forward the service call request to a target service called in at least one service detection service;
[0007] The target service is used to respond to the service call request and return the response result to the application interface gateway;
[0008] The application interface gateway is also used to return the response results to the middleware service.
[0009] Optionally, in the case where the target service is a detection data upload service, the target service is specifically used to upload the detection data to be uploaded corresponding to the service call request to the database, and return the obtained data upload result to the application program interface gateway;
[0010] and / or,
[0011] In the case where the target service is a detection data query service, the target service is specifically used to query the database based on the detection data to be queried corresponding to the service call request, and return the obtained data query result to the application interface gateway;
[0012] and / or,
[0013] In the case where the target service is a detection indicator query service, the target service is specifically used to query the indicator library based on the detection indicator to be queried corresponding to the service call request, and return the obtained indicator query result to the application interface gateway;
[0014] and / or,
[0015] In the case where the target service is a detection indicator update service, the target service is specifically used to update the indicator library based on the detection indicator to be updated corresponding to the service call request, and return the obtained indicator update result to the application interface gateway.
[0016] Optionally, an application program interface gateway is specifically used to receive a service call request sent by any middleware service of at least two middleware services, and forward the service call request to a target service called in at least one service detection service;
[0017] The application program interface gateway is also specifically used to determine the request service that sends the service call request among at least two middleware services, and return the response result to the request service.
[0018] On this basis, optionally, the types of at least two middleware services include at least one of a Redis service, a MySQL service, and an Elasticsearch service, and the number of middleware services under any type among the at least two middleware services is at least one.
[0019] Optionally, the service detection system further includes a load balancing service, and the number of application program interface gateways is at least two; wherein,
[0020] A load balancing service, used to receive a service call request sent by the middleware service, and forward the service call request to a load balanced target gateway among at least two application interface gateways;
[0021] The target gateway is specifically used to forward the service call request to the target service called in at least one service detection service;
[0022] The target service is specifically used to respond to the service call request and return the response result to the target gateway;
[0023] The target gateway is also used to return the response result to the load balancing service;
[0024] The load balancing service is also used to return the response results to the middleware service.
[0025] On this basis, optionally, the above service detection system further includes an aggregation gateway;
[0026] The target gateway is used to forward the service call request to the aggregation gateway;
[0027] The aggregation gateway is used to forward the service call request to the target service called in at least one service detection service;
[0028] The target service is specifically used to respond to the service call request and return the response result to the aggregation gateway;
[0029] The aggregation gateway is also used to return the response results to the target service.
[0030] Optionally, an application program interface gateway is specifically used to receive a service call request sent by a middleware service, and forward the service call request to a target service called in at least one service detection service when a token corresponding to the service call request is within a pre-configured token time limit.
[0031] On this basis, an optional application interface gateway is specifically used to receive a service call request sent by a middleware service, and when the difference between the token application time and the service request time is within a pre-configured token time limit, the service call request is forwarded to the called target service in at least one service detection service, wherein the token application time is determined based on the token information used to describe the token obtained from the service call request, and is used to indicate the time for requesting to apply for the token; the service request time is used to indicate the time for requesting to call the target service.
[0032] On this basis, optionally, the application interface gateway is also used to receive a token application request sent by the middleware service, and return the token information corresponding to the token application request to the middleware service, so that the middleware service generates a service call request based on the token information.
[0033] Alternatively, the application program interface gateway is also used to generate an error message when the token is not within the token time limit, and return the error message to the middleware service.
[0034] The service detection system provided by the embodiment of the present invention includes an application interface gateway and at least one service detection service, wherein the at least one service detection service includes at least one of a detection data upload service, a detection data query service, a detection index query service, and a detection index update service; wherein the application interface gateway is used to receive a service call request sent by a middleware service, and forward the service call request to a target service called in at least one service detection service; the target service is used to respond to the service call request, and return the obtained response result to the application interface gateway; the application interface gateway is also used to return the response result to the middleware service. The above technical scheme, by setting an application interface gateway and a unified service detection service, enables the middleware service to call the corresponding service detection service by accessing the application interface gateway, thereby actively uploading its own detection data to the service detection system (i.e., the service detection system passively receives the detection data), and it does not need to deploy any content on the middleware service, thereby ensuring the security of the middleware service and realizing the decoupling between the middleware service and the service detection system.
[0035] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0037] Figure 1 is a framework diagram of a service detection system provided according to an embodiment of the present invention;
[0038] Figure 2 is a framework diagram of another service detection system provided according to an embodiment of the present invention;
[0039] Figure 3 is an architectural diagram of an optional example of another service detection system provided in an embodiment of the present invention;
[0040] Figure 4 is a signaling diagram of an optional example in another service detection system provided in an embodiment of the present invention;
[0041] Figure 5 It is a flowchart of an optional example of another service detection system provided according to an embodiment of the present invention. DETAILED DESCRIPTION
[0042] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0043] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. The situations of "target", "original", etc. are similar and will not be repeated here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0044] Before introducing the embodiments of the present invention, the shortcomings of the prior art described in the background technology are further explained. First, when the server of the Agent probe authorizes the client, usually once the authorization is permanently valid, it can only be terminated by canceling the authorization, which is very inflexible and has poor adaptability. Second, large companies often involve multiple availability zones and multiple data centers in the same Region. When different availability zones and / or different data centers need to collect different detection data, the Agent probe can only perform one adaptation, and greatly increases the communication cost of multiple parties. Third, the detection indicators and content that can be collected are all constrained by the Agent probe provided by the unified service detection system. When different project groups have new detection indicators and non-indicator item requirements for Redis services, R&D personnel are required to develop the Agent probe twice or even multiple times. Fourth, when the server is hacked, each Redis service node can be accessed through the Agent probe, which will damage and use each Redis service node, with serious consequences. Fifth, when Redis services are deployed in multiple availability zones and multiple data centers, when different Redis services run in multiple network environments, a large number of repeated and complex configurations need to be opened on the firewall to enable the service detection system to communicate with the network where the Agent probes deployed on each Redis service are located. This not only makes the settings repeated and complex, but also increases the risk. Sixth, there are multiple services inside Redis, many of which are used to run data. Since these services themselves will not be called by other services, it is impossible to provide port detection for the Agent probe, and thus the detection data of these services cannot be obtained. Seventh, the Agent probe deployed on the Redis service can only be used to detect the detection data of the Redis service, and does not support reuse for other PaaS services, and the scalability is not good. Eighth, when the Agent probe scans too many detection indicators, it is easy to cause problems such as queuing or abnormal waiting, which will affect the real-time nature of the detection data. It can be seen that the technical solution of deploying Agent probes on Redis services to detect Redis services has many problems.
[0045] In order to solve the above problems, the inventor proposed the following technical solution: develop a unified service detection service for the service detection system, where the service detection service can provide services to the outside world in the form of an application programming interface (API); then, the Redis service actively accesses these service detection services by calling the application programming interface gateway, thereby uploading its own detection data to the service detection system. By comparing with the existing solutions, it can be seen that the service detection system has changed its acquisition method of detection data from active collection to passive reception. This will be elaborated in detail below.
[0046] Figure 1 is a structural block diagram of a service detection system provided in an embodiment of the present invention. This embodiment is applicable to the case where the middleware service actively reports its own detection data so that the service detection system can detect itself. Figure 1 The service detection system described in the embodiment of the present invention may include: an application interface gateway 10 and at least one service detection service 11, wherein the at least one service detection service 11 includes at least one of a detection data upload service, a detection data query service, a detection index query service, and a detection index update service; wherein the application interface gateway 10 is used to receive a service call request sent by a middleware service, and forward the service call request to a target service called in at least one service detection service 11; the target service is used to respond to the service call request, and return the obtained response result to the application interface gateway 10; the application interface gateway 10 is also used to return the response result to the middleware service. Specifically,
[0047] The Application Programming Interface (API) gateway 10 can be understood as the main entrance of the service detection system, which is used to carry all API services. In practical applications, the API gateway 10 can be a single-node gateway, which provides a unified API gateway for different clients; it can be a backend for frontends (BFF) gateway, which provides different API gateways for different clients, such as developing corresponding API gateways for Web applications, mobile applications, and public programs, so as to receive service call requests from corresponding sources; it can also be an API gateway implemented based on OpenResty; etc., which are not specifically limited here.
[0048] At least one service detection service 11 can be a pre-developed service that can be used to detect any middleware service, so it is unified relative to each middleware service. It should be noted that the advantage of setting a unified service detection service here is that it is convenient for horizontal expansion and can be applied to each middleware service. These middleware services can all upload detection data based on the unified service detection service, so there is no need to deploy corresponding Agent probes on each middleware service, thereby reducing the development workload on the service detection system side. In an embodiment of the present invention, at least one service detection service 11 may include at least one of a detection data upload service, a detection data query service, a detection index query service, and a detection index update service, wherein the detection data upload service can allow the middleware service to upload its own detection data; the detection data query service can allow the middleware service or other services to query the uploaded detection data; the detection index query service can allow the middleware service to query the detection index added on the service detection system side; the detection index update service can allow the middleware service to add new detection indicators and / or delete existing detection indicators, etc., thereby realizing the update function of the detection index.
[0049] Next, the data flow process between the API gateway 10 and at least one service detection service 11 is described in detail. The API gateway 10 can receive a service call request sent by a middleware service, which can also be called a Platform-as-a-Service (PaaS) service. Specifically, it can be a Redis service, a MySQL service, or an Elasticsearch service, etc., which is not specifically limited here; the service call request can be understood as a request for calling a service detection service in at least one service detection service 11, where the service detection service called in at least one service detection service 11 is referred to as a target service. Furthermore, the API gateway 10 determines the target service based on the service call request, and then forwards the service call request to the target service. Then, the target service responds to the received service call request and returns the obtained response result to the API gateway 10, so that the API gateway 10 returns the received response result to the middleware service, thereby completing a detection process of the middleware service.
[0050] On this basis, optionally, the API gateway 10 is specifically used to receive a service call request sent by any middleware service of at least two middleware services, and forward the service call request to the target service called in at least one service detection service 11; the API gateway 10 is also specifically used to determine the request service that sends the service call request in at least two middleware services, and return the response result to the request service. In other words, the number of middleware services connected to the service detection system can be two or more, and the API gateway 10 can receive a service call request sent by any middleware service of these middleware services. Then, after receiving the response result returned by the target service, the API gateway 10 can return the response result to the request service that sends the above-mentioned service call request in these middleware services, thereby completing a detection process of the request service, ensuring the correspondence and accuracy of the service detection. In actual applications, optionally, the types of at least two middleware services can include at least one of Redis service, MySQL service and Elasticsearch service, and the number of middleware services under any type in at least two middleware services is at least one. In other words, the types of these middleware services may be the same or different, and the number of middleware services of the same type may be one or more, which are not specifically limited herein.
[0051] The above technical solution, by providing a unified service detection service, can flexibly obtain the detection data of different middleware services, thereby meeting the diversified needs of the project team; moreover, it is conducive to the service detection system to horizontally manage new middleware services, which can be achieved by simply modifying the fields in the service detection service, and the service modification cost is much lower than the development cost of a new Agent probe; furthermore, it greatly improves the security of detection data collection, and can prevent the situation where the server is compromised and the Agent probe is used to attack and invade all middleware services. In addition, when Redis services are deployed in multiple availability zones and multiple data centers, by setting up an API gateway, it is sufficient for each middleware service to access the API gateway, without opening a large number of repeated and complex configurations on the firewall. In addition, by publishing the configuration information of the event to the formal environment, the joint debugging and communication costs of the middleware service and the service detection system can be greatly shortened.
[0052] The service detection system provided by the embodiment of the present invention includes an application interface gateway and at least one service detection service, wherein the at least one service detection service includes at least one of a detection data upload service, a detection data query service, a detection index query service, and a detection index update service; wherein the application interface gateway is used to receive a service call request sent by a middleware service, and forward the service call request to a target service called in at least one service detection service; the target service is used to respond to the service call request, and return the obtained response result to the application interface gateway; the application interface gateway is also used to return the response result to the middleware service. The above technical scheme, by setting an application interface gateway and a unified service detection service, enables the middleware service to call the corresponding service detection service by accessing the application interface gateway, thereby actively uploading its own detection data to the service detection system (i.e., the service detection system passively receives the detection data), and it does not need to deploy any content on the middleware service, thereby ensuring the security of the middleware service and realizing the decoupling between the middleware service and the service detection system.
[0053] On this basis, an optional technical solution is that when the target service is a detection data upload service, the target service is specifically used to upload the detection data to be uploaded corresponding to the service call request to the database, and return the obtained data upload result to the application interface gateway. Exemplarily, the detection data upload service can also be called the basic indicator attribute interface, which can contain 7 main fields, 3 of which are public parameter fields, namely: the version of the Redis service, the region where the Redis service is deployed, and the action of calling this interface; the other 4 fields represent the fields of the detection data to be uploaded, namely: business namespace (Namespace), indicator name (MetricName), indicator detection data list (MetricSet) and optional parameters (Dimensions.N). Through this interface, the Redis service can upload the detection data written in the local log according to the standard field format (JSON) negotiated in advance with the service detection system, which can effectively decouple the dependency between the Redis service and the service detection system, greatly shortening the joint debugging and communication costs of both parties. Among them, basic indicator attributes can include operating system level, such as CPU, memory, network IO and disk IO indicators, etc.; collection indicators such as Redis server running process information, which includes the collection of distributed cache running process information, such as server running information, number of client connections, memory consumption, persistence information, number of key values, master-slave synchronization, command statistics and cluster information, etc.; and collection of running logs, which includes recording some important operation processes in the log, such as running persistence, which can effectively help analyze crashed programs. The return field of this interface can include the request ID (RequestID) of the service call request and the information verification result.
[0054] Another optional technical solution is that when the target service is a detection data query service, the target service is specifically used to query the database based on the detection data to be queried corresponding to the service call request, and return the obtained data query results to the application interface gateway. Exemplarily, the detection data query service can also be called a conditional query detection data interface. This interface can still have the above-mentioned three common parameter fields, and the remaining fields include a namespace, a list of indicator items, a list of instance object dimension combinations (including detection data), a detection statistical period, a start time, and an end time; a total of 6 fields are returned, namely, a statistical period, an indicator name, an array of data points, a start time, an end time, a query result, and a RequestID.
[0055] Another optional technical solution, when the target service is a detection indicator query service, the target service is specifically used to query the indicator library based on the detection indicator to be queried corresponding to the service call request, and return the obtained indicator query result to the application interface gateway. Exemplarily, the detection indicator query service can also be called an acquisition detection indicator interface. This interface is intended to provide a Redis service with a query for detection indicators that have been added to the service detection system, which can be double-checked with the detection indicators corresponding to the detection data uploaded by the Redis service. The public parameter fields of this interface are still the above 3, and the remaining fields may include namespace, start time, end time and custom dimension (Groupby); the return field includes the detection indicator statistical period, start time, end time, detection indicator item list and RequestID.
[0056] Another optional technical solution, when the target service is a detection indicator update service, the target service is specifically used to update the indicator library based on the detection indicator to be updated corresponding to the service call request, and return the obtained indicator update result to the application interface gateway. Exemplarily, the detection indicator update service can also be called the update detection indicator interface. The public parameter fields of this interface are still the above 3, and the remaining fields are the namespace, detection indicator statistical period, detection indicator item list, start time, end time and custom dimension; the return field contains RequestID and information verification results. The above technical solution can support the configuration of custom indicator and non-indicator detection items for project teams using middleware services, thereby reducing the joint debugging and communication costs of both the middleware service and the service detection system, so as to quickly respond to the needs of increasing or decreasing detection indicators proposed by the middleware service.
[0057] Figure 2 It is a structural block diagram of another service detection system provided in an embodiment of the present invention. This embodiment is optimized based on the above-mentioned technical solutions. In this embodiment, optionally, the above-mentioned service detection system also includes a load balancing service, and the number of application interface gateways is at least two; wherein the load balancing service is used to receive the service call request sent by the middleware service, and forward the service call request to the target gateway that is load balanced in at least two application interface gateways; the target gateway is specifically used to forward the service call request to the target service called in at least one service detection service; the target service is specifically used to respond to the service call request and return the obtained response result to the target gateway; the target gateway is also specifically used to return the response result to the load balancing service; the load balancing service is also used to return the response result to the middleware service. Among them, the explanations of the terms that are the same or corresponding to the above-mentioned embodiments are not repeated here.
[0058] For details, see Figure 2The service detection system described in the embodiment of the present invention may include: at least two application interface gateways 20, at least one service detection service 22 and a load balancing service 21, wherein at least one service detection service 22 includes at least one of a detection data upload service, a detection data query service, a detection index query service and a detection index update service; wherein the load balancing service 21 is used to receive a service call request sent by a middleware service, and forward the service call request to a target gateway that is load balanced in at least two application interface gateways 20; the target gateway is used to forward the service call request to a target service that is called in at least one service detection service 22; the target service is used to respond to the service call request and return the obtained response result to the target gateway; the target gateway is also used to return the response result to the load balancing service 21; the load balancing service 21 is also used to return the response result to the middleware service. Specifically,
[0059] There are at least two API gateways 20, and a load balancing service 21 is used to receive service call requests sent by the middleware service, and load balance the service call requests to at least two API gateways 20. Here, the API gateway that is load balanced (i.e., used to receive service call requests) among the at least two API gateways 20 is called a target gateway, so that the target gateway forwards the received service call request to the corresponding target service, and returns the response result returned by the target service to the load balancing service 21. In this way, the load balancing service 21 can return the received response result to the middleware service, thereby completing a detection process of the middleware service.
[0060] The technical solution of the embodiment of the present invention, by setting up a load balancing service and at least two API gateways, can balance the load of multiple service call requests to the at least two API gateways, and then quickly dispatch these service call requests to the corresponding service detection services, that is, by means of service call requests with high concurrency of effective load, the real-time nature of service detection is guaranteed.
[0061] An optional technical solution, the service detection system further includes an aggregation gateway; wherein the target gateway is specifically used to forward the service call request to the aggregation gateway; the aggregation gateway is used to forward the service call request to the target service called in at least one service detection service; the target service is specifically used to respond to the service call request and return the response result to the aggregation gateway; the aggregation gateway is also used to return the response result to the target service. The above technical solution, by setting up an aggregation gateway, facilitates data statistics, aggregation calculations and horizontal comparisons of index and non-index detections within the middleware service.
[0062] In order to better understand the service detection system described in the embodiment of the present invention as a whole, the following is an exemplary description of it in combination with specific examples. Figure 3 Here, taking the middleware service as Redis service as an example, the service call requests from each data center are sent to the load balancing service. In actual applications, the load balancing service can be optionally implemented based on the Domain Name System (DNS). DNS processes the received service call request and load balances the processed service call request (here referred to as the service call request) to the API gateway cluster based on OpenResty, thereby supporting high-concurrency and high-access API gateways to do the first layer of traffic protection, and perform identity authentication, security, detection, logging and flow control strategies at this layer, thereby improving the speed of API service authentication, authorization and protocol conversion under the microservice architecture, and improving service access efficiency. Then, the API gateway loads the service call request to different aggregation gateways to perform aggregation service operations here, and at the same time, timeout, cache, fuse, retry and query aggregation strategies can be applied, thereby playing the role of a double-layer gateway. Then, the part from the aggregation gateway to the service detection service of the backend belongs to internal transmission, and internal communication can be more friendly through the Remote Procedure Call Protocol (RPC), thereby improving communication performance. The above technical solution adopts the API gateway method, which greatly improves the strategies of authority authentication, security, reliability and load distribution in the microservice scenario. It is not only conducive to the subsequent service detection system to manage new Redis services, but also supports the shielding of illegal service call requests, and can effectively load high-concurrency service call requests.
[0063] In practical applications, the above API gateway may optionally include the following modules:
[0064] A detection module, used to detect the service detection service;
[0065] Log module, used to log the API gateway;
[0066] The flow control module is used to control the flow of service call requests sent by the Redis service, that is, to limit the flow;
[0067] The interface control module is used to control the interface version of the connected service detection service, so as to forward the service call request to the service detection service of the corresponding interface version;
[0068] The rewriting module is used to rewrite the route of the service call request and route the service call request according to the rewritten route.
[0069] The embodiments of the present invention are optimized based on the above technical solutions. In this embodiment, optionally, the application program interface gateway is specifically used to receive a service call request sent by a middleware service, and when the token corresponding to the service call request is within a pre-configured token time limit, forward the service call request to the target service called in at least one service detection service. The explanations of the terms that are the same or corresponding to the above embodiments are not repeated here.
[0070] Specifically, the service detection system described in the embodiment of the present invention may include: an application interface gateway and at least one service detection service, the at least one service detection service including at least one of a detection data upload service, a detection data query service, a detection index query service and a detection index update service; wherein the application interface gateway is used to receive a service call request sent by a middleware service, and when the token corresponding to the service call request is within a pre-configured token time limit, forward the service call request to the target service called in at least one service detection service; the target service is used to respond to the service call request and return the obtained response result to the application interface gateway; the application interface gateway is also used to return the response result to the middleware service. In other words, the API gateway only forwards the service call request where the token is within the token time limit to the corresponding target service, thereby ensuring the security of the target service. In actual applications, optionally, the token time limit can be a time limit preset for the target service, or a time limit preset for all service detection services, which is not specifically limited here. Optionally, the API gateway can also be used to generate an error message when the token is not within the token time limit, and return the error message to the middleware service so that the middleware service re-requests the token.
[0071] The technical solution of the embodiment of the present invention can allow the service detection service to limit the authorization period by setting a token for the service call request. It has the advantages of being more flexible and adaptable, while improving security to facilitate data isolation and provide personalized interface services.
[0072] An optional technical solution, an application program interface gateway, is specifically used to receive a service call request sent by a middleware service, and forward the service call request to the target service called in at least one service detection service when the difference between the token application time and the service request time is within the pre-configured token time limit; wherein the token application time is determined based on the token information used to describe the token obtained from the service call request, and is used to indicate the time when the token application is requested; the service request time is used to indicate the time when the target service is requested to be called. In other words, tokens requested within the token time limit before the service request time are valid. For example, if the service request time is 16:07:35 and the token time limit is 60 seconds, then tokens requested after 16:06:35 on the same day are all valid. The above technical solution can accurately determine whether the token is within the validity period.
[0073] On this basis, optionally, the application interface gateway is also used to receive a token application request sent by the middleware service, and return the token information corresponding to the token application request to the middleware service, so that the middleware service can generate a service call request based on the token information, that is, the service call request can be generated based on the token information, specifically, it can be generated based on the token information and the service identifier of the target service.
[0074] In order to better understand the above technical solution, the following is an exemplary description of it in combination with specific examples. Figure 4 , the token application request sent by the Redis service may carry the client identifier (Client_id) and client secret (Client_secret) used to represent identity information. On this basis, the API gateway can also obtain the IP address of the Redis service side, and determine the corresponding token information based on the identity information. The token information may include the authorization token (access_token), token type (token_type), token time limit (expires_in), and the request key name (request_head) of the token application request. Then, the Redis service can generate the corresponding request header based on the received token information, and generate a service call request based on this request header. Then, the API gateway verifies whether the token corresponding to the service call request is within the token time limit, and if so, forwards the service call request to the target service; if not, an error message indicating that the token has expired is returned to the Redis service, so that the Redis service can request the token again, thereby ensuring the effective and secure call of the target service.
[0075] In order to better understand the data flow process of the service detection system described in the above technical solutions as a whole, the following is an exemplary description of it with reference to specific examples. Figure 5 :
[0076] The Redis service initiates a service call request to the service detection service. Specifically, it can be a post request to the basic indicator attribute service, a get request to the conditional query detection data service, a get request to the acquisition detection indicator service, or a post request to the update detection indicator service, and sends the service call request to the load balancing service.
[0077] The load balancing service receives service call requests from different data centers and forwards them to the API gateway.
[0078] The API gateway verifies the timeliness, identity, and authority of the service call request, and determines whether it is within the token time limit. If it is not within the token time limit, the corresponding error information is returned to the load balancing service, so that the load balancing service records the error information and returns it to the Redis service. If it is within the token time limit, verify the rationality of security, current limiting, logging, and detection, and if it is unreasonable, return the error information to the load balancing service, so that the load balancing service records the error information and returns it to the Redis service; if it is reasonable, verify the timeout, cache, fuse, and retry strategies to determine whether it meets the request service conditions. If it meets the conditions, the corresponding service detection service performs data verification and operates the database; if it does not meet the conditions, record redundant records, and return the error information to the API gateway, so that the error information is returned to the load balancing service through the API gateway, so that the load balancing service records the error information and returns it to the Redis service. Of course, the operation results of the service detection service can also be returned to the Redis service based on the link of the aggregation gateway, API gateway, and load balancing service.
[0079] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A service detection system, characterized in that: include: An application program interface gateway and at least one service detection service, wherein the at least one service detection service includes at least one of a detection data upload service, a detection data query service, a detection index query service, and a detection index update service; wherein, The application program interface gateway is used to receive a service call request sent by the middleware service, and forward the service call request to the target service called in the at least one service detection service; The target service is used to respond to the service call request and return the obtained response result to the application interface gateway; The application program interface gateway is further used to return the response result to the middleware service; The application program interface gateway is specifically used for: Receive a service call request sent by a middleware service, and forward the service call request to a target service called in the at least one service detection service if a token corresponding to the service call request is within a pre-configured token time limit; wherein the token time limit includes a time limit pre-set for the target service or a time limit pre-set for all service detection services; If the token is not within the token time limit, an error message is generated, and the error message is returned to the middleware service so that the middleware service requests a token again; The system also includes a load balancing service, and the number of the application interface gateways is at least two; wherein, The load balancing service is used to receive a service call request sent by the middleware service, and forward the service call request to a load balanced target gateway among the at least two application program interface gateways; The target gateway is specifically used to forward the service call request to the target service called in the at least one service detection service; The target service is specifically used to respond to the service call request and return the obtained response result to the target gateway; The target gateway is further specifically used to return the response result to the load balancing service; The load balancing service is further used to return the response result to the middleware service; The system also includes an aggregation gateway; The target gateway is specifically used to forward the service call request to the aggregation gateway; The aggregation gateway is used to forward the service call request to the target service called in the at least one service detection service; The target service is specifically used to respond to the service call request and return the obtained response result to the aggregation gateway; The aggregation gateway is further configured to return the response result to the target service.
2. The system according to claim 1, characterized in that: In the case where the target service is the detection data upload service, the target service is specifically used to upload the detection data to be uploaded corresponding to the service call request to the database, and return the obtained data upload result to the application interface gateway; and / or, In the case where the target service is the detection data query service, the target service is specifically used to query the database based on the detection data to be queried corresponding to the service call request, and return the obtained data query result to the application interface gateway; and / or, In the case where the target service is the detection index query service, the target service is specifically used to query the index library based on the detection index to be queried corresponding to the service call request, and return the obtained index query result to the application interface gateway; and / or, In the case where the target service is the detection indicator update service, the target service is specifically used to update the indicator library based on the detection indicator to be updated corresponding to the service call request, and return the obtained indicator update result to the application interface gateway.
3. The system according to claim 1, characterized in that: The application program interface gateway is specifically used to receive a service call request sent by any middleware service of at least two middleware services, and forward the service call request to the target service called in the at least one service detection service; The application program interface gateway is further specifically used to determine the request service that sends the service call request among the at least two middleware services, and return the response result to the request service.
4. The system according to claim 3, characterized in that The types of the at least two middleware services include at least one of a Redis service, a MySQL service, and an Elasticsearch service, and the number of middleware services in any type among the at least two middleware services is at least one.
5. The system according to claim 1, characterized in that: The application program interface gateway is specifically used to receive a service call request sent by the middleware service, and forward the service call request to the target service called in the at least one service detection service when the difference between the token application time and the service request time is within the pre-configured token time limit; Among them, the token application time is determined according to the token information used to describe the token obtained from the service call request, and is used to indicate the time for requesting to apply for the token; the service request time is used to indicate the time for requesting to call the target service.
6. The system according to claim 5, characterized in that: The application program interface gateway is also used to receive a token application request sent by the middleware service, and return the token information corresponding to the token application request to the middleware service, so that the middleware service generates the service call request according to the token information.
