Intelligent management system and method applied to asynchronous API data
By using an intelligent management system that combines token bucket rate limiting and non-blocking task scheduling to dynamically adjust caching strategies, the problems of low cache hit rate and resource consumption are solved, achieving efficient data management and system optimization.
Patent Information
- Application Number
- CN202610131265.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-30
- Publication Date
- 2026-04-24
AI Technical Summary
Existing caching mechanisms fail to adequately consider the time sensitivity of data and the stability of historical calls, resulting in low cache hit rates or the risk of outdated data. The token bucket rate limiting mechanism consumes scheduling resources and restricts the system's concurrent processing capacity.
It adopts elastic lifecycle data assets, non-blocking task suspension scheduling, and dynamic adjustment of caching strategies based on historical behavior. Combined with the token bucket rate limiting mechanism, the token management module calculates the number of tokens and the sleep state, the intelligent cache management module dynamically sets the cache duration, and the retry and alarm module performs exponential latency backoff retries.
It improved system resource utilization efficiency, optimized data timeliness and cache hit rate, reduced unnecessary API calls and token resource consumption, and enhanced system robustness and observability.
Smart Images

Figure CN121924083A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer internet technology, specifically to an intelligent management system and method for asynchronous API data. Background Technology
[0002] As cloud-native applications evolve towards higher concurrency density, lower latency tolerance, and more refined cost control, existing caching mechanisms mostly adopt fixed lifecycles or simple timestamp expiration strategies. These fail to fully consider dynamic factors such as the time sensitivity of the data itself, the stability of historical calls, and the subsequent access frequency, resulting in both low cache hit rates and the risk of data obsolescence. While token bucket rate limiting mechanisms can ensure compliant call rates, their waiting logic usually relies on blocking sleep or polling detection, causing a large number of worker threads to occupy scheduling resources even when there are no actual computing tasks, which severely restricts the system's concurrency processing limit.
[0003] Therefore, how to construct an asynchronous API data intelligent management method and system that integrates elastic lifecycle data assets, non-blocking task suspension scheduling, and dynamic adjustment of caching strategies based on historical behavior, in order to achieve synergistic optimization among cost saving, resource efficiency, and data timeliness, has become a key challenge currently faced by those skilled in the art. Summary of the Invention
[0004] The purpose of this invention is to provide an intelligent management system and method for asynchronous API data, so as to solve the problems raised in the prior art.
[0005] To achieve the above objectives, the present invention provides the following technical solution: an intelligent management method for asynchronous API data; The specific steps of the method include: Step S1: The Web server receives the data request from the front end, extracts the data identifier di, generates a globally unique task identifier IDi, constructs a task unit Ji containing the task identifier IDi and the data identifier di, writes the task unit Ji into the distributed message queue Q, and returns a receive permission response containing the task identifier IDi to the front end. Step S2: The task processing engine retrieves the task unit Ji from the distributed message queue Q and queries the local cache storage area based on the data identifier di. Step S3: If a data copy matching the data identifier di and within its valid lifecycle is found, the content of the data copy is returned directly, and the process ends; if no valid data copy is found, proceed to step S4. Step S4: Before executing the API call, obtain the current token bucket state, calculate the number of tokens added from the last token filling time to the current time, and update the total number of tokens; Step S5: Determine whether the updated total number of tokens meets the execution authorization conditions; if it does, authorize the execution of the API call and proceed to step S6; if it does not, calculate the next token generation prediction time, set task unit Ji to sleep state, set the wake-up time, and pause the process until it is woken up. Step S6: Execute the API call. If the call is successful, dynamically set the effective storage duration of the returned data copy based on the historical call status and store the data in the local cache storage area; if the call fails, trigger the retry mechanism. Step S7: For the task unit that fails to be called, the exponential delay backoff mechanism is used for retry scheduling. When the total number of retries exceeds the preset threshold, the task status is marked as a failed task status and an alarm is triggered. In step S8, the final status, call results, and related metadata of all tasks are stored in the task status database with the task identifier IDi as the primary key.
[0006] Preferably, the method for the token management module to perform token calculation and task scheduling includes: the current token bucket state includes the last token filling time t. last Current token count T k Token replenishment rate k and token bucket capacity C; calculated from t last The number of tokens n added during the period up to the current time t is calculated using the formula: where ⌊·⌋ represents the floor function; update the total number of tokens T. update The calculation formula is as follows: where represents the minimum value function; if , then authorize the execution of the API call and decrement the token count by 1; otherwise, calculate the next token generation prediction time t. predict The calculation formula is as follows, where ⌈·⌉ represents the floor function, which sets task unit Ji to sleep state and sets the wake-up time to t. predict .
[0007] Furthermore, the method for the intelligent cache management module to set the initial effective storage duration of data replicas includes: for task unit Ji, obtaining the data freshness validity period T of its corresponding data from the API service response. fresh Query the historical call records of task unit Ji from the task status database and calculate the average historical call time Δt. call Based on T fresh With Δt call The initial effective storage duration τ0 of the data copy is calculated using the formula, where α and β are preset weight coefficients that satisfy α + β = 1 and α > 0.5, to ensure that the data freshness commitment dominates the initial duration setting.
[0008] In addition, the intelligent cache management module extends the effective storage time of data replicas by calculating an updated value τ of its effective storage time when a data replica within its effective lifecycle is hit by a subsequent task. new Its calculation formula is, where τ current This represents the remaining effective storage time of the data replica, where γ is the gain coefficient, with a value range of 0 < γ < 0.2; simultaneously, a global storage time limit τ is set. max Ensure that any updated value τ new All conditions must be met to prevent hot data from occupying cache space indefinitely.
[0009] Preferably, the method for the retry and alarm module to perform exponential delay backoff retries includes: setting the maximum number of retries to L; for a failed task unit, the delay time δ for its nth retry. n Following the exponential growth law, i.e., each unit of time; when the cumulative number of retries for a task unit reaches L times and the API call still fails, the retry and alarm module marks the task status as "failed task status" and writes this status along with the failure timestamp into the task status database, while triggering the preset alarm process.
[0010] Furthermore, the method for storing task status in the task status database includes: when an API call is successful, the task processing engine stores the returned API data, the timestamp of the successful call, the time taken for this call, and the corresponding data identifier di, with the task identifier IDi as the primary key, in the task status database; for API call tasks skipped due to cache hits, the task processing engine stores the hit timestamp, the data source marked as "cached", and the corresponding data identifier di, also with the task identifier IDi as the primary key, in the task status database, forming a complete task execution audit trail.
[0011] Furthermore, the intelligent management system includes a server information management module, a distributed message queue management module, a task processing engine, a local cache storage area, a token management module, an intelligent cache management module, a task status database, and a retry and alarm module. The server information management module, deployed at the front end of the web server, receives HTTP / HTTPS requests from clients, parses the request body to extract data identifiers, generates a globally unique task identifier based on a globally monotonically increasing sequence generator or a UUID algorithm, constructs a task unit Ji containing the task identifier IDi and the data identifier di, serializes the task unit Ji in a specific format, writes it to the distributed message queue Q, and immediately returns a 202 Accepted response containing the task identifier IDi to the front end, thus achieving rapid confirmation of the request.
[0012] The task processing engine, as the core execution unit of the system, continuously retrieves task units Ji from the distributed message queue Q in a pull mode. Upon receiving a task unit Ji, it first uses its data identifier di as the lookup key to perform a lookup operation in the local cache storage area. The local cache storage area adopts a memory-mapped structure based on timestamp indexes. Each cache entry contains fields such as data content payload, data identifier di, initial valid storage duration τ0, current remaining valid storage duration, last access timestamp, and storage limit.
[0013] The task processing engine directly reads the data copy from the data content field, encapsulates it into a standard API response format, and pushes the result to the front-end client through a callback channel connection. At the same time, it triggers the intelligent cache management module to perform an operation to extend the effective storage time. The processing flow of task unit Ji terminates here, and no further API call steps are required.
[0014] If a cache miss occurs or a cache entry expires, the task processing engine will hand over the task unit Ji to the token management module for rate limiting authorization.
[0015] The token management module manages the token bucket state, which is characterized by four parameters: the time t of the last token filling. last Current token count T k The token replenishment rate k and the token bucket capacity C are also considered. Upon receiving an authorization request from task unit Ji, the token management module first obtains the current system time t and calculates the time since t. last The time interval Δt that elapses until t is equal to t - t. last The number of new tokens, n = ⌊k · (Δt / 1000)⌋, is then calculated, where ⌊·⌋ represents the floor function. The total number of tokens, T, is then updated. update = min(Tk + n, C), where min(·) represents the minimum value function.
[0016] If T update If the value is ≥ 1, the token management module authorizes the execution of the API call, decrements the total number of tokens by 1, and updates t. last ←t, and simultaneously pass the task unit Ji to the API call execution module; otherwise, calculate the next token generation prediction time t. predict . t predict = t last + ⌈(C − T k )⌉ / k × 1000, where ⌈·⌉ represents the floor function, and the result is converted to milliseconds. The token management module puts task unit Ji into a sleep state and sets it to the wake-up time t. predictThey are registered together to either the time wheel or a heap-based delayed task queue. The scheduler periodically scans this queue, and when system time reaches t... predict When the task unit Ji is not in use, it is automatically resubmitted to the task processing engine's queue for processing, achieving non-blocking wake-up and avoiding idle thread resources.
[0017] After obtaining token authorization, the API call execution module initiates a call to the target asynchronous API service, carrying the data identifier di as a request parameter. The API service declares the freshness validity period T of the data in the response header. fresh For example, via Cache-Control: max-age=T fresh The field. Simultaneously, the task processing engine queries the historical call records of this data identifier di from the task status database, extracting the average response latency Δt of the most recent N successful calls. call .
[0018] Based on these two inputs, the intelligent cache management module calculates the initial effective storage duration τ0 of the data replica, using the formula: τ0 = α · T fresh + β · Δt call Here, α and β are preset weighting coefficients, satisfying α + β = 1 and α > 0.5, to ensure that the freshness requirement declared by the server has a dominant weight. For example, α = 0.7 and β = 0.3 are set. The calculated τ0 is in seconds and converted to milliseconds for storage in the cache entry.
[0019] When the API call successfully returns data, the task processing engine writes the data content, call completion timestamp, actual call time, and data identifier di, along with the task identifier IDi, into the task status database.
[0020] The intelligent cache management module creates new cache entries in the local cache storage area and sets the maximum storage duration τ. max .
[0021] For cache entries that are already within their validity period, if they are hit by subsequent task units, the intelligent cache management module performs an operation to extend the effective storage duration. Specifically, it calculates the updated effective storage duration τ. new If the calculated τ new Exceeding the preset τ max Then it is truncated to τ. max Simultaneously, the last access timestamp of the cached entry is updated. This mechanism allows frequently accessed, hot data to maintain a longer validity period, thereby improving cache hit rate and reducing unnecessary API calls.
[0022] For API call failures, the retry and alarm module intervenes. The system presets a maximum number of retries, L. For the nth retry, n starts counting from 1, and the delay time is in seconds. For example, after the first failure, wait 1 second to retry, 2 seconds for the second, 4 seconds for the third, and so on. The retry task is repackaged into the original task unit Ji and written back to the distributed message queue Q, or managed by a dedicated retry queue. When the number of retries reaches L, the task status is marked as "failed task status," and the failure reason, such as HTTP 500, timeout, network error, etc., the last call time, the cumulative number of retries, and the original request context, are persistently written to the task status database with the task identifier IDi as the primary key.
[0023] Meanwhile, the retry and alarm module sends structured alarm events to the operation and maintenance monitoring system via SMTP, Webhook, or message queue, including task identifier, data identifier, and failure summary.
[0024] The task status database is implemented using a relational or document-oriented database. The database stores fields including: task identifier, data identifier, API return data content, call timestamp, call duration, initial valid storage duration, final cache write time, and cache hit count. For failed tasks, it stores the task identifier, data identifier, failure reason code, a list of retry timestamps, cumulative retry count, and final status flag. The final status of all tasks is persistently stored in this structure, supporting efficient queries by task identifier, data identifier, or time range, providing a data foundation for system observability, audit traceability, and business analysis.
[0025] Compared with the prior art, the beneficial effects of the present invention are: 1. By deeply coupling the token bucket rate limiting mechanism with task scheduling and introducing a sleep and wake-up mechanism based on precise calculation, thread blocking and CPU resource idleness during task waiting for tokens are avoided, which significantly improves the system's resource utilization efficiency and overall throughput in high-concurrency scenarios. 2. An intelligent caching strategy is adopted that dynamically calculates the initial cache duration based on data freshness and historical call performance, and adaptively extends the cache life cycle based on access popularity. This effectively balances data timeliness and cache hit rate, significantly reducing unnecessary API calls while ensuring data freshness, thus saving token resources and network overhead. 3. A closed-loop task status management system with task identifiers as the primary key was constructed. This system uniformly and persistently stores and associates status information from multiple stages, including task execution, cache management, token control, and retry alarms. This provides a complete and reliable data foundation for system monitoring, fault diagnosis, and subsequent intelligent strategy optimization. Simultaneously, through an exponential backoff retry mechanism linked to task status, and by marking and alarming failures based on preset thresholds, the system avoids retry impacts caused by momentary service failures, enhancing its robustness and observability against external service anomalies. Attached Figure Description
[0026] Figure 1 This is a flowchart illustrating an intelligent management method for asynchronous API data according to the present invention. Figure 2 This is a schematic diagram of the structure of an intelligent management system for asynchronous API data according to the present invention. Detailed Implementation
[0027] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0028] Example: Figures 1-2 As shown, the present invention provides a technical solution: an intelligent management system and method for asynchronous API data.
[0029] The methods include: Step S1: The Web server receives the data request from the front end, extracts the data identifier di, generates a globally unique task identifier IDi, constructs a task unit Ji containing the task identifier IDi and the data identifier di, writes the task unit Ji into the distributed message queue Q, and returns a receive permission response containing the task identifier IDi to the front end. Step S2: The task processing engine retrieves the task unit Ji from the distributed message queue Q and queries the local cache storage area based on the data identifier di. Step S3: If a data copy matching the data identifier di and within its valid lifecycle is found, the content of the data copy is returned directly, and the process ends; if no valid data copy is found, proceed to step S4. Step S4: Before executing the API call, obtain the current token bucket state, calculate the number of tokens added from the last token filling time to the current time, and update the total number of tokens; Step S5: Determine whether the updated total number of tokens meets the execution authorization conditions; if it does, authorize the execution of the API call and proceed to step S6; if it does not, calculate the next token generation prediction time, set task unit Ji to sleep state, set the wake-up time, and pause the process until it is woken up. Step S6: Execute the API call. If the call is successful, dynamically set the effective storage duration of the returned data copy based on the historical call status and store the data in the local cache storage area; if the call fails, trigger the retry mechanism. Step S7: For the task unit that fails to be called, the exponential delay backoff mechanism is used for retry scheduling. When the total number of retries exceeds the preset threshold, the task status is marked as a failed task status and an alarm is triggered. In step S8, the final status, call results, and related metadata of all tasks are stored in the task status database with the task identifier IDi as the primary key.
[0030] The technical solution of the present invention will be quantitatively described below through a specific implementation example: Suppose in a price query service system, the front end requests a query for the real-time price of product code "SH06". The web server receives this request, extracts the data identifier di="SH06", generates a task identifier IDi="task-8f3a1c2b", constructs a task unit Ji={"task_id":"task-8f3a1c2b","data_id":"SH06"}, writes it to the Kafka topic "async_tasks", and returns {"task_id":"task-8f3a1c2b","status":"accepted"}.
[0031] The task processing engine pulls Ji from Kafka. It queries the local cache but misses. It then enters the token verification phase. At this point, the token bucket state is: t last =1717020000000, T k =0, k=2, meaning 2 tokens are replenished per second, C=10.
[0032] The current system time is t = 1717020000500 (12:00:00.500). Calculate Δt = 500ms, n = ⌊2×(500 / 1000)⌋ = ⌊1.0⌋ = 1, T update =min(0+1,10)=1, because T update ≥1, authorized call, T k Updated to 0, t last Updated to 1717020000500.
[0033] The API call execution module sends a request to the market data service. The service response header contains Cache-Control: max-age=3, that is, T fresh = 3 seconds.
[0034] Query the historical records, the average latency Δt of the last 5 calls call = 0.8 seconds. Set α = 0.7, β = 0.3, then τ0 = 0.7×3 + 0.3×0.8 = 2.1 + 0.24 = 2.34 seconds. The call is successful, return the quote data, and the call duration δcall = 0.75 seconds.
[0035] Write a record to the task status database: task_id = "task-8f3a1c2b", data_id = "SH06", status = "success", create_time = 1717020000000,, complete_time = 1717020001250, call_duration_ms = 750, retry_count = 0.
[0036] At the same time, create a new entry in the local cache: di = "SH06", data = quote data, t creation = 1717020001250, τ0 = 2340ms, τ current = 2340ms, τ max = 3600000ms.
[0037] After 1 second (t = 1717020002250); Another request queries the same product, and the cache is hit (1717020002250 <1717020>001250 + 2340 = 1717020003590).
[0038] Trigger the extension mechanism, obtain γ = 0.15, then τ new = 2340 - (2250 - 1250) + 0.15×2340 = 1340 + 351 = 1691ms. But the total validity period should not exceed τ max . The new expiration time = t now + τ new = 1717020002250 + 1691 = 1717020003941. The original expiration time was 1717020003590, and now it is extended to 1717020003941.
[0039] Consider the rate limiting scenario again: If at t = 1717020000500, T k = 0, but k = 0.5, 1 token per 2 seconds, then n = ⌊0.5×0.5⌋ = ⌊0.25⌋ = 0, Tupdate =0.
[0040] Calculate t predict One token needs to be filled, and the time is 1 / 0.5 = 2 seconds, therefore t predict =1717020000000+2000=1717020002000, the task is suspended, and will be retried after 2 seconds.
[0041] For retrying on failure: Let L=3. If the first call fails (n=1), δ1=1 second, and retry after 1 second; if it fails again (n=2), δ2=2 seconds; if it fails a third time (n=3), δ3=4 seconds; if it fails a fourth time (n=4>L=3), it is marked as a failure, written to the database, and an alarm is triggered.
[0042] The system includes: a server information management module, a distributed message queue management module, a task processing engine, a token management module, an intelligent cache management module, a task status database, and a retry and alarm module; The server information management module is used to receive requests from the front end, construct task units including task identifiers and data identifiers, write task units into a distributed message queue, and return a receive permission response containing task identifiers to the front end. The distributed message queue management module is used to receive and store task units written by the web server, and provides asynchronous task scheduling and buffering. The task processing engine retrieves task units from the distributed message queue, queries the local cache storage area based on the data identifier, and if a data copy matching the data identifier and within its valid lifecycle is found, it directly returns the content of the data copy, skipping the API call process; if no valid data copy is found, it executes the token management and API call process. The token management module is used to obtain the current token bucket status before executing the API call, calculate the number of tokens added from the last token filling time to the current time, and update the total number of tokens. If the number of tokens meets the execution authorization conditions, the task processing engine is authorized to execute the API call. Otherwise, the next token generation prediction time is calculated, the task unit is set to sleep state, and the wake-up time is set. The intelligent cache management module is used to dynamically set the initial effective storage time of data copies in the local cache storage area based on the data freshness commitment and historical call status returned by the API service for successfully completed API calls, and to extend the effective storage time of data copies according to preset rules when the data copies are hit by subsequent tasks. The task status database is used to store the final status, call results and related metadata of all task units, with the task identifier as the primary key. The retry and alarm module is used to schedule retry in the event of API call failure using an exponential delay backoff mechanism. When the total number of retries exceeds a preset threshold, the task status is marked as a failed task and an alarm is triggered.
[0043] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or essential characteristics. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.
Claims
1. An intelligent management method for asynchronous API data, characterized in that: The methods include: The web server receives a request from the front end, constructs a task unit including the task identifier and the data identifier, writes the task unit into a distributed message queue, and returns a receive permission response containing the task identifier to the front end. The task processing engine retrieves task units from the distributed message queue and queries the local cache storage area based on the data identifier. If a data copy that matches the data identifier and is within its valid lifecycle exists, the engine directly returns the content of the data copy, skipping the API call. Before executing the API call, obtain the current token bucket state, calculate the number of tokens added from the last token filling time to the current time, and update the total number of tokens; If the number of tokens meets the execution authorization conditions, the API call is authorized; otherwise, the predicted time for the next token generation is calculated, the task unit is put into a sleep state, and the wake-up time is set. For successfully completed API calls, the effective storage duration of the data copy is dynamically set based on the historical call status, and the effective storage duration is extended when the data copy is hit by a subsequent task. For API call failures, an exponential delay backoff mechanism is used for retrying. When the total number of retries exceeds the threshold, the task status is marked as a failed task and an alarm is triggered. The final state of all tasks is stored in the task state database using the task identifier as the primary key.
2. The intelligent management method for asynchronous API data according to claim 1, characterized in that: During API calls, the methods for authorizing API call execution and putting task units into a dormant state include: The current token bucket state includes the last token filling time tlast, the current number of tokens Tk, the token replenishment rate k, and the token bucket capacity C; Calculate the number of tokens n added from tlast to the current time t, n = ⌊k·(t − tlast)⌋, and update the total number of tokens Tupdate, Tupdate= min(Tk + n, C), where ⌊·⌋ represents the floor function and min(·) represents the minimum value function; If Tupdate ≥ 1, then authorize the execution of the API call and decrement the token count by 1; otherwise, calculate the next token generation prediction time tpredict = tlast + ⌈(C − Tk)⌉ / k, put the task unit Ji into a sleep state, and set the wake-up time to tpredict. Here, ⌈·⌉ represents the floor function.
3. The intelligent management method for asynchronous API data according to claim 1, characterized in that: Methods to skip API calls before authorizing their execution include: For a given task unit Ji, obtain the data freshness validity period Tfresh of the corresponding data replica of task unit Ji from the API service, obtain the average historical call time Δtcall from the historical call records of task unit Ji, and calculate the initial effective storage duration τ0 of the corresponding data replica of task unit Ji, τ0 = α·Tfresh + β·Δtcall, where α and β are preset weight coefficients, satisfying α + β = 1, and α > 0.
5.
4. The intelligent management method for asynchronous API data according to claim 3, characterized in that: When a data copy is hit by a subsequent task within its validity period, the methods to extend its effective storage time include: Calculate the updated value of the effective storage time τnew, τnew = τcurrent + γ·τ0, where γ is the gain coefficient, 0 < γ < 0.2, and τcurrent is the current remaining effective storage time of the data replica; Set the storage duration limit τmax, and any update value τnew can be less than or equal to τmax.
5. The intelligent management method for asynchronous API data according to claim 1, characterized in that: Methods for storing task status in a task status database include: The maximum number of retries is set to L. For a failed task unit call, the delay time for the nth retry is δ. n In a given unit of time, when the number of retries for a failed API call reaches the maximum number of retries L, the task status is marked as "failed task status" and written to the task status database. When an API call is successful, the returned API data, call timestamp, call duration, and data identifier are stored in the task status database with the task identifier as the primary key.
6. An intelligent management system for asynchronous API data, used to execute the intelligent management method for asynchronous API data as described in any one of claims 1-5, characterized in that: The system includes: The system includes a server information management module, a task processing engine, a token management module, an intelligent cache management module, a task status database, and a retry and alarm module. The server information management module receives frontend requests and generates task units, which are then written to the distributed message queue. The distributed message queue management module manages the distributed message queue. The task processing engine queries the local cache; if a match is not found, the token management module calculates the token status and determines whether to execute the API call. The intelligent cache management module dynamically sets the effective storage duration of data copies. The task status database records the final status of the task units. The retry and alarm module is used to reschedule task units.
7. The intelligent management system for asynchronous API data according to claim 6, characterized in that: The intelligent management system includes: The server information management module is used to receive requests from the front end, construct task units including task identifiers and data identifiers, write task units into a distributed message queue, and return a receive permission response containing task identifiers to the front end. The distributed message queue management module is used to receive and store task units written by the web server, and provides asynchronous task scheduling and buffering. The task processing engine retrieves task units from the distributed message queue, queries the local cache storage area based on the data identifier, and if a data copy matching the data identifier and within its valid lifecycle is found, it directly returns the content of the data copy, skipping the API call process; if no valid data copy is found, it executes the token management and API call process.
8. The intelligent management system for asynchronous API data according to claim 6, characterized in that: The system includes: The token management module is used to obtain the current token bucket status before executing API calls, calculate the number of tokens added from the last token filling time to the current time, and update the total number of tokens. If the number of tokens meets the execution authorization conditions, then authorize the task processing engine to execute the API call; otherwise, calculate the next token generation prediction time, set the task unit to sleep state, and set the wake-up time.
9. The intelligent management system for asynchronous API data according to claim 6, characterized in that: The system includes: The intelligent cache management module is used to dynamically set the initial effective storage duration of data copies in the local cache storage area based on the data freshness commitment and historical call status returned by the API service for successfully completed API calls, and to extend the effective storage duration of data copies according to preset rules when the data copies are hit by subsequent tasks.
10. The intelligent management system for asynchronous API data according to claim 6, characterized in that: The system includes: The task status database is used to store the final status, call results and related metadata of all task units, with the task identifier as the primary key. The retry and alarm module is used to schedule retry in the event of API call failure using an exponential delay backoff mechanism. When the total number of retries exceeds a preset threshold, the task status is marked as a failed task and an alarm is triggered.
Citation Information
Patent Citations
Distributed caching method and system for IOT scene
CN113392132A
AI gateway multi-level cache synchronization method and system oriented to high-concurrency API service
CN120528975A
Video stream concurrent access front-end dynamic scheduling control system and method based on digital twinborn scene
CN120786117A
Configurable rate limiting using static token buckets, and applications thereof
US8681630B1
