I have a backend REST service deployed on Fly. How do you recommend going about implementing API request throttling (using leaky bucket, for example) for each customer at the load balancer level so the boxes don’t get overwhelmed? Do I need to run my own nginx reverse proxy? We had an event today where one user spammed the service with a ton of requests, which generated a ton of logs from the proxy
(which I presume is the Fly.io internal reverse proxy) from the iad
region:
2023-03-20T23:56:36.902 proxy[a11f988a] sjc [warn] Instance reached connections hard limit of 25
2023-03-20T23:56:36.874 proxy[a11f988a] iad [warn] Failed to proxy HTTP request (error: no known healthy instances found for route tcp/443. (hint: is your app shutdown? is there an ongoing deployment with a volume or using the 'immediate' strategy? if not, this could be a delayed state issue)). Retrying in 1000 ms (attempt 30)
2023-03-20T23:58:43.615 proxy[302d9500] lhr [warn] Instance reached connections hard limit of 25
2023-03-20T23:58:43.656 proxy[cba9b5df] iad [warn] Failed to proxy HTTP request (error: no known healthy instances found for route tcp/443. (hint: is your app shutdown? is there an ongoing deployment with a volume or using the 'immediate' strategy? if not, this could be a delayed state issue)). Retrying in 1000 ms (attempt 10)
2023-03-20T23:58:43.663 proxy[cba9b5df] iad [warn] Failed to proxy HTTP request (error: no known healthy instances found for route tcp/443. (hint: is your app shutdown? is there an ongoing deployment with a volume or using the 'immediate' strategy? if not, this could be a delayed state issue)). Retrying in 1000 ms (attempt 30)
2023-03-20T23:58:43.667 proxy[cba9b5df] iad [warn] Failed to proxy HTTP request (error: no known healthy instances found for route tcp/443. (hint: is your app shutdown? is there an ongoing deployment with a volume or using the 'immediate' strategy? if not, this could be a delayed state issue)). Retrying in 934 ms (attempt 40)
2023-03-20T23:58:43.672 proxy[cba9b5df] iad [warn] Failed to proxy HTTP request (error: no known healthy instances found for route tcp/443. (hint: is your app shutdown? is there an ongoing deployment with a volume or using the 'immediate' strategy? if not, this could be a delayed state issue)). Retrying in 1000 ms (attempt 10)