Skip to content

Open-source status page, incident response and uptime monitoring

server: fix env (#2750)

Thibault Le Ouay574998ae586a
diff --git a/apps/server/fly.toml b/apps/server/fly.toml
index 980deddef..456af16de 100644
--- a/apps/server/fly.toml
+++ b/apps/server/fly.toml
@@ -23,6 +23,9 @@ primary_region = "ams"
min_machines_running = 1
processes = ["app"]
+# Keep `soft_limit` < `API_MAX_IN_FLIGHT` (see `[env]`) <= `hard_limit`. If the
+# app's cap sits below `soft_limit` the two guards fight: the app sheds 503s
+# while Fly still reads the machine as having room and never starts a peer.
[http_service.concurrency]
type = "requests"
hard_limit = 1000
@@ -41,6 +44,9 @@ primary_region = "ams"
[env]
NODE_ENV = "production"
PORT = "3000"
+ # Backstop only. Fly stops routing here at `hard_limit`, so the in-flight
+ # guard should fire only once that has already failed to protect the machine.
+ API_MAX_IN_FLIGHT = "1000"
# [checks]
diff --git a/apps/server/src/libs/middlewares/limits.ts b/apps/server/src/libs/middlewares/limits.ts
index 0c5d6b576..69904d93a 100644
--- a/apps/server/src/libs/middlewares/limits.ts
+++ b/apps/server/src/libs/middlewares/limits.ts
@@ -2,6 +2,12 @@ import { env } from "@/env";
/** `skipValidation` hands back raw strings, so coerce; missing, non-numeric or zero values fall back. */
export const limits = {
+ /**
+ * Conservative default for self-hosted single-container deploys. Fly
+ * production overrides it from `apps/server/fly.toml`, where it must stay
+ * above `soft_limit` and at most `hard_limit` so Fly scales out before the
+ * app starts shedding.
+ */
maxInFlight: Number(env.API_MAX_IN_FLIGHT) || 128,
perMinute: Number(env.API_RATE_LIMIT_PER_MINUTE) || 600,
burstPer10s: Number(env.API_RATE_LIMIT_BURST_PER_10S) || 100,
diff --git a/deno.lock b/deno.lock
index 1fc5ffecc..58ec016ae 100644
--- a/deno.lock
+++ b/deno.lock
@@ -112,8 +112,7 @@
"packageJson": {
"dependencies": [
"npm:@jsr/std__expect@^1.0.19",
- "npm:@jsr/std__testing@^1.0.19",
+ "npm:@jsr/std__testing@^1.0.19"
]
}
},