# Failures and scaling

> What happens when each part fails, and how Run grows with traffic.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://run.docs.sypnia.com/architecture/failures-and-scaling/

For agents: Run failures: failed build (production untouched), failed health check (resources removed, production untouched), API/DB outage (apps keep serving; no deploys), deployer step retries (idempotent, FIFO per app), lost Git webhook (polling fallback), certificate pending, Lambda regional issue (static cache keeps serving), Fargate task crash (replaced, unhealthy taken out of LB), DLQ pages on-call. Scaling: CloudFront for static, Lambda per request up to max_instances (min_instances avoids cold starts), Fargate autoscaling on CPU/requests, builds parallel up to plan concurrency then queued, control plane stateless proportional to deploys.

## When something fails

| What fails                     | Effect                             | What Run does                                                                                                       |
| ------------------------------ | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| A build                        | the deploy is `failed`             | production is untouched; the error and the last log lines are reported to the CLI, the pull request and the console |
| A deploy's health check        | the deploy is `failed`             | resources of that deploy are removed after a grace period; production is untouched                                  |
| The Run API or its database    | no new deploys or releases         | apps keep serving: the data plane does not call the control plane                                                   |
| A step of the deployer         | the step is retried from the queue | deploy steps are idempotent and per app in order (FIFO); after retries the deploy is marked `failed`                |
| A Git webhook is lost          | a push is not seen                 | Run also polls connected repositories every few minutes and deploys what it missed                                  |
| A certificate cannot be issued | the domain stays `pending`         | the app keeps answering at its other addresses; the console shows the missing record                                |
| A Lambda region problem        | requests to dynamic paths fail     | static paths keep being served from CloudFront's cache; Run reports the incident                                    |
| A Fargate task crashes         | ECS starts a new one               | the load balancer stops sending traffic to it while it is unhealthy                                                 |

Messages that fail every retry go to a dead-letter queue that pages the on-call engineer in Sypnia Cloud; nothing is dropped silently.

## Scaling

- **Static files** scale with CloudFront; nothing to do.
- **Lambda** scales per request up to the function's `max_instances` (or the cell's quota). `min_instances` removes cold starts at a cost.
- **Fargate** services scale between `min_instances` and `max_instances` on CPU and request count.
- **Builds** run in parallel up to the plan's concurrent builds; extra builds wait in the queue in order.
- **The control plane** is stateless Lambda over Postgres; its load is proportional to deploys, not to your visitors.
