Standby mode
Serve HTTP from a warm Actor container, with autoscaling, billing, and errors.
Standby mode lets an Actor run as an always-on HTTP service. Instead of starting a fresh run for every request, the platform keeps a warm container alive and forwards your HTTP requests to it. It suits real-time APIs, on-demand scraping endpoints, and webhook receivers.
How it works
When you send an HTTP request to a standby-enabled Actor URL, Scrape.ly:
- Finds the Actor by
username/actorName(the username is case-insensitive). - Checks access: the Actor must be public, or yours.
- Checks that standby mode is enabled.
- Picks one of your standby runs of that Actor, or starts a new one (an Actor with a shared pool uses a run of its pool instead). If the run is still starting (for example, another request just started it), Scrape.ly waits up to 5 minutes for it to become ready.
- Checks your effective balance (balance minus credits reserved by other running jobs).
- Forwards the request (method, path, query, headers, and body) to the container's web server.
Standby runs belong to the caller. Each user who calls a standby Actor gets their own runs, billed to their own account; your requests never go to another user's container. Some Actors maintained by Scrape.ly work differently and serve every caller from one shared pool: see Shared pool.
A standby run stays alive while requests keep arriving, and stops after it has been idle for the Actor's idle timeout (5 minutes by default). Each request resets the idle timer.
The platform does not start an HTTP server for you. Your Actor process must listen on the web-server port (ACTOR_WEB_SERVER_PORT, 4321). If nothing is listening, requests fail because the container is not ready.
Endpoints
Authentication is always required, sent in the Authorization: Bearer header. All HTTP methods are accepted (GET, POST, PUT, PATCH, DELETE, HEAD, and others).
/v2/{username}/{actorName}/v2/{username}/{actorName}/v2/{username}/{actorName}/{path}/v2/{username}/{actorName}/{path}Both the Actor root and any subpath are forwarded. The subpath and query string are passed to the Actor's web server as they are.
curl "https://api.scrape.ly/v2/jane/my-api" \
-H "Authorization: Bearer $SCRAPELY_TOKEN"
curl -X POST "https://api.scrape.ly/v2/jane/my-api/scrape?url=https://example.com" \
-H "Authorization: Bearer $SCRAPELY_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "depth": 1 }'| Path param | Type | Description |
|---|---|---|
username | string | The Actor owner's username (case-insensitive). |
actorName | string | Actor name. |
path | string | Optional. Forwarded to the Actor's HTTP server. |
The response is whatever the Actor returns: status code, headers, and body are passed through. The one exception is a 502 or 504 from the Actor, which arrives as 503 with the Actor's headers and body and X-Scrapely-Status: 502 or 504 (see Errors).
Before forwarding, the platform removes your credentials: Authorization, Proxy-Authorization, Cookie, and every X-Scrapely-* header are stripped, so the Actor never sees your API token. If your Actor needs its own authentication, use a different header or a query parameter.
These URLs share the /v2 namespace with the rest of the API, and the standby route is matched last. A username or Actor name that collides with an API path (for example /v2/actors/...) is handled by that API route instead.
Enabling standby mode
Enable standby in the Actor's settings in the dashboard, or set actorStandby with the Update Actor endpoint. Requests to an Actor that exists but doesn't have standby enabled return 400 standby-not-enabled.
actorStandby field | Default | Description |
|---|---|---|
isEnabled | false | Turns standby mode on. |
build | latest | Build tag or number that standby runs use. It must be a successful build. Other users' standby runs use the User Build when it's set. |
memoryMbytes | 2048 | Memory for each standby run. |
idleTimeoutSecs | 300 | Seconds without requests before a standby run stops, the last run too; the next request starts a new one. |
desiredRequestsPerActorRun | 100 | Requests a run handles at the same time before another run is started. |
maxRequestsPerActorRun | none | Hard cap on requests a run handles at the same time. Between the desired value and the max, a run still takes requests while another run starts. |
Standby runs have no run timeout; the idle timeout ends them.
Full-permission Actors need approval before your first standby request starts a run. Otherwise the request returns 403 full-permission-actor-not-approved.
Readiness
A GET or HEAD request to the Actor root that carries an x-scrapely-standby-readiness-probe (or x-apify-container-server-readiness-probe) header is answered by the platform itself with 200 and { "status": "ready", "timestamp": "..." }. It is not forwarded and doesn't start a run.
For real traffic, your Actor still has to bind the web-server port. See Standby mode in the JavaScript SDK for how to read the port and start a server.
Shared pool
Some Actors maintained by Scrape.ly keep one shared pool of standby runs for all callers. The Actor's owner runs the pool and keeps at least one run warm, so you don't wait for a container to start. You call these Actors the same way, with the same URLs and your own token.
Each request you send is recorded as a run in your account, the request run:
| Request run | Details |
|---|---|
| Origin | STANDBY |
| Storage | Its own default dataset and key-value store. The Actor writes the request's results there. |
| Status | RUNNING while the request is forwarded. Then SUCCEEDED, FAILED when the response status is 400 or higher, or ABORTED when you close the connection before the answer (or abort the run). |
| Log | The request line and how it ended. |
| Limits | It doesn't take one of your concurrent run slots. |
The request run starts like any run. If your balance can't cover it, the request returns 402 payment-required, as Start a run does.
When the pool's container fails before it answers (it refuses or drops the connection, or its server is gone), Scrape.ly sends the request to another run of the pool, up to 3 sends in all, with the same request run. A timeout (504 container-timeout) is not retried, and neither is a request the container already answered. If every send fails, you get the error of the last one.
Billing
Standby runs are billed to the caller like normal runs: compute time while the container is alive, plus platform usage. Requests are rejected with 402 insufficient-funds if your effective balance is zero or negative.
On an Actor with a shared pool, you pay per request run: the Actor's own events for that request (for example, each result) plus browser usage for any browser session it opens for your request. You never pay compute, idle time, or an Actor start fee.
Errors
| Status | Type | Meaning |
|---|---|---|
| 400 | standby-not-enabled | The Actor exists but standby mode is off. |
| 400 | actor-not-available | Someone else's Actor has no build you can run right now. |
| 401 | token-not-provided / token-not-valid | Missing or invalid Authorization header. |
| 402 | insufficient-funds | Effective balance is zero or negative. |
| 403 | full-permission-actor-not-approved | The Actor needs full permissions and you haven't approved it. |
| 403 | actor-requires-paid-plan | The Actor runs on paid plans only and your account is on the Free plan. No run is started. |
| 404 | record-or-token-not-found | Unknown username/actorName, or someone else's private Actor. |
| 500 | standby-error | An unexpected error while starting or reaching the standby run. Retry. |
| 503 | proxy-error | The request could not be forwarded to the container. Sent with X-Scrapely-Status: 502. |
| 503 | standby-timeout | A new standby run did not become ready within 5 minutes. |
| 503 | standby-not-ready | An existing standby run that was still starting did not become ready within 5 minutes. |
| 503 | standby-run-ended | The standby run ended (for example, it crashed on start) before it could take the request. error.data has runId and status. Retry, and check the run's log if it repeats. |
| 503 | container-unavailable | The standby run's web server refused the connection, for example because it stopped. Retry. |
| 503 | container-owner-unavailable | The server hosting the container cannot be reached. Retry. |
| 503 | container-timeout | The Actor did not respond within 5 minutes. Sent with X-Scrapely-Status: 504. The Actor may still have done the work, so don't resend a request that changes something unless it's safe to repeat. |
When a standby run can't start for a reason on your account, such as your own Actor having no successful build, too little credit, or your run or memory limits, the request returns the same status and type as Start a run, for example 402 payment-required or 429 concurrency-limit-exceeded.
Related
- Standby mode in the JavaScript SDK: writing an Actor that serves HTTP
- Actors API: Actor settings, builds, and permission approvals