# Scaling

Source: https://frameleaf.app/docs/admin/scaling/

The Frameleaf server is built so that several copies can run side by side. Put a gaming PC to work on transcoding and thumbnails, or spread the load across a small cluster, then hand the hardware back whenever you need it.

Most homes never need this. One server with the defaults handles a family library, and there are easier ways to get more done first:

- **Raise how much runs at once.** One container already runs several background jobs together. See [Concurrency](https://frameleaf.app/docs/admin/jobs/#concurrency), or set **Jobs at once** and **Thumbnail workers** on Manager's [Containers](https://frameleaf.app/docs/admin/manager/#suggested-for-this-server) page, which suggests values for your server's cores and memory.
- **Use a graphics card.** See [Hardware acceleration](https://frameleaf.app/docs/admin/hardware-acceleration/).
- **Lend another computer.** A gaming PC or laptop can take on the heavy AI work without running a second copy of the server. See [Workers and where jobs run](https://frameleaf.app/docs/admin/workers/) and [Frameleaf Desktop](https://frameleaf.app/docs/apps/desktop/).
- **Move the database and thumbnails to a fast drive.** See [Move data to another drive](https://frameleaf.app/docs/admin/move-data-to-another-drive/).

Running several copies of the server is for manual Docker Compose installations. Manager looks after one set of containers on one server.

The one requirement is that every copy uses the same shared infrastructure:

- the same PostgreSQL database, with the same database settings on every copy. Background queues live in PostgreSQL too, so there's no Redis to share
- the same files, mounted at the same path in every container

Each machine needs secure access to the shared database and media mounts. Keep the PostgreSQL data directory on local disk, even when your media is on a network share. The exact steps depend on your own infrastructure, so this works best if you're comfortable managing it.

## Background workers only

Each server container runs three workers: `api` for the web app and phone apps, `microservices` for background jobs, and `edge` for remote access. If you're adding machines only to get through background work faster, turn off the API on them with `FRAMELEAF_WORKERS_EXCLUDE=api`; the edge worker then stays off too. See [Split the server into containers](https://frameleaf.app/docs/admin/jobs/#split-the-server-into-containers).

Machine learning scales separately: run more machine learning containers and put a load balancer in front of them. See [Remote machine learning](https://frameleaf.app/docs/admin/remote-machine-learning/#several-machine-learning-computers) and [Workers and where jobs run](https://frameleaf.app/docs/admin/workers/).

## Scaling down

You can scale down just as easily. All state lives in PostgreSQL and the file system, so it's safe to stop a server container, for example to free your GPU for a game. As long as one container runs the API worker, you can still browse Frameleaf, and jobs wait until a worker is available to process them.

When a container stops, running jobs get a short grace period and then go back to waiting. See [Stopping the server](https://frameleaf.app/docs/admin/jobs/#stopping-the-server).
