Repository navigation
Open
Labels
Description
Affected area
Local development
Supabase CLI version
v2.121.0
Operating system
Ubuntu 24.04.5 LTS (x64, 4 vCPU / 16 GB)
Installation method
pnpm
Command
supabase start --runtime native --eager -x functions,studio,mail,analytics,poolerActual output
# The stack starts fine. The problem is CPU per request in the
# __supabase_stack_host__ process, which serves the API gateway.
# 1,000 sequential GET /rest/v1/<table>?select=id&limit=1 (Node, undici).
# CPU per request from utime+stime in /proc/<pid>/stat, before and after:
client connections wall/req gateway CPU/req postgrest CPU/req
new connection each 2.5-2.8 ms 1.8-2.1 ms 0.46-0.52 ms
keep-alive 2.07 ms ~1.7 ms ~0.47 ms
# Integration-test run against the same stack (~120k REST/Auth requests,
# CPU-bound on 4 vCPU), cumulative CPU per process:
__supabase_stack_host__ ~160-195 CPU-s
postgrest ~115 CPU-s
postgres (all backends) ~210-230 CPU-sExpected behavior
A local reverse proxy should add a small fraction of the upstream service's CPU per request. Here the gateway uses about 4× PostgREST's CPU per request, and about as much in total as all of PostgREST, which slows test suites that run on the same machine as the stack.
The responses in the benchmark were small (184-byte 401s), so payload size isn't the cause. Keep-alive barely changes the cost (~1.8 → ~1.7 ms), so it isn't TCP setup either: the cost is per request.
Steps to reproduce
- In any project, set
[experimental] stack = truein supabase/config.toml. - Run
supabase start --runtime native --eager -x functions,studio,mail,analytics,pooler. - Note the gateway's CPU:
pid=$(pgrep -f __supabase_stack_host__); awk '{print $14+$15}' /proc/$pid/stat(clock ticks, 10 ms each). Do the same forpgrep -x postgrest. - Send 1,000 sequential requests to
$API_URL/rest/v1/<any table>?select=id&limit=1with theapikeyheader (curl in a loop, or a Node fetch loop). - Read both counters again. (Difference × 10 ms) / 1,000 is CPU per request: ~1.8–2.1 ms for the gateway against ~0.5 ms for PostgREST.
Crash report ID
No response
Docker and service versions
No Docker: native runtime (CLI stack engine).
Service versions from the stack cache:
auth v2.197.0
postgrest v16.4
postgres 17.11.0.004
realtime v2.143.4
storage v1.82.1Additional context
Possible contributors (guesses, not verified):
- Per-request access logging. The gateway's log and PostgREST's each get a line for every request, both captured and timestamped by the stack host. Each log is ~13 MB after a test run.
- Per-request proxy setup, such as no upstream connection reuse, or rebuilding the transport or translating API keys on each request.
Ask: could the gateway's per-request overhead be reduced, or access logging made optional (or cheaper) for test and CI use?
Activity