@Endpoint function.
What runs where
The@Endpoint decorator marks functions for remote execution. Everything else runs locally.
Flash apps
When you build a Flash app: Development (flash dev):
- FastAPI server runs locally.
@Endpointfunctions run on Runpod workers.
flash deploy):
- Each endpoint configuration becomes a separate Serverless endpoint.
- All endpoints run on Runpod.
Execution flow
Here’s what happens when you call an@Endpoint function:
Endpoint naming
Flash identifies endpoints by theirname parameter:
- Same name, same config: Reuses the existing endpoint.
- Same name, different config: Updates the endpoint automatically.
- New name: Creates a new endpoint.
workers without creating a new endpoint—Flash detects the change and updates it.
Worker lifecycle
Workers scale up and down based on demand and your configuration.Worker states
A worker is billed only while it is Running. Idle means the worker has scaled down, not that it is waiting for work. See worker lifecycle.
Scaling behavior
- First job arrives → Scale to 1 worker (cold start).
- More jobs arrive while worker busy → Scale up to max workers.
- Jobs complete → Workers keep running and wait up to
idle_timeoutseconds for new jobs. They are billed while they wait. - No new jobs → Workers scale down to the minimum and billing stops for the ones that stopped.
Cold starts and warm starts
Understanding cold and warm starts helps you predict latency and set expectations.Cold start
A cold start occurs when no workers are available to handle your job, because:- You’re calling an endpoint for the first time.
- All workers have been scaled down after not processing requests for
idle_timeoutseconds. - All running workers are busy processing requests.
- Runpod provisions a new worker with your configured GPU/CPU.
- The worker image starts (dependencies are pre-installed during build).
- Your function executes.
When using
flash build or flash deploy, dependencies are pre-installed in the worker image, eliminating pip installation at request time. When running standalone scripts with @Endpoint functions outside of a Flash app, dependencies may be installed on the worker at request time.Warm start
A warm start occurs when a worker is already running and waiting for work:- Worker completed a previous job and is waiting for more work.
- Worker is within its
idle_timeoutperiod.
- Job is routed immediately to the waiting worker.
- Your function executes.
The relationship between configuration and starts
Yourworkers and idle_timeout settings directly affect cold start frequency:
workers=(0, n): Workers scale to zero when not processing. Every request after theidle_timeoutperiod triggers a cold start.workers=(1, n): At least one worker stays ready. First concurrent request is warm, additional requests may cold start.- Higher
idle_timeout: Workers stay running longer before scaling down, reducing cold starts for sporadic traffic.