ChenChuang commented on issue #12823: URL: https://github.com/apache/apisix/issues/12823#issuecomment-3673378970
Consider the following enhancement: Overview: * Use in-memory counter and redis hash to track request counter of across gateway instances. * Flush counter in memory to redis asynchronously and periodically. * Handle instance TTL with expire time stored in redis hash. Redis hash structure: key: the key of limit field: unique id of the instance value: A structured value storing: 1. current_count: The instance's current concurrent request count. 2. expires_at: Expiration time of the instance. Request handling: * On request arrival: increment the local counter in memory and asynchronously update the instance's field in the redis hash. * On request completion, decrement the local counter and update redis. Check limit: 1. Use HGETALL to fetch counters from all gateway instances. 2. Sum the counts locally to determine total concurrent requests. Timer: * Flush counter to redis periodically in order to keep instance alive. * Clean expired instances in redis with Lua script periodically. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
