> ## Documentation Index
> Fetch the complete documentation index at: https://inframan.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Services and runtimes

> Web services, workers and jobs, and how Inframan decides whether a web service runs on Knative or as a Kubernetes Deployment.

Each entry under `services:` in `inframan.yaml` is a service: one container image, built from one `Dockerfile`, deployed as one unit. Its `type` decides how it runs.

## Service types

| `type` | Use it for | Receives traffic | Scales |
| - | - | - | - |
| `web` (default) | HTTP APIs and websites | Yes, on `port` | By requests in flight, by CPU, or fixed |
| `worker` | Queue consumers, schedulers, anything long-running without inbound traffic | No | Fixed at `min_replicas` |
| `job` | Work that runs to completion once per release, such as a data backfill | No | Runs once |

```yaml inframan.yaml theme={null}
services:
  web:
    port: 3000
  worker:
    type: worker
    start_command: node dist/worker.js
    scaling:
      type: "off"
      min_replicas: 2
  backfill:
    type: job
    start_command: node dist/backfill.js
```

> [!NOTE]
>
> A `job` runs on each release and is retried up to three times if it fails. It has no schedule: Inframan doesn't run cron jobs. For work that must happen before a release, such as a database migration, use a [pre-deploy step](https://inframan.mintlify.site/deploy/pipelines.md) instead.

## How a web service runs

A web service runs on one of two runtimes. Its `scaling.type` decides which:

| `scaling.type` | Runtime | What you get |
| - | - | - |
| `concurrency` | Knative | Scales on concurrent requests per replica, and to zero on non-production infrastructures. Needs the [Knative](https://inframan.mintlify.site/provision/add-ons/knative.md) add-on. |
| `hpa` | Kubernetes Deployment | A Horizontal Pod Autoscaler on CPU, and optionally memory, utilization. Never scales below one replica. |
| `"off"` | Kubernetes Deployment | A fixed number of replicas. |
| Not set | Knative if it's installed, otherwise a Deployment with `hpa` | |

Both runtimes run the same pod: the same image, environment, probes and resources. You can switch a service between them by changing `scaling.type` and deploying.

If a service asks for `concurrency` on an infrastructure without Knative, its release fails with `SCALING_TYPE_UNSUPPORTED`. Install Knative, or change the service to `hpa`.

See [Autoscaling](https://inframan.mintlify.site/optimize/autoscaling.md) for how each scaler behaves.

## One version per release

Every release runs each service as a new, separately named version, such as `api-v42`. With the default `blue-green` rollout, the previous version keeps running until traffic has moved to the new one, then it's removed. With `recreate`, it stops first. This is what makes [revisions, traffic splitting and rollback](https://inframan.mintlify.site/deploy/revisions.md) possible.

Each version has its own internal address, `http://api-v42-00001.<namespace>.svc.cluster.local`, on both runtimes. [Connections](https://inframan.mintlify.site/deploy/connections.md) between services use these addresses, so services always reach the version that shipped with them.

## Resources

Every replica gets requests and limits, whether you set them or not. On non-production infrastructures the defaults are:

| | CPU | Memory |
| - | - | - |
| Request | `100m` | `128Mi` |
| Limit | `500m` | `256Mi` |

Set your own under `resources` in [`inframan.yaml`](https://inframan.mintlify.site/deploy/inframan-yaml#resources). A replica that goes over its memory limit is restarted by Kubernetes.

## Shutting down

When a replica is stopped, it receives `SIGTERM` and has `termination_grace_seconds` to finish its work, 30 seconds by default, before it's killed. Give a worker that processes long jobs more time.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.