How to forward the request to upstream service even when it exceeds the rate limit

Hello,
I would like to use the Rate limit plugin in my application to throttle (slow-down or deprioritize) the processing of certain user’s requests whose excessive requests/sec or per min starves other customers. We may want to charge such customers more for every request exceeding the rate-limit in case throttling their request is something not agreeable to the customers.

Our application does some CPU-intensive background jobs like image processing operations etc hence we are using queue (RabbitMQ) for asynchronous processing.

From what I understand, using the rate-limit plugin, it may be straightforward to configure the rate limit which basically would reject/decline a request with 429 error for a certain consumer if they exceed the rate-limit.

However, in my case, I do not want to reject the request, but rather forward it anyway to upstream service. The upstream service would read the header, and determine if the request violates the SLA for the TPS agreed upon and either bill those customers with additional charges or just assign a low-priority to those requests dynamically so that our system doesn’t process it before other priority requests (all those requests which don’t violate the rate-limit should take precedence over the requests which violate rate-limit policy)

Is there a way to intercept all such request which exceeds the configured rate-limit and forward to upstream service anyway by assigning some custom header (rate-limit-exceeded) so that the upstream service can either process them on low priority or throttle the processing. We may want to charge those customers an extra amount in case they wouldn’t like their latency to increase as and when they exceed the rate-limit by auto-scaling our services/infra in such a scenario.


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ