Skip to content

Resource Limits

Thunder enforces resource limits at multiple levels to ensure fair scheduling, prevent runaway functions, and protect the host process. All limits are configurable via CLI flags or environment variables.


These limits apply to each individual function isolate.

ResourceCLI flagEnv varDefaultDescription
Heap memory--max-heap-mibEDGE_RUNTIME_MAX_HEAP_MIB128 MiBMaximum V8 heap size. The isolate is terminated if it exceeds this.
CPU time--cpu-time-limit-msEDGE_RUNTIME_CPU_TIME_LIMIT_MS50000 msCumulative CPU time (excludes I/O wait). Isolate is terminated when exceeded.
Wall-clock timeout--wall-clock-timeout-msEDGE_RUNTIME_WALL_CLOCK_TIMEOUT_MS60000 msTotal elapsed time from request start. Covers CPU, I/O, and idle time.
VFS total quota--vfs-total-quota-bytesEDGE_RUNTIME_VFS_TOTAL_QUOTA_BYTES10 MiBTotal writable bytes in /tmp. See Virtual File System.
VFS max file size--vfs-max-file-bytesEDGE_RUNTIME_VFS_MAX_FILE_BYTES5 MiBMaximum size of a single file in /tmp.
  • Heap exceeded: The isolate is terminated immediately. The client receives a 503 Service Unavailable with an error body.
  • CPU time exceeded: The V8 execution is interrupted. The client receives a 504 Gateway Timeout.
  • Wall-clock exceeded: The request is aborted. The client receives a 504 Gateway Timeout.
  • VFS quota exceeded: The fs write call throws an ENOSPC error. The isolate continues running.

These limits apply to the Thunder server process as a whole.

ResourceCLI flagEnv varDefaultDescription
Request body--max-request-body-sizeEDGE_RUNTIME_MAX_REQUEST_BODY_SIZE5 MiBMaximum size of an incoming request body. Requests exceeding this receive 413 Payload Too Large.
Response body--max-response-body-sizeEDGE_RUNTIME_MAX_RESPONSE_BODY_SIZE10 MiBMaximum size of a function response body. Responses exceeding this are truncated and the connection is closed.
ResourceCLI flagEnv varDefaultDescription
Max connections--max-connectionsEDGE_RUNTIME_MAX_CONNECTIONS10000Maximum concurrent TCP connections on the ingress listener. New connections beyond this are rejected with 503.
Rate limit--rate-limitEDGE_RUNTIME_RATE_LIMITUnlimitedMaximum requests per second across all connections. When exceeded, requests receive 429 Too Many Requests.

The isolate pool manages the lifecycle of V8 isolates across all deployed functions.

ResourceCLI flagEnv varDefaultDescription
Global max isolates--pool-global-max-isolatesEDGE_RUNTIME_POOL_GLOBAL_MAX_ISOLATES256Maximum number of live isolates across all functions.
Min free memory--pool-min-free-memory-mibEDGE_RUNTIME_POOL_MIN_FREE_MEMORY_MIBWhen free system memory drops below this threshold, the pool evicts idle isolates.
Pool enabled--pool-enabledEDGE_RUNTIME_POOL_ENABLEDtrueWhen disabled, a fresh isolate is created and destroyed for every request.

Per-function pool sizes (min and max isolates per function) are configured in the function manifest, not at the server level.


ResourceDefaultDescription
Max connections per isolate128Maximum number of concurrent outbound WebSocket connections from a single isolate.
Connect timeout30 sMaximum time to complete the WebSocket handshake.

WebSocket connections count toward the isolate’s wall-clock timeout. Long-lived WebSocket connections should account for this.


Thunder includes an adaptive egress connection manager that manages the file descriptor (FD) budget for outbound connections. It ensures that fetch(), WebSocket, and TCP connections do not exhaust the process FD limit.

The manager:

  • Tracks active outbound connections across all isolates.
  • Reserves FDs for the ingress listener and internal use.
  • Queues outbound connection attempts when the FD budget is saturated.
  • Reports FD utilisation as part of the scaling signal.

The FD budget is derived from the system ulimit -n minus a safety margin for internal operations.


ScenarioSuggested tuning
CPU-bound functions (image processing, crypto)Increase --cpu-time-limit-ms, keep --max-heap-mib at 128+.
I/O-bound functions (API aggregation)Default CPU is usually sufficient. Increase --wall-clock-timeout-ms if external calls are slow.
Memory-intensive functionsIncrease --max-heap-mib. Monitor heap usage via OTEL metrics.
High-traffic, low-latency functionsReduce --wall-clock-timeout-ms to fail fast. Increase --max-connections.
File-heavy functionsIncrease VFS quotas as needed, but stay within isolate memory budget.

Use the /_internal/health and /_internal/metrics endpoints (or OTEL export) to monitor resource consumption and tune limits based on real traffic patterns.