API (Application Program Interface) request cache processing method, device and system and medium

By using distributed cache nodes and event-driven mechanisms in the API interface request cache system, the cache avalanche and data inconsistency problems are solved, the system reliability and scalability are improved, and the consistency and load balancing of cached data are ensured.

CN118916099APending Publication Date: 2024-11-08PING AN BANK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411058420.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-02
Publication Date
2024-11-08

AI Technical Summary

Technical Problem

The existing API interface request cache system has flaws in cache avalanches and data inconsistencies, and cannot effectively deal with cache failures and data update problems, resulting in increased pressure on the backend and data inconsistencies.

Method used

The distributed cache node and event-driven mechanism are adopted to store the API interface cached data in multiple nodes through a pre-built sharding architecture, and listen to data change events for automatic updates to ensure consistency and load balancing of cached data.

Benefits of technology

Improve the reliability and data consistency of API interface request cache processing, avoid cache avalanche, reduce back-end pressure, and enhance the scalability and fault tolerance of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118916099A_ABST
    Figure CN118916099A_ABST
Patent Text Reader

Abstract

The invention discloses an API (Application Program Interface) request cache processing method, device and system and a medium. The method comprises the following steps: creating and configuring a plurality of distributed cache nodes; storing the cache data of the API interface in each distributed cache node based on a pre-constructed fragment architecture; monitoring a data change event, and performing cache data updating on the API subjected to data change according to an event-driven mechanism; and in response to the API calling request, obtaining the latest cache data of the target API from the distributed cache node and returning the latest cache data to a calling requester. According to the method, the fragmentation architecture of cache data is designed, the data are stored on different distributed cache nodes in a scattered mode, so that load balance and expansibility are achieved, cache avalanche is avoided, the reliability of API interface request cache processing is improved, the cache data are automatically updated through an event driving mechanism when a data change event is monitored, and the data change efficiency is improved. And the consistency of the cached data is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of financial technology, and in particular to an API interface request cache processing method, device, system and medium. Background Art

[0002] API interface request caching in financial business systems is an important solution technology in the field of information technology. It is mainly used to provide caching, load balancing, current limiting and other functions. It can be used to build a high-performance API request processing system to improve the high availability of the system.

[0003] There are currently some solutions, products and technologies for API interface request caching and performance optimization in the industry, which can cache frequently accessed data, but generally there are still some defects, mainly reflected in the inability to solve the problem of cache avalanche. When the cache system fails or a large number of caches fail at the same time, all requests will directly access the backend service, causing a sharp increase in backend pressure and avalanche. In addition, when traditional solutions process cache data and backend data, when the backend data changes, the cache is not updated or invalidated in time, which will lead to data inconsistency. Therefore, how to improve the reliability and data consistency of API interface request cache processing is a problem that needs to be solved urgently. Summary of the invention

[0004] In view of the above-mentioned deficiencies in the prior art, the object of the present invention is to provide an API interface request cache processing method, device, system and medium that can be applied to financial technology or other related fields, the main purpose of which is to improve the reliability and data consistency of API interface request cache processing.

[0005] The technical solution of the present invention is as follows:

[0006] A first aspect of the present invention provides an API interface request cache processing method, comprising:

[0007] Create and configure multiple distributed cache nodes;

[0008] Store the cache data of the API interface in each distributed cache node based on the pre-built sharding architecture;

[0009] Monitor data change events and update cached data for API interfaces where data changes have occurred according to the event-driven mechanism;

[0010] In response to an API interface call request, the latest cache data of the target API interface is obtained from the distributed cache node and returned to the call requester.

[0011] In one embodiment, before storing the cache data of the API interface in each distributed cache node based on the pre-built sharding architecture, the method further includes:

[0012] Determine data sharding parameters based on system load and data size;

[0013] A corresponding sharding architecture is constructed according to the data sharding parameters.

[0014] In one embodiment, the monitoring of data change events and updating cached data of the API interface where data has changed according to an event-driven mechanism include:

[0015] Subscribe to a preset message queue, which is used to receive API update events published when data changes occur in the API interface;

[0016] In response to the release of the API update event, cached data is updated for the API interface where data has been changed.

[0017] In one embodiment, in response to the API interface call request, obtaining the latest cache data of the target API interface from the distributed cache node and returning it to the call requester includes:

[0018] Receive API interface call requests;

[0019] The API interface call request is processed asynchronously through an event loop strategy, and a preset completion event is continuously checked during the request execution process;

[0020] The corresponding callback function is called according to the type of the completion event, and the latest cache data of the target API interface read by the completion event is processed and returned to the call requester.

[0021] In one embodiment, in response to the API interface call request, obtaining the latest cache data of the target API interface from the distributed cache node and returning it to the call requester includes:

[0022] Receive multiple API interface call requests within a preset time, and parse the target API interface to be called by each API interface call request;

[0023] Merge multiple API interface call requests accordingly according to different target API interfaces to obtain batch call requests;

[0024] Acquire multiple groups of cache data of each target API interface from the distributed cache node according to the batch call request;

[0025] Distribute the multiple groups of cache data of each target API interface to the corresponding call requester.

[0026] In one embodiment, the method further comprises:

[0027] Corresponding preloaded data is determined according to the data loading strategy, and the preloaded data is added to the cache during a low traffic peak period.

[0028] In one embodiment, the method further comprises:

[0029] Collect and analyze specified performance indicator data;

[0030] The performance indicator data is monitored for abnormalities according to preset alarm rules, and an alarm is triggered if an abnormality is found.

[0031] A second aspect of the present invention provides an API interface request cache processing device, comprising:

[0032] Create a configuration module to create and configure multiple distributed cache nodes;

[0033] The data cache module is used to store the cache data of the API interface in each distributed cache node based on the pre-built sharding architecture;

[0034] The data update module is used to monitor data change events and update cached data of API interfaces where data changes have occurred according to the event-driven mechanism;

[0035] The request response module is used to respond to the API interface call request, obtain the latest cache data of the target API interface from the distributed cache node and return it to the call requester.

[0036] A third aspect of the present invention provides an API interface request cache processing system, the system comprising at least one processor; and

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

[0038] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the above-mentioned API interface request cache processing method.

[0039] A fourth aspect of the present invention provides a non-volatile computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are executed by one or more processors, the one or more processors can execute the above-mentioned API interface request cache processing method.

[0040] Beneficial effects: The present invention discloses a method, device, system and medium for caching API interface requests. Compared with the prior art, the embodiments of the present invention create and configure multiple distributed cache nodes; store the cache data of the API interface in each distributed cache node based on a pre-built sharding architecture; monitor data change events, and update the cache data of the API interface with data changes according to an event-driven mechanism; in response to an API interface call request, obtain the latest cache data of the target API interface from the distributed cache node and return it to the call requester. By designing a sharding architecture for cached data, data is stored in different distributed cache nodes to achieve load balancing and scalability, avoid cache avalanches, and improve the reliability of API interface request cache processing. In addition, the cached data is automatically updated when a data change event is monitored through an event-driven mechanism to ensure the consistency of the cached data. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The present invention will be further described below with reference to the accompanying drawings and embodiments, in which:

[0042] Figure 1 A flow chart of the API interface request cache processing method provided by an embodiment of the present invention;

[0043] Figure 2 A flow chart of constructing a sharding architecture in the API interface request cache processing method provided in an embodiment of the present invention;

[0044] Figure 3 A flow chart of step S103 in the API interface request cache processing method provided in an embodiment of the present invention;

[0045] Figure 4 A flow chart of step S104 in the API interface request cache processing method provided in an embodiment of the present invention;

[0046] Figure 5 Another flow chart of step S104 in the API interface request cache processing method provided by an embodiment of the present invention;

[0047] Figure 6 A schematic diagram of the functional modules of the API interface request cache processing device provided by an embodiment of the present invention;

[0048] Figure 7 A schematic diagram of the hardware structure of the API interface request cache processing system provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0049] In order to make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail below. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. The embodiments of the present invention are described below in conjunction with the accompanying drawings.

[0050] API interface request caching in financial business systems is an important solution technology in the field of information technology. It is mainly used to provide caching, load balancing, current limiting and other functions. It can be used to build a high-performance API request processing system to improve the high availability of the system.

[0051] There are currently some solutions, products and technologies for API interface request caching and performance optimization in the industry, which can cache frequently accessed data, but generally there are still some defects, mainly reflected in the inability to solve the problem of cache avalanche. When the cache system fails or a large number of caches fail at the same time, all requests will directly access the backend service, causing a sharp increase in backend pressure and avalanche. In addition, when traditional solutions process cache data and backend data, when the backend data changes, the cache is not updated or invalidated in time, which will lead to data inconsistency. Therefore, how to improve the reliability and data consistency of API interface request cache processing is a problem that needs to be solved urgently.

[0052] In order to solve the above problems, the present invention proposes an API interface request cache processing method, please refer to Figure 1 , Figure 1 A flowchart of an embodiment of the API interface request cache processing method provided by the present invention. The system architecture of the API interface request cache processing method provided in this embodiment may include a first terminal device, a second terminal device, a third terminal device, a network and a server. The network is used to provide a medium for a communication link between the first terminal device, the second terminal device, the third terminal device and the server. The network may include various connection types, such as wired and / or wireless communication links, etc.

[0053] The user may use the first terminal device, the second terminal device, and the third terminal device to interact with the server through the network to receive or send messages, etc. Various communication client applications may be installed on the first terminal device, the second terminal device, and the third terminal device, such as knowledge reading applications, web browser applications, search applications, instant messaging tools, email clients, and / or social platform software, etc. (only as examples).

[0054] The first terminal device, the second terminal device, and the third terminal device may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0055] The server may be a server that provides various services, such as a background management server that provides support for the content browsed by the user using the first terminal device, the second terminal device, and the third terminal device (for example only). The background management server may analyze and process the received data such as the user request, and feed back the processing results (such as web pages, information, or data obtained or generated according to the user request) to the terminal device. The server may be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server for a distributed system, or a server combined with a blockchain.

[0056] It should be noted that the API interface request cache processing method provided in the embodiment of the present invention can generally be executed by the first terminal device, the second terminal device or the third terminal device. Correspondingly, the API interface request cache processing device provided in the embodiment of the present invention can also be set in the first terminal device, the second terminal device or the third terminal device.

[0057] Alternatively, the API interface request cache processing method provided by the embodiment of the present invention may also be generally executed by a server. Accordingly, the API interface request cache processing device provided by the embodiment of the present invention may generally be arranged in a server. The API interface request cache processing method provided by the embodiment of the present invention may also be executed by a server or a server cluster that is different from the server and can communicate with the first terminal device, the second terminal device, the third terminal device and / or the server. Accordingly, the API interface request cache processing device provided by the embodiment of the present invention may also be arranged in a server or a server cluster that is different from the server and can communicate with the first terminal device, the second terminal device, the third terminal device and / or the server.

[0058] It should be understood that the numbers of the above terminal devices, networks and servers are only illustrative. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0059] like Figure 1 As shown, the API interface request cache processing method provided in this embodiment specifically includes the following steps:

[0060] S101. Create and configure multiple distributed cache nodes.

[0061] In this embodiment, by creating and configuring multiple distributed cache nodes, all distributed cache nodes are formed into a cache cluster to achieve data sharing and high availability. In specific implementation, a distributed cache cluster can be created through distributed cache tools such as Redis or Memcached, and each distributed cache node can be further configured according to factors such as data access mode, data popularity, business needs, etc., such as configuring the network to ensure that all cache nodes can access each other at the network level, including configuring the correct network interface, subnet, firewall rules, etc.; configuring cache sharding strategy, determining data sharding logic, such as consistent hashing or range sharding, to ensure that data is evenly distributed among different nodes; configuring data replication and synchronization strategy, including master-slave replication, bidirectional replication, etc., to ensure data consistency and high availability; configuring failover and fault recovery mechanisms, such as using Redis Sentinel or Cluster mode, to ensure automatic switching when a node fails; configuring access control, authentication and encryption measures to protect cache data security and prevent unauthorized access; configuring and adjusting cache strategies, such as setting reasonable expiration time, elimination strategy, etc., to optimize cache performance, etc. By creating and configuring multiple distributed cache nodes, we ensure the effective creation and stable operation of distributed cache nodes, thereby providing high-performance and high-availability cache services for API interface data.

[0062] S102: Store the cache data of the API interface in each distributed cache node based on the pre-built sharding architecture.

[0063] In this embodiment, the cache data of the API interface is dispersedly stored on different distributed cache nodes through a pre-designed sharding architecture, and the cache read and write operations are implemented in the API request gateway by setting a cache manager to store, read and update data. Data sharding can distribute data to multiple nodes and distribute requests to each node more evenly, thereby reducing the load of a single node, avoiding the situation where some nodes are overloaded while other nodes are idle, achieving load balancing, and improving overall access speed and processing capabilities.

[0064] In one embodiment, Figure 2 As shown, before storing the cache data of the API interface in each distributed cache node based on the pre-built sharding architecture, the method further includes:

[0065] S201, determining data sharding parameters according to system load and data scale;

[0066] S202: construct a corresponding sharding architecture according to the data sharding parameters.

[0067] In this embodiment, the sharding architecture is designed based on the system load and data scale. Specifically, the data scale of the API interface cache data can be evaluated first to determine the total amount of current data and the expected growth rate; then the access pattern is analyzed, including hot data, access frequency, and data read-write ratio, etc., and the dimension of the sharding is determined according to the data characteristics and access pattern. For example, if the data is mainly accessed according to the user ID, then the user ID can be used as the sharding key; a suitable sharding strategy is selected, such as range sharding, which distributes data to different nodes according to the range of the sharding key, hash sharding, which uses the hash value of the sharding key to determine which node the data should be stored in, and consistent hashing, which solves the problem of large-scale data migration caused by the increase or decrease of nodes in hash sharding; then the number of shards is determined, and a reasonable number of shards is determined based on the data scale and expected growth. The number of shards must be able to balance the load and allow the system to scale horizontally. Based on various data sharding parameters, the corresponding sharding architecture is constructed to distribute the cache data of the API interface to different cache nodes to achieve load balancing and scalability. At the same time, you can also set a suitable cache expiration time, implement hot data preloading, use cache degradation strategies, etc., to avoid cache avalanche and cache breakdown problems, and improve the reliability of API interface request cache processing.

[0068] S103: Monitor data change events, and update cached data of the API interface where data changes have occurred according to the event-driven mechanism.

[0069] In this embodiment, in order to ensure the consistency of API interface data, it is necessary to implement a cache update strategy based on business needs and the frequency of data updates, and to update the cache in a timely manner when the data of the backend service changes, so as to keep the cache data up to date. Specifically, by monitoring data change events, the cache data of the API interface where data changes have occurred is updated according to an event-driven mechanism, and the event-driven mechanism is used to implement timely updates of cache data, allowing the cache system to update immediately when data changes occur, rather than relying on scheduled tasks or polling. This reduces the possibility of cached data being outdated, and can ensure that cached data is synchronized with source data in real time, reducing the risk of data inconsistency. Compared with periodically checking data changes, the event-driven mechanism only triggers updates when data changes, reducing the waste of CPU and I / O resources, and can reduce unnecessary cache update operations, and only update data that has actually changed, thereby improving system performance.

[0070] In one embodiment, Figure 3 As shown, the monitoring of data change events and updating of cached data of the API interface where data has changed according to the event-driven mechanism include:

[0071] S301, subscribing to a preset message queue, wherein the message queue is used to receive an API update event published when data changes occur in an API interface;

[0072] S302: In response to the release of the API update event, update cached data of the API interface where data has been changed.

[0073] In this embodiment, the event-driven mechanism relies on monitoring data change events, and then updates the cache in real time. The cache data update of the event-driven mechanism is realized through the publish / subscribe mode, in which the data change is published as an event, and the cache system responds to these events as a subscriber and updates the cache. In terms of implementation, by using a preset message queue as an intermediary for event delivery, when the data of the API interface is updated, the background service will generate an API update event and send it to the preset message queue. The cache system subscribes to this message queue. Once it receives the release notification of the API update event, it immediately updates the cache entry of the API where the data has changed, ensuring that the docking system always receives the latest data. Through the event-driven cache update strategy, when the data of the backend service changes, the cache can be updated in time to keep the cache data up to date and ensure data consistency.

[0074] S104: In response to the API interface call request, the latest cache data of the target API interface is obtained from the distributed cache node and returned to the call requester.

[0075] In this embodiment, after receiving the API interface call request, the API request gateway responds to the request, parses the target API interface to be called in the request and the corresponding request parameters, etc., queries the relevant data of each distributed cache node in the cache cluster through the cache layer, such as determining the cache key and initiating a query request to the cache system. If there is data in the distributed cache node, that is, a cache hit, the data is directly obtained from the cache and returned to the caller. If there is no data in the cache, that is, a cache miss, it is necessary to obtain data from the back-end data source such as a database to update the cache and return the data to the caller. The design of the cache mechanism in this embodiment greatly reduces the network overhead of the request. When the cache hits, the request can be responded directly in the cache layer without further access to the back-end system, thereby reducing network transmission delays and loads. The reuse of cached data reduces the number of requests to the back-end system, and the back-end server can handle more concurrent requests without being limited by the processing time of a single request. This reduced number of requests directly increases the throughput of the back-end system, allowing the system to be better expanded to cope with high traffic situations.

[0076] And through the distributed cache nodes, the horizontal expansion capability of the cache layer is further improved, thereby improving the scalability and capacity of the system, so that the system can flexibly respond to different load requirements. And distributed cache is usually highly fault-tolerant, even if some nodes fail, it will not affect the availability of the entire system.

[0077] In one embodiment, Figure 4 As shown, in response to the API interface call request, the latest cache data of the target API interface is obtained from the distributed cache node and returned to the call requester, including:

[0078] S401, receiving an API interface call request;

[0079] S402, asynchronously processing the API interface call request through an event loop strategy, and continuously checking whether a preset completion event occurs during the request execution process;

[0080] S403: Call a corresponding callback function according to the type of the completion event, process the latest cache data of the target API interface read by the completion event, and return it to the call requester.

[0081] In this embodiment, the received request is processed through an asynchronous processing mechanism, which allows the program to continue to execute other tasks while waiting for a task to complete, rather than blocking and waiting for the completion of the current task. For example, when a Web server processes a user request, if it uses a synchronous method, when the server processes a time-consuming database query, it must wait for the query to complete before continuing to process other user requests, which will cause the request response to be slow. In this embodiment, asynchronous processing is adopted, and the server can start processing the next user request immediately after initiating a database query, and come back to process the query results after the database query is completed, which greatly improves the response speed and throughput of the server.

[0082] Specifically, asynchronous processing is achieved through an event loop. After the system receives an API interface call request, it initiates a corresponding non-blocking I / O operation, such as reading a file. Since it is non-blocking, the system will not wait for the file to be read, but will immediately return and continue to execute other tasks. During the execution process, it will continuously check whether a preset completion event (such as an I / O completion event) has occurred. When the file read operation is completed, the system will generate a completion event. When the completion event is detected, the corresponding callback function registered before is called according to the type of the completion event to process the latest cached data of the target API interface. After the callback function is executed, the processing result is returned to the call requester. Asynchronous processing is achieved through the event loop mechanism, so that the system can execute other tasks while waiting for the I / O operation to complete, maintaining the high performance and high availability of the cache system.

[0083] In one embodiment, Figure 5 As shown, in response to the API interface call request, the latest cache data of the target API interface is obtained from the distributed cache node and returned to the call requester, including:

[0084] S501, receiving multiple API interface call requests within a preset time, and parsing the target API interface to be called by each API interface call request;

[0085] S502, merging multiple API interface call requests accordingly according to different target API interfaces to obtain batch call requests;

[0086] S503, acquiring multiple groups of cache data of each target API interface from the distributed cache node according to the batch call request;

[0087] S504: Distribute the multiple groups of cache data of the target API interfaces to the corresponding call requesting parties.

[0088] In this embodiment, when a large number of API interface call requests are received in a short period of time, multiple requests are merged into one request for processing to provide support for batch requests, thereby reducing network overhead and improving request response speed. Specifically, after receiving multiple API interface call requests, the target API interface that needs to be called by each API interface call request is parsed, and each request is merged according to the target API interface. Requests for the same target API interface are merged into a group of batch call requests, and multiple groups of cache data corresponding to the target API interface are obtained from the distributed cache node according to the batch call request, and then the responsive cache data is distributed to the original call requester. For example, in the case where data needs to be obtained in batches from an external API, middleware can be used to collect multiple requests in a short period of time, merge them into a batch request and send it to the external API, and then the responses are distributed to the original requester, thereby effectively reducing the pressure of data requests and improving the data request efficiency of the API interface.

[0089] In one embodiment, the method further comprises:

[0090] Corresponding preloaded data is determined according to the data loading strategy, and the preloaded data is added to the cache during a low traffic peak period.

[0091] In this embodiment, according to different data loading strategies, the corresponding preloaded data is added to the cache during system startup or low traffic peak period, thereby reducing the delay of the first access and improving the response speed of the system. The specific data loading strategy can be, for example, a frequency-based loading strategy, which is based on the query frequency of the past period of time, and the data with a frequency higher than the preset value is marked as preloaded data, thereby loading the frequently accessed data into the cache in advance; a time-based loading strategy, based on the most recent query time window, the latest queried data is marked as preloaded data, and then the latest access data is loaded into the cache in advance; a loading strategy based on business needs, according to different business types, the associated business data is marked as preloaded data, and then the business data is loaded into the cache in advance, improving business processing efficiency; a loading strategy based on user behavior prediction, through user behavior prediction to determine the data that may be frequently accessed, mark it as preloaded data and add it to the cache, thereby improving the cache hit rate, etc. Flexible adjustment of the corresponding data loading strategy according to demand, through data preloading under different strategies, effectively reducing access delays and improving the response speed of cache processing.

[0092] In one embodiment, the method further comprises:

[0093] Collect and analyze specified performance indicator data;

[0094] The performance indicator data is monitored for abnormalities according to preset alarm rules, and an alarm is triggered if an abnormality is found.

[0095] In this embodiment, real-time performance monitoring is performed on the cache system, specified performance indicator data is collected and analyzed, and corresponding alarm rules are set. The specific performance indicator data collected may include:

[0096] (1) CPU usage, which measures the use of system processing power to determine whether long-term high loads lead to low system efficiency or excessive concurrency;

[0097] (2) Memory usage rate, by reading the amount of memory used by the application, to determine whether there is a memory leak, which causes the usage rate to continue to increase and exhaust system resources;

[0098] (3) Disk I / O: By obtaining the disk read and write rates, it is possible to determine whether there is a disk I / O bottleneck, which may affect application performance and thus database applications;

[0099] (4) Request processing time: By obtaining the time required for the server to process the request, it can be determined whether the backend service efficiency is low and the system resources are tight;

[0100] (5) Error rate, by obtaining the frequency of errors generated by the application, it is possible to determine whether there is a high error rate, which indicates a defect or system overload;

[0101] (6) Number of concurrent users: The number of users using the application at the same time can be used to determine whether there is a high concurrency demand, and additional resources or optimization may be required to maintain performance.

[0102] The above-mentioned multiple performance indicator data are monitored through preset alarm rules to determine whether there are any abnormalities in the performance indicator data. If there are any abnormalities, an alarm is triggered. Specific alarm rules may include:

[0103] (1) Resource usage exceeds the threshold, such as when CPU or memory usage exceeds the set safety threshold (for example, CPU usage exceeds 80% continuously);

[0104] (2) The response time is too long. When the request processing time exceeds the preset maximum response time (for example, more than 2 seconds), the system slow response alarm will be triggered;

[0105] (3) Error rate surge: When the error rate suddenly rises to an abnormal level (e.g., the error rate exceeds 5%), an alarm indicating a system failure will be triggered;

[0106] (4) Insufficient disk space. When the disk usage approaches the upper limit of capacity (such as the usage rate exceeds 90%), the system cannot write data normally and an alarm is triggered;

[0107] (5) Network traffic abnormalities: When network bandwidth usage increases or decreases abnormally, a system configuration error alarm will be triggered.

[0108] In this embodiment, through real-time performance monitoring, corresponding performance indicator data is collected and analyzed in a timely manner. Through the set alarm mechanism, performance problems can be quickly discovered and corresponding measures can be taken, further ensuring the reliability of API interface request cache processing.

[0109] The API interface request cache processing method provided in the embodiment of the present invention designs a sharding architecture for cache data and stores the data in different distributed cache nodes to achieve load balancing and scalability, avoid cache avalanche, and improve the reliability of API interface request cache processing. The event-driven mechanism automatically updates the cache data when a data change event is monitored to ensure the consistency of the cache data.

[0110] It should be noted that there is not necessarily a certain order between the above-mentioned steps. A person skilled in the art can understand, based on the description of the embodiments of the present invention, that in different embodiments, the above-mentioned steps may have different execution orders, that is, they may be executed in parallel, may be executed interchangeably, and so on.

[0111] Another embodiment of the present invention provides an API interface request cache processing device, such as Figure 6As shown, the device 1 comprises:

[0112] Creating a configuration module 11, used to create and configure multiple distributed cache nodes;

[0113] The data cache module 12 is used to store the cache data of the API interface in each distributed cache node based on the pre-built sharding architecture;

[0114] The data update module 13 is used to monitor data change events and update cached data of the API interface where data changes have occurred according to the event-driven mechanism;

[0115] The request response module 14 is used to respond to the API interface call request, obtain the latest cache data of the target API interface from the distributed cache node and return it to the call requester.

[0116] The module referred to in the present invention refers to a series of computer program instruction segments that can perform specific functions, which is more suitable for describing the API interface request cache processing execution process than a program. For the specific implementation of each module, please refer to the corresponding method embodiment above, which will not be repeated here.

[0117] In one embodiment, the device 1 further comprises:

[0118] A parameter determination module is used to determine data sharding parameters according to system load and data size;

[0119] The sharding architecture building module is used to build a corresponding sharding architecture according to the data sharding parameters.

[0120] In one embodiment, the data updating module 13 includes:

[0121] A subscription unit, used to subscribe to a preset message queue, wherein the message queue is used to receive an API update event published when data changes occur in the API interface;

[0122] The response update unit is used to update the cached data of the API interface where the data has been changed in response to the release of the API update event.

[0123] In one embodiment, the request response module 14 includes:

[0124] A request receiving unit, used to receive an API interface call request;

[0125] An event loop unit is used to asynchronously process the API interface call request through an event loop strategy, and continuously check whether a preset completion event has occurred during the request execution process;

[0126] The data response unit is used to call the corresponding callback function according to the type of the completion event, process the latest cache data of the target API interface read by the completion event, and return it to the call requester.

[0127] In one embodiment, the request response module 14 includes:

[0128] A request receiving unit, used to receive multiple API interface call requests within a preset time, and parse the target API interface to be called by each API interface call request;

[0129] A request merging unit is used to merge multiple API interface call requests according to different target API interfaces to obtain batch call requests;

[0130] A data acquisition unit, used to acquire multiple groups of cache data of each target API interface from the distributed cache node according to the batch call request;

[0131] The data distribution unit is used to distribute the multiple groups of cache data of each target API interface to the corresponding call requester.

[0132] In one embodiment, the device 1 further comprises:

[0133] The preloading module is used to determine corresponding preloading data according to the data loading strategy, and add the preloading data to the cache during the low-peak period of traffic.

[0134] In one embodiment, the device 1 further comprises:

[0135] Collection and analysis module, used to collect and analyze specified performance indicator data;

[0136] The abnormality alarm module is used to monitor whether the performance indicator data has abnormalities according to preset alarm rules, and trigger an alarm if an abnormality exists.

[0137] Another embodiment of the present invention provides an API interface request cache processing system, such as Figure 7 As shown, the system 10 includes:

[0138] One or more processors 110 and memory 120, Figure 7 A processor 110 is used as an example for description. The processor 110 and the memory 120 may be connected via a bus or other means. Figure 7 The example of connecting through bus is taken in the following.

[0139] The processor 110 is used to complete various control logics of the system 10, and it can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), a single-chip microcomputer, an ARM (Acorn RISC Machine) or other programmable logic device, a discrete gate or transistor logic, a discrete hardware component, or any combination of these components. In addition, the processor 110 can also be any traditional processor, microprocessor or state machine. The processor 110 can also be implemented as a combination of computing devices, for example, a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors combined with a DSP and / or any other such configuration.

[0140] The memory 120, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions corresponding to the API interface request cache processing method in the embodiment of the present invention. The processor 110 executes various functional applications and data processing of the system 10 by running the non-volatile software programs, instructions and units stored in the memory 120, that is, implementing the API interface request cache processing method in the above method embodiment.

[0141] The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required by at least one function; the data storage area may store data created according to the use of the system 10, etc. In addition, the memory 120 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 120 may optionally include a memory remotely arranged relative to the processor 110, and these remote memories may be connected to the system 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0142] One or more units are stored in the memory 120. When executed by one or more processors 110, the API interface request cache processing method in any of the above method embodiments is executed, for example, the following steps are executed:

[0143] Create and configure multiple distributed cache nodes;

[0144] Store the cache data of the API interface in each distributed cache node based on the pre-built sharding architecture;

[0145] Monitor data change events and update cached data for API interfaces where data changes have occurred according to the event-driven mechanism;

[0146] In response to an API interface call request, the latest cache data of the target API interface is obtained from the distributed cache node and returned to the call requester.

[0147] In one embodiment, before storing the cache data of the API interface in each distributed cache node based on the pre-built sharding architecture, the method further includes:

[0148] Determine data sharding parameters based on system load and data size;

[0149] A corresponding sharding architecture is constructed according to the data sharding parameters.

[0150] In one embodiment, the monitoring of data change events and updating cached data of the API interface where data has changed according to an event-driven mechanism include:

[0151] Subscribe to a preset message queue, which is used to receive API update events published when data changes occur in the API interface;

[0152] In response to the release of the API update event, cached data is updated for the API interface where data has been changed.

[0153] In one embodiment, in response to the API interface call request, obtaining the latest cache data of the target API interface from the distributed cache node and returning it to the call requester includes:

[0154] Receive API interface call requests;

[0155] The API interface call request is processed asynchronously through an event loop strategy, and a preset completion event is continuously checked during the request execution process;

[0156] The corresponding callback function is called according to the type of the completion event, and the latest cache data of the target API interface read by the completion event is processed and returned to the call requester.

[0157] In one embodiment, in response to the API interface call request, obtaining the latest cache data of the target API interface from the distributed cache node and returning it to the call requester includes:

[0158] Receive multiple API interface call requests within a preset time, and parse the target API interface to be called by each API interface call request;

[0159] Merge multiple API interface call requests accordingly according to different target API interfaces to obtain batch call requests;

[0160] Acquire multiple groups of cache data of each target API interface from the distributed cache node according to the batch call request;

[0161] Distribute the multiple groups of cache data of each target API interface to the corresponding call requester.

[0162] In one embodiment, the method further comprises:

[0163] Corresponding preloaded data is determined according to the data loading strategy, and the preloaded data is added to the cache during a low traffic peak period.

[0164] In one embodiment, the method further comprises:

[0165] Collect and analyze specified performance indicator data;

[0166] The performance indicator data is monitored for abnormalities according to preset alarm rules, and an alarm is triggered if an abnormality is found.

[0167] An embodiment of the present invention provides a non-volatile computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are executed by one or more processors, the API interface request cache processing method in any of the above method embodiments is executed, for example, the following steps are performed:

[0168] Create and configure multiple distributed cache nodes;

[0169] Store the cache data of the API interface in each distributed cache node based on the pre-built sharding architecture;

[0170] Monitor data change events and update cached data for API interfaces where data changes have occurred according to the event-driven mechanism;

[0171] In response to an API interface call request, the latest cache data of the target API interface is obtained from the distributed cache node and returned to the call requester.

[0172] In one embodiment, before storing the cache data of the API interface in each distributed cache node based on the pre-built sharding architecture, the method further includes:

[0173] Determine data sharding parameters based on system load and data size;

[0174] A corresponding sharding architecture is constructed according to the data sharding parameters.

[0175] In one embodiment, the monitoring of data change events and updating cached data of the API interface where data has changed according to an event-driven mechanism include:

[0176] Subscribe to a preset message queue, which is used to receive API update events published when data changes occur in the API interface;

[0177] In response to the release of the API update event, cached data is updated for the API interface where data has been changed.

[0178] In one embodiment, in response to the API interface call request, obtaining the latest cache data of the target API interface from the distributed cache node and returning it to the call requester includes:

[0179] Receive API interface call requests;

[0180] The API interface call request is processed asynchronously through an event loop strategy, and a preset completion event is continuously checked during the request execution process;

[0181] The corresponding callback function is called according to the type of the completion event, and the latest cache data of the target API interface read by the completion event is processed and returned to the call requester.

[0182] In one embodiment, in response to the API interface call request, obtaining the latest cache data of the target API interface from the distributed cache node and returning it to the call requester includes:

[0183] Receive multiple API interface call requests within a preset time, and parse the target API interface to be called by each API interface call request;

[0184] Merge multiple API interface call requests accordingly according to different target API interfaces to obtain batch call requests;

[0185] Acquire multiple groups of cache data of each target API interface from the distributed cache node according to the batch call request;

[0186] Distribute the multiple groups of cache data of each target API interface to the corresponding call requester.

[0187] In one embodiment, the method further comprises:

[0188] Corresponding preloaded data is determined according to the data loading strategy, and the preloaded data is added to the cache during a low traffic peak period.

[0189] In one embodiment, the method further comprises:

[0190] Collect and analyze specified performance indicator data;

[0191] The performance indicator data is monitored for abnormalities according to preset alarm rules, and an alarm is triggered if an abnormality is found.

[0192] As an example, non-volatile storage media can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) as external cache memory. By way of illustration and not limitation, RAM can be obtained in many forms such as synchronous RAM (SRAM), dynamic RAM, (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), and direct Rambus RAM (DRRAM). The disclosed memory components or memories of the operating environment described herein are intended to include one or more of these and / or any other suitable types of memory.

[0193] In summary, the present invention discloses a method, device, system and medium for caching API interface requests, the method comprising: creating and configuring multiple distributed cache nodes; storing the cache data of the API interface in each distributed cache node based on a pre-built sharding architecture; monitoring data change events, and updating the cache data of the API interface with data changes according to an event-driven mechanism; in response to an API interface call request, obtaining the latest cache data of the target API interface from the distributed cache node and returning it to the call requester. By designing a sharding architecture for cached data, data is stored in different distributed cache nodes in a dispersed manner to achieve load balancing and scalability, avoid cache avalanches, and improve the reliability of API interface request cache processing. In addition, the cached data is automatically updated when a data change event is monitored through an event-driven mechanism to ensure the consistency of the cached data.

[0194] Of course, those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware (such as a processor, a controller, etc.) through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium, and the computer program can include the processes of the above-mentioned method embodiments when executed. The storage medium can be a memory, a disk, a floppy disk, a flash memory, an optical storage device, etc.

[0195] It should be understood that the application of the present invention is not limited to the above examples. For ordinary technicians in this field, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.

Claims

1. A method for caching API interface requests, characterized in that: include: Create and configure multiple distributed cache nodes; Store the cache data of the API interface in each distributed cache node based on the pre-built sharding architecture; Monitor data change events and update cached data for API interfaces where data changes have occurred according to the event-driven mechanism; In response to an API interface call request, the latest cache data of the target API interface is obtained from the distributed cache node and returned to the call requester.

2. The API interface request cache processing method according to claim 1, characterized in that: Before storing the cache data of the API interface in each distributed cache node based on the pre-built sharding architecture, the method further includes: Determine data sharding parameters based on system load and data size; A corresponding sharding architecture is constructed according to the data sharding parameters.

3. The API interface request cache processing method according to claim 1, characterized in that: The monitoring of data change events and updating cached data of the API interface where data has changed according to the event-driven mechanism include: Subscribe to a preset message queue, which is used to receive API update events published when data changes occur in the API interface; In response to the release of the API update event, cached data is updated for the API interface where data has been changed.

4. The API interface request cache processing method according to claim 1, characterized in that: The step of obtaining the latest cache data of the target API interface from the distributed cache node and returning the data to the call requester in response to the API interface call request includes: Receive API interface call requests; The API interface call request is processed asynchronously through an event loop strategy, and a preset completion event is continuously checked during the request execution process; The corresponding callback function is called according to the type of the completion event, and the latest cache data of the target API interface read by the completion event is processed and returned to the call requester.

5. The API interface request cache processing method according to claim 1, characterized in that: The step of obtaining the latest cache data of the target API interface from the distributed cache node and returning the data to the call requester in response to the API interface call request includes: Receive multiple API interface call requests within a preset time, and parse the target API interface to be called by each API interface call request; Merge multiple API interface call requests accordingly according to different target API interfaces to obtain batch call requests; Acquire multiple groups of cache data of each target API interface from the distributed cache node according to the batch call request; Distribute the multiple groups of cache data of each target API interface to the corresponding call requester.

6. The API interface request cache processing method according to claim 1, characterized in that: The method further comprises: Corresponding preloaded data is determined according to the data loading strategy, and the preloaded data is added to the cache during a low traffic peak period.

7. The API interface request cache processing method according to claim 1, characterized in that: The method further comprises: Collect and analyze specified performance indicator data; The performance indicator data is monitored for abnormalities according to preset alarm rules, and an alarm is triggered if an abnormality is found.

8. An API interface request cache processing device, characterized in that: include: Create a configuration module to create and configure multiple distributed cache nodes; The data cache module is used to store the cache data of the API interface in each distributed cache node based on the pre-built sharding architecture; The data update module is used to monitor data change events and update cached data of API interfaces where data changes have occurred according to the event-driven mechanism; The request response module is used to respond to the API interface call request, obtain the latest cache data of the target API interface from the distributed cache node and return it to the call requester.

9. An API interface request cache processing system, characterized in that: The system includes at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the API interface request cache processing method described in any one of claims 1-7.

10. A non-volatile computer-readable storage medium, characterized in that: The non-volatile computer-readable storage medium stores computer-executable instructions, which, when executed by one or more processors, enable the one or more processors to execute the API interface request cache processing method described in any one of claims 1-7.