# Configuration and sizing

## Settings (environment variables)

| Variable | Default | Meaning |
|---|---|---|
| `WITHOUTBG_MAX_INFERENCE_SIDE` | `1024` | Long side (px) the matte is estimated at; it is resized back to the original size. Raise up to `4096` for finer edges on large photos, at more CPU time and memory. |
| `WITHOUTBG_ORT_THREADS` | all cores | Caps ONNX Runtime threads. Set it when several containers or other services share a server. |

```bash
docker run -d -p 8000:8000 -e WITHOUTBG_MAX_INFERENCE_SIDE=2048 -e WITHOUTBG_ORT_THREADS=4 "$IMAGE"
```

The container listens on port 8000 and runs as a non-root user. It needs no volumes
and no outbound network.

## Server sizing

| | Minimum | Recommended |
|---|---|---|
| CPU | 4 cores, x86_64 | 8+ cores |
| RAM | 8 GB | 16 GB (a container peaks at about 5.5 GB) |
| Disk | 5 GB free | |
| GPU | not needed | |

Latency depends on the CPU, the image and `WITHOUTBG_MAX_INFERENCE_SIDE`. Measure on
your own hardware with a sample of your images before sizing a fleet.

## Scaling

One container processes one image at a time and queues the rest. For more throughput,
run more containers (each with `WITHOUTBG_ORT_THREADS` set to its share of the cores)
or more servers behind a load balancer. Use `GET /ready` as the load balancer's
health check.

## Reverse proxy

The service has no TLS or authentication of its own. In front of it, set TLS, your
authentication, a request body limit (25 MB suits most photos) and a timeout of at
least 120 s for large images.
