Substation monitoring system API gateway cluster implementation method and system
By introducing gateway main service and management service into the substation monitoring system, and calculating reliability score based on interface call indicators, the problems of multi-protocol conversion and high availability of API gateways are solved, and stable and efficient communication of the substation monitoring system is achieved.
Patent Information
- Application Number
- CN202510798493.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-16
- Publication Date
- 2025-11-14
AI Technical Summary
Existing API gateways in substation monitoring systems suffer from inconsistent protocol conversion, inconsistent traffic scheduling, and insufficient high availability. In particular, they cannot achieve multi-protocol conversion when making cross-language calls, and cannot dynamically switch to other available nodes when a gateway node crashes abnormally.
The gateway master service provides an HTTP/Thrift protocol interface, communicates with business services via RPC protocol, and the gateway management service calculates the reliability score based on the interface call indicators within the sliding window time. The gateway routing service provides the current optimal gateway master service node to achieve unified traffic scheduling and high availability.
It achieves unified conversion of multiple protocols between microservices, ensures high availability of the API gateway cluster and dynamic traffic scheduling, and ensures stable system operation.
Smart Images

Figure CN120956804A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of digital information technology for substation monitoring systems, and in particular to a method and system for implementing an API gateway cluster for a substation monitoring system. Background Technology
[0002] Substation monitoring systems are a core component of smart grid construction, aiming to achieve comprehensive monitoring and management of substation equipment, environment, and operational status through technologies such as full coverage, real-time sensing, and intelligent analysis. A substation monitoring system based on a microservice architecture is constructed from multiple service units that communicate using various protocols such as HTTP / Thrift and RPC (Remote Procedure Call). These services cooperate and collaborate to achieve the final value. To enhance collaboration among services, an API gateway serves as the unified entry point for the monitoring system. External systems or clients do not need to know the specific protocols used by the internal microservices; they only need to interact with the API gateway, greatly simplifying the communication process and reducing system complexity. As the system's first line of defense, the API gateway performs strict authentication and authorization checks on all requests entering the system, preventing unauthorized access and malicious attacks. By filtering and limiting requests, the API gateway ensures stable system operation even under high concurrency, preventing system crashes caused by a surge of requests. Furthermore, the API gateway provides unified monitoring and management functions. By recording and analyzing all requests, administrators can understand the system's operational status in real time and promptly identify and resolve potential problems.
[0003] The existing API gateway has the following problems:
[0004] 1. Protocol Conversion: The substation monitoring system contains microservices developed in multiple languages. Cross-language calls involve multiple protocol conversions, such as the conversion between HTTP / Thrift protocol and RPC protocol. The existing API gateway cannot achieve unified adaptation and conversion of the above protocols.
[0005] 2. Unified traffic scheduling: The existing API gateway communicates with the client in a point-to-point manner, which makes it impossible to achieve unified traffic scheduling for the gateway cluster;
[0006] 3. High availability: When the gateway node to which the client is connected crashes abnormally, the client cannot dynamically obtain other available nodes in the gateway cluster, and the API gateway cannot be guaranteed to have high availability.
[0007] Therefore, a new API gateway cluster implementation method and system are needed to solve the above problems. Summary of the Invention
[0008] Purpose of the invention: This invention aims to provide a method and system for implementing an API gateway cluster in a substation monitoring system, solving the problems of cross-language multi-protocol conversion between microservices in the current substation monitoring system, unified traffic scheduling of the API gateway cluster, and high availability of the gateway.
[0009] Technical solution: This invention provides a method for implementing an API gateway cluster in a substation monitoring system, including:
[0010] The gateway main service provides an interface for client programs to call using the HTTP / Thrift protocol, and converts the request protocol to communicate with various business services of the substation monitoring system through the RPC protocol;
[0011] The gateway management service calculates the reliability score of the main gateway service based on three indicators: average interface call time, total number of interface calls, and number of client connections, which are statistically analyzed within the sliding window period.
[0012] The gateway routing service sorts the reliability scores calculated by the gateway management service and provides an HTTP / Thrift protocol interface for clients to call, and provides the client with the optimal gateway master service node address at the current moment; the client establishes a connection / connection pool with the gateway master service through the optimal gateway service node address.
[0013] Furthermore, the HTTP / Thrift protocol to RPC protocol conversion service provided by the gateway main service includes:
[0014] The client obtains the gateway main service address through the gateway routing service and establishes a connection / connection pool with the gateway main service through this address;
[0015] The client initiates an HTTP / Thrift request to the gateway's main service through the established connection / connection pool;
[0016] After receiving a client request, the gateway main service, acting as an HTTP / Thrift Server, communicates with various business services of the substation monitoring system via the RPC protocol. After receiving the response from the business service, it returns the result to the client via the HTTP / Thrift protocol.
[0017] Furthermore, the reliability score calculation method provided by the gateway management service includes:
[0018] The gateway main service reports the IP address of the interface caller, the interface address, the call time, and the interface call result to the Redis cache queue;
[0019] The gateway management service consumes the aforementioned monitoring information from the Redis cache queue and stores it in the time-series database;
[0020] The gateway management service queries the time-series database to obtain basic indicator data for all gateway main services, including the average interface call time, total number of interface calls, and number of client connections within the last t seconds.
[0021] The average call time of each node of the gateway main service within the last t seconds is: T avg (i)
[0022] The total number of interface calls made by each node of the gateway main service within the last t seconds is quantified as follows: S sum (i)
[0023] The number of client connections per node of the gateway main service within the most recent t seconds is: C sum (i)
[0024] Where i represents the i-th node of the gateway's main service.
[0025] The gateway management service calculates the scores of various indicators of the main gateway service based on the basic indicator data, and calculates the reliability score of the main gateway service according to the set weights.
[0026] The average call time score of each node of the gateway main service within the most recent t seconds is as follows:
[0027]
[0028] Where i represents the i-th node of the gateway main service, and n is the number of gateway main service nodes;
[0029] In particular, when When the value is 0, the average call time of each node of the gateway main service within the most recent t seconds is set to 1.
[0030] The score for the total number of interface calls made by each node of the gateway main service within the last t seconds is as follows:
[0031]
[0032] Where i represents the i-th node of the gateway main service, and n is the number of gateway main service nodes;
[0033] In particular, when When the value is 0, the score of the indicator of the total number of interface calls of each node of the gateway main service in the most recent t seconds is set to 1;
[0034] The scores for the number of client connections within the most recent t seconds for each node of the gateway main service are as follows:
[0035]
[0036] Where i represents the i-th node of the gateway main service, and n is the number of gateway main service nodes;
[0037] In particular, when When the value is 0, the score of the client connection count metric for each node of the gateway main service within the most recent t seconds is set to 1;
[0038] The reliability score F of the gateway main service score (i) The calculation is as follows:
[0039] F score (i)=(α*F t (i)+β*F s (i)+γ*F c (i))*100%
[0040] Where α represents the weight of the average call time score, β represents the weight of the total number of call scores, and γ represents the weight of the client connection score, where α+β+γ=1;
[0041] The gateway management service updates the reliability score information to the Redis cache;
[0042] The gateway management service periodically calculates the reliability score of all gateway nodes using the above method and updates it to the Redis cache;
[0043] When the API gateway master node to which the client is connected experiences an abnormal downtime, the client obtains a new available gateway master service node through the gateway routing service and re-establishes the connection / connection pool.
[0044] This invention also provides a substation monitoring system API gateway cluster system, comprising:
[0045] The gateway main service component provides an interface for client programs to call using the HTTP / Thrift protocol, and converts the request protocol to communicate with various business services of the substation monitoring system via the RPC protocol;
[0046] The gateway management service component calculates the reliability score of the main gateway service based on three metrics: average interface call time, total number of interface calls, and number of client connections, which are statistically analyzed within a sliding window period.
[0047] The gateway routing service component sorts the reliability scores calculated by the gateway management service and provides an HTTP / Thrift protocol interface for clients to call. It also provides clients with the optimal gateway master service node address at the current moment. Clients establish connections / connection pools with the gateway master service through the optimal gateway service node address.
[0048] Furthermore, the gateway main service provides HTTP / Thrift protocol to RPC protocol conversion services, including:
[0049] The client obtains the gateway main service address through the gateway routing service and establishes a connection / connection pool with the gateway main service through this address;
[0050] The client initiates an HTTP / Thrift request to the gateway's main service through the established connection / connection pool;
[0051] After receiving a client request, the gateway main service, acting as an HTTP / Thrift Server, communicates with various business services of the substation monitoring system via the RPC protocol. After receiving the response from the business service, it returns the result to the client via the HTTP / Thrift protocol.
[0052] Furthermore, the reliability score calculation method provided by the gateway management service component includes:
[0053] The gateway main service reports the IP address of the interface caller, the interface address, the call time, and the interface call result to the Redis cache queue;
[0054] The gateway management service consumes the aforementioned monitoring information from the Redis cache queue and stores it in the time-series database;
[0055] The gateway management service queries the time-series database to obtain basic indicator data for all gateway main services, including the average interface call time, total number of interface calls, and number of client connections within the last t seconds.
[0056] The average call time of each node of the gateway main service within the last t seconds is: T avg (i)
[0057] The total number of interface calls made by each node of the gateway main service within the last t seconds is quantified as follows: S sum (i)
[0058] The number of client connections per node of the gateway main service within the most recent t seconds is: C sum (i)
[0059] Where i represents the i-th node of the gateway's main service.
[0060] The gateway management service calculates the scores of various indicators of the main gateway service based on the basic indicator data, and calculates the reliability score of the main gateway service according to the set weights.
[0061] The average call time score of each node of the gateway main service within the most recent t seconds is as follows:
[0062]
[0063] Where i represents the i-th node of the gateway main service, and n is the number of gateway main service nodes;
[0064] In particular, when When the value is 0, the average call time of each node of the gateway main service within the most recent t seconds is set to 1.
[0065] The score for the total number of interface calls made by each node of the gateway main service within the last t seconds is as follows:
[0066]
[0067] Where i represents the i-th node of the gateway main service, and n is the number of gateway main service nodes;
[0068] In particular, when When the value is 0, the score of the indicator of the total number of interface calls of each node of the gateway main service in the most recent t seconds is set to 1;
[0069] The scores for the number of client connections within the most recent t seconds for each node of the gateway main service are as follows:
[0070]
[0071] Where i represents the i-th node of the gateway main service, and n is the number of gateway main service nodes;
[0072] In particular, when When the value is 0, the score of the client connection count metric for each node of the gateway main service within the most recent t seconds is set to 1;
[0073] The reliability score F of the gateway main service score (i) The calculation is as follows:
[0074] F score (i)=(α*F t (i)+β*F s (i)+γ*F c (i))*100%
[0075] Where α represents the weight of the average call time score, β represents the weight of the total number of call scores, and γ represents the weight of the client connection score, where α+β+γ=1;
[0076] The gateway management service updates the reliability score information to the Redis cache;
[0077] The gateway management service periodically calculates the reliability score of all gateway nodes using the above method and updates it to the Redis cache;
[0078] When the API gateway master node to which the client is connected experiences an abnormal downtime, the client obtains a new available gateway master service node through the gateway routing service and re-establishes the connection / connection pool.
[0079] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described method.
[0080] The present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the above-described method.
[0081] Beneficial effects: Compared with the prior art, the significant advantages of this invention are: 1. The API gateway cluster implementation method of the substation monitoring system implemented by this invention can realize unified conversion and adaptation of multi-protocol cross-language calls between microservices; 2. This invention calculates the reliability score of the gateway main service in real time through the gateway management service, and provides the client with the optimal gateway main service node at the current moment through the gateway routing service, thereby realizing unified traffic scheduling of the gateway main service and ensuring its high availability. Attached Figure Description
[0082] Figure 1 This is a schematic diagram of the API gateway cluster architecture and process of the present invention.
[0083] Figure 2 This is a flowchart illustrating the conversion process between the Http / Thrift protocol and the RPC protocol in this invention.
[0084] Figure 3 This is a schematic diagram illustrating the gateway main service reliability score calculation process of the present invention.
[0085] Figure 4 This is a schematic diagram of the API gateway cluster access process of the present invention. Detailed Implementation
[0086] The invention will now be further described with reference to the accompanying drawings.
[0087] See Figure 1 This invention provides a method for implementing an API gateway cluster in a substation monitoring system, the specific steps of which are as follows:
[0088] Step S1: After the API gateway cluster starts up, the gateway master service actively reports heartbeat information to the Redis cache; the gateway management service initializes the reliability score of all nodes of the gateway master service based on the heartbeat information; in the initial state, the reliability score of each gateway master service node is the same.
[0089] In step S2, the client establishes a connection with the gateway routing service via the HTTP / Thrift protocol;
[0090] Step S3: The gateway routing service retrieves the address of the current optimal gateway master service node from the Redis cache and returns it to the client;
[0091] Step S4: The client establishes a connection / connection pool with the gateway master service using the optimal gateway master service node address obtained in the above steps.
[0092] Step S5: The client initiates an HTTP / Thrift call request;
[0093] Step S6: After receiving the client request, the gateway main service forwards it to the corresponding substation monitoring system business service via the RPC protocol.
[0094] Step S7: The substation monitoring system service returns the request result.
[0095] Step S8: The gateway main service performs protocol conversion on the request results returned by the above business services and then returns the results to the client.
[0096] Step S9: The gateway main service reports all request records, including the IP of the interface caller, the interface address, the interface call time, and the interface call result, to the Redis cache.
[0097] Step S10: The gateway management service consumes the request record details data from the Redis cache;
[0098] Step S11: The gateway management service stores the detailed data of consumed request records into the time-series database;
[0099] In step S12, the gateway management service analyzes and calculates the reliability score of each node of the gateway main service, and updates the indicator value to the Redis cache.
[0100] See Figure 2 The substation monitoring system API gateway cluster implementation method provided by this invention includes the following steps in the gateway main service's HTTP / Thrift protocol to RPC protocol conversion process:
[0101] The client initiates a call request to the gateway main service via the HTTP / Thrift protocol. After receiving the request, the gateway main service initiates an RPC request to the monitoring system business service.
[0102] The monitoring system's business service returns the RPC request result to the gateway's main service, and the gateway's main service returns an HTTP / Thrift request to the client.
[0103] See Figure 3 The flowchart for calculating the reliability score of the gateway main service in the API gateway cluster implementation method of the substation monitoring system provided by this invention is as follows:
[0104] The gateway management service queries the time-series database to obtain basic metric data for all gateway main services:
[0105] (1) The average call time of each node of the gateway main service within the most recent t seconds is: T avg (i)
[0106] (2) The total number of interface calls made by each node of the gateway main service within the last t seconds is: S sum (i)
[0107] (3) The number of client connections per node of the gateway main service within the most recent t seconds is: C sum (i)
[0108] Where i represents the i-th node of the gateway's main service.
[0109] The scores for average call time, total number of calls, and number of client connections for the gateway's main service are calculated as follows:
[0110] (1) The average call time score of each node of the gateway main service within the most recent t seconds is:
[0111]
[0112] Where i represents the i-th node of the gateway's main service, and n is the number of gateway's main service nodes.
[0113] In particular, when When the value is 0, the average call time of each node of the gateway main service within the most recent t seconds is set to 1.
[0114] (2) The score for the total number of interface calls made by each node of the gateway main service within the most recent t seconds is:
[0115]
[0116] Where i represents the i-th node of the gateway's main service, and n is the number of gateway's main service nodes.
[0117] In particular, when When the value is 0, the score of the indicator of the total number of interface calls of each node of the gateway main service in the most recent t seconds is set to 1.
[0118] (3) The score for the number of client connections in the most recent t seconds for each node of the gateway main service is:
[0119]
[0120] Where i represents the i-th node of the gateway's main service, and n is the number of gateway's main service nodes.
[0121] In particular, when When the value is 0, the score for the number of client connections in the most recent t seconds for each node of the gateway main service is set to 1.
[0122] The reliability score F of the gateway main service score (i) The calculation is as follows:
[0123] F score (i)=(α*F t (i)+β*F s (i)+γ*F c (i))*100%
[0124] Where α represents the weight of the average call time score, β represents the weight of the total number of call scores, and γ represents the weight of the client connection score, where α+β+γ=1, and α, β, and γ can be adjusted according to the actual situation.
[0125] The gateway management service periodically calculates the reliability score of all gateway nodes using the above method and updates it to the Redis cache, thereby ensuring that the client can always retrieve the optimal gateway master service node in the API gateway cluster, realizing dynamic and unified scheduling of traffic in the substation monitoring system API gateway cluster.
[0126] When the API gateway master node to which the client is connected experiences an abnormal downtime, the client can obtain a new available gateway master service node through the gateway routing service and re-establish the connection / connection pool, thereby ensuring the high availability of the API gateway cluster.
[0127] See Figure 4 The client access process in the substation monitoring system API gateway cluster implementation method provided by this invention includes:
[0128] The client establishes a connection with the gateway routing service via the HTTP / Thrift protocol and obtains the current optimal gateway master service node;
[0129] The client establishes a connection / connection pool with the gateway master service node obtained in the above steps;
[0130] The client initiates a call request to the gateway main service. After receiving the request, the gateway main service performs unified authentication, traffic limiting and load balancing on the request before initiating an RPC request to the monitoring system business service.
[0131] The monitoring system's business service returns the request result to the gateway's main service, which then returns the request to the client.
[0132] See Figure 1The present invention provides a substation monitoring system API gateway cluster system, including: a startup component, a connection component, a node acquisition component, a request component, a forwarding component, a request return component, a reporting component, a consumption component, a storage component, and a computing component.
[0133] The startup component is used to proactively report heartbeat information to the Redis cache after the API gateway cluster starts up. The gateway management service initializes the reliability score of all nodes of the gateway master service based on the heartbeat information. In the initial state, the reliability score of each gateway master service node is the same.
[0134] The connection component is used by the client to establish a connection with the gateway routing service via the HTTP / Thrift protocol;
[0135] The node retrieval component is used by the gateway routing service to retrieve the address of the current optimal gateway master service node from the Redis cache and return it to the client;
[0136] The connection component is used by the client to establish a connection / connection pool with the gateway master service based on the optimal gateway master service node address obtained through the above steps;
[0137] The request component is used by the client to initiate HTTP / Thrift call requests;
[0138] The forwarding component is used by the gateway main service to forward client requests to the corresponding substation monitoring system business service via the RPC protocol.
[0139] The substation monitoring system service returned the request result;
[0140] The request return component is used by the gateway main service to perform protocol conversion on the request results returned by the above business services and then return the results to the client.
[0141] The reporting component is used by the gateway main service to report all request records, including the caller's IP, interface address, interface call time, and interface call result, to the Redis cache;
[0142] The consumer component is used by the gateway management service to consume request record details data from the Redis cache;
[0143] The storage component is used by the gateway management service to store the detailed data of consumed request records into a time-series database;
[0144] The computing component is used by the gateway management service to analyze and calculate the reliability scores of each node of the gateway main service, and update the metric values to the Redis cache.
[0145] See Figure 2The substation monitoring system API gateway cluster provided by this invention implements the conversion between Http / Thrift protocol and RPC protocol in the main gateway service of the system, including: a component for initiating a call request and a component for returning the call result.
[0146] The component that initiates the call request is the client that sends a call request to the gateway main service via the HTTP / Thrift protocol. After receiving the request, the gateway main service sends an RPC request to the monitoring system business service.
[0147] The call result returns the RPC request result to the gateway main service as the monitoring system business service, and the gateway main service returns the HTTP / Thrift request to the client.
[0148] See Figure 3 The logic for calculating the reliability score of the gateway main service in the substation monitoring system API gateway cluster implementation system provided by this invention is as follows:
[0149] The gateway management service queries the time-series database to obtain basic metric data for all gateway main services:
[0150] (1) The average call time of each node of the gateway main service within the most recent t seconds is: T avg (i)
[0151] (2) The total number of interface calls made by each node of the gateway main service within the last t seconds is: S sum (i)
[0152] (3) The number of client connections per node of the gateway main service within the most recent t seconds is: C sum (i)
[0153] Where i represents the i-th node of the gateway's main service.
[0154] The scores for average call time, total number of calls, and number of client connections for the gateway's main service are calculated as follows:
[0155] (1) The average call time score of each node of the gateway main service within the most recent t seconds is:
[0156]
[0157] Where i represents the i-th node of the gateway's main service, and n is the number of gateway's main service nodes.
[0158] In particular, when When the value is 0, the average call time of each node of the gateway main service within the most recent t seconds is set to 1.
[0159] (2) The score for the total number of interface calls made by each node of the gateway main service within the most recent t seconds is:
[0160]
[0161] Where i represents the i-th node of the gateway's main service, and n is the number of gateway's main service nodes.
[0162] In particular, when When the value is 0, the score of the indicator of the total number of interface calls of each node of the gateway main service in the most recent t seconds is set to 1.
[0163] (3) The score for the number of client connections in the most recent t seconds for each node of the gateway main service is:
[0164]
[0165] Where i represents the i-th node of the gateway's main service, and n is the number of gateway's main service nodes.
[0166] In particular, when When the value is 0, the score for the number of client connections in the most recent t seconds for each node of the gateway main service is set to 1.
[0167] The reliability score F of the gateway main service score (i) The calculation is as follows:
[0168] F score (i)=(α*F t (i)+β*F s (i)+γ*F c (i))*100%
[0169] Where α represents the weight of the average call time score, β represents the weight of the total number of call scores, and γ represents the weight of the client connection score, where α+β+γ=1, and α, β, and γ can be adjusted according to the actual situation.
[0170] The gateway management service periodically calculates the reliability score of all gateway nodes using the above method and updates it to the Redis cache, thereby ensuring that the client can always retrieve the optimal gateway master service node in the API gateway cluster, realizing dynamic and unified scheduling of traffic in the substation monitoring system API gateway cluster.
[0171] When the API gateway master node to which the client is connected experiences an abnormal downtime, the client can obtain a new available gateway master service node through the gateway routing service and re-establish the connection / connection pool, thereby ensuring the high availability of the API gateway cluster.
[0172] See Figure 4The client access in the substation monitoring system API gateway cluster system provided by this invention includes: a service acquisition component, a connection component, a call component, and a call return component.
[0173] The service acquisition component is used by the client to establish a connection with the gateway routing service via the HTTP / Thrift protocol and obtain the current optimal gateway master service node.
[0174] The connection component is used by the client to establish a connection / connection pool with the gateway master service node obtained in the above steps;
[0175] The calling component is used by the client to initiate a call request to the gateway main service. After receiving the request, the gateway main service performs unified authentication, traffic limiting and load balancing on the request before initiating an RPC request to the monitoring system business service.
[0176] The calling return component will send the request result from the monitoring system business service to the gateway main service, and the gateway main service will then return the request to the client.
[0177] The computer device of the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above method.
[0178] The computer-readable storage medium of the present invention stores a computer program thereon, which, when executed by a processor, implements the steps of the above-described method.
Claims
1. A method for implementing an API gateway cluster in a substation monitoring system, characterized in that, include: The gateway main service provides an interface for client programs to call using the HTTP / Thrift protocol, and converts the request protocol to communicate with various business services of the substation monitoring system through the RPC protocol; The gateway management service calculates the reliability score of the main gateway service based on three indicators: average interface call time, total number of interface calls, and number of client connections, which are statistically analyzed within the sliding window period. The gateway routing service sorts the reliability scores calculated by the gateway management service and provides a Thrift protocol interface for clients to call, and provides the client with the optimal gateway master service node address at the current moment; the client establishes a connection / connection pool with the gateway master service through the optimal gateway service node address.
2. The method for implementing a substation monitoring system API gateway cluster according to claim 1, characterized in that, The gateway main service provides HTTP / Thrift protocol to RPC protocol conversion services, including: The client obtains the gateway main service address through the gateway routing service and establishes a connection / connection pool with the gateway main service through this address; The client initiates an HTTP / Thrift request to the gateway's main service through the established connection / connection pool; After receiving a client request, the gateway main service, acting as an HTTP / Thrift Server, communicates with various business services of the substation monitoring system via the RPC protocol. After receiving the response from the business service, it returns the result to the client via the HTTP / Thrift protocol.
3. The substation monitoring system API gateway cluster implementation method according to claim 1, characterized in that, The reliability score calculation method provided by the gateway management service includes: The gateway main service reports the IP address of the interface caller, the interface address, the call time, and the interface call result to the Redis cache queue; The gateway management service consumes the aforementioned monitoring information from the Redis cache queue and stores it in the time-series database; The gateway management service queries the time-series database to obtain basic indicator data for all gateway main services, including the average interface call time, total number of interface calls, and number of client connections within the last t seconds. The average call time of each node of the gateway main service within the last t seconds is: T avg (i) The total number of interface calls made by each node of the gateway main service within the last t seconds is quantified as follows: S sum (i) The number of client connections per node of the gateway main service within the most recent t seconds is: C sum (i) Where i represents the i-th node of the gateway's main service; The gateway management service calculates the scores of various indicators of the main gateway service based on the basic indicator data, and calculates the reliability score of the main gateway service according to the set weights. The average call time score of each node of the gateway main service within the most recent t seconds is as follows: Where i represents the i-th node of the gateway main service, and n is the number of gateway main service nodes; In particular, when When the value is 0, the average call time of each node of the gateway main service within the most recent t seconds is set to 1. The score for the total number of interface calls made by each node of the gateway main service within the last t seconds is as follows: Where i represents the i-th node of the gateway main service, and n is the number of gateway main service nodes; In particular, when When the value is 0, the score of the indicator of the total number of interface calls of each node of the gateway main service in the most recent t seconds is set to 1; The scores for the number of client connections within the most recent t seconds for each node of the gateway main service are as follows: Where i represents the i-th node of the gateway main service, and n is the number of gateway main service nodes; In particular, when When the value is 0, the score of the client connection count metric for each node of the gateway main service within the most recent t seconds is set to 1; The reliability score F of the gateway main service score (i) The calculation is as follows: F score (i)=(α*F t (i)+β*F s (i)+γ*F c (i))*100% Where α represents the weight of the average call time score, β represents the weight of the total number of call scores, and γ represents the weight of the client connection score, where α+β+γ=1; The gateway management service updates the reliability score information to the Redis cache; The gateway management service periodically calculates the reliability score of all gateway nodes using the above method and updates it to the Redis cache; When the API gateway master node to which the client is connected experiences an abnormal downtime, the client obtains a new available gateway master service node through the gateway routing service and re-establishes the connection / connection pool.
4. A substation monitoring system API gateway cluster system, characterized in that, include: The gateway main service component provides an interface for client programs to call using the HTTP / Thrift protocol, and converts the request protocol to communicate with various business services of the substation monitoring system via the RPC protocol; The gateway management service component calculates the reliability score of the main gateway service based on three metrics: average interface call time, total number of interface calls, and number of client connections, which are statistically analyzed within a sliding window period. The gateway routing service component sorts the reliability scores calculated by the gateway management service and provides an HTTP / Thrift protocol interface for clients to call. It also provides clients with the optimal gateway master service node address at the current moment. Clients establish connections / connection pools with the gateway master service through the optimal gateway service node address.
5. The substation monitoring system API gateway cluster system according to claim 4, characterized in that, In the gateway main service component, the HTTP / Thrift protocol to RPC protocol conversion service includes: The client obtains the gateway main service address through the gateway routing service and establishes a connection / connection pool with the gateway main service through this address; The client initiates an HTTP / Thrift protocol request to the gateway main service through the established connection / connection pool; After receiving a client request, the gateway main service, acting as an HTTP / Thrift Server, communicates with various business services of the substation monitoring system via the RPC protocol. After receiving the response from the business service, it returns the result to the client via the HTTP / Thrift protocol.
6. The substation monitoring system API gateway cluster system according to claim 4, characterized in that, In the gateway management service component, the reliability score calculation method includes: The gateway main service reports the IP address of the interface caller, the interface address, the call time, and the interface call result to the Redis cache queue; The gateway management service consumes the aforementioned monitoring information from the Redis cache queue and stores it in the time-series database; The gateway management service queries the time-series database to obtain basic indicator data for all gateway main services, including the average interface call time, total number of interface calls, and number of client connections within the last t seconds. The average call time of each node of the gateway main service within the last t seconds is: T avg (i) The total number of interface calls made by each node of the gateway main service within the last t seconds is quantified as follows: S sum (i) The number of client connections per node of the gateway main service within the most recent t seconds is: C sum (i) Where i represents the i-th node of the gateway's main service. The gateway management service calculates the scores of various indicators of the main gateway service based on the basic indicator data, and calculates the reliability score of the main gateway service according to the set weights. The average call time score of each node of the gateway main service within the most recent t seconds is as follows: Where i represents the i-th node of the gateway main service, and n is the number of gateway main service nodes; In particular, when When the value is 0, the average call time of each node of the gateway main service within the most recent t seconds is set to 1. The score for the total number of interface calls made by each node of the gateway main service within the last t seconds is as follows: Where i represents the i-th node of the gateway main service, and n is the number of gateway main service nodes; In particular, when When the value is 0, the score of the indicator of the total number of interface calls of each node of the gateway main service in the most recent t seconds is set to 1; The scores for the number of client connections within the most recent t seconds for each node of the gateway main service are as follows: Where i represents the i-th node of the gateway main service, and n is the number of gateway main service nodes; In particular, when When the value is 0, the score of the client connection count metric for each node of the gateway main service within the most recent t seconds is set to 1; The reliability score F of the gateway main service score (i) The calculation is as follows: F score (i)=(α*F t (i)+β*F s (i)+γ*F c (i))*100% Where α represents the weight of the average call time score, β represents the weight of the total number of call scores, and γ represents the weight of the client connection score, where α+β+γ=1; The gateway management service updates the reliability score information to the Redis cache; The gateway management service periodically calculates the reliability score of all gateway nodes using the above method and updates it to the Redis cache; When the API gateway master node to which the client is connected experiences an abnormal downtime, the client obtains a new available gateway master service node through the gateway routing service and re-establishes the connection / connection pool.
7. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 3.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Multi-protocol automatic adaptation cloud native gateway system control method, system, device and application
CN114125055A
Remote procedure call processing method and device based on API gateway
CN116074337A
Dynamic thermal expansion and capacity reduction method and system for cloud computer gateway cluster
CN118784488A