---
title: "Run web and worker processes apart · Agent Wranglers"
url: https://agentwranglers.se/playbook/scaling/stateless-app-servers/web-and-worker-processes
updated: 2026-10-21
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Run web and worker processes apart

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Stateless app servers](https://agentwranglers.se/playbook/scaling/stateless-app-servers.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers). Updated 2026-10-21.

- ID: SCL-10
- Level: Recommended
- Chapter: [Stateless app servers](https://agentwranglers.se/playbook/scaling/stateless-app-servers)
- Rule: Run request handling and background work as separate process types from the same build, so each scales on its own.
- Applies when: The project runs its own servers, virtual machines or containers.
- How: The Twelve-Factor App calls these process types, such as `web` and `worker`. A slow export then cannot take the CPU that pages need. You can also add workers without adding web servers. Give each type its own count, its own [limits on memory and processes](https://agentwranglers.se/playbook/operations/running-the-service/resource-limits) and its own [scale rule](https://agentwranglers.se/playbook/scaling/load-balancing-and-autoscaling/scale-on-saturation). Run scheduled jobs as a third type, once at a time as [Run each scheduled job once at a time](https://agentwranglers.se/playbook/scaling/background-jobs-and-queues/single-job-runs) says.
- Check: The deploy settings list web and worker as separate types with separate counts. Change the worker count on staging, and no web process restarts.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### YAML example

```yaml
# compose.yaml: one image, two process types for a made-up shop
services:
  web:
    image: registry.example.com/shop:1.42.0
    command: ["node", "server.js"]
    deploy: { replicas: 3, resources: { limits: { memory: 512M } } }
  worker:
    image: registry.example.com/shop:1.42.0
    command: ["node", "worker.js"]
    deploy: { replicas: 2, resources: { limits: { memory: 1G } } }
```

## Sources

- [The Twelve-Factor App, Concurrency](https://12factor.net/concurrency)

## Related rules

- [Set limits on memory and processes](https://agentwranglers.se/playbook/operations/running-the-service/resource-limits) in Operations
- [Scale on the resource that runs out](https://agentwranglers.se/playbook/scaling/load-balancing-and-autoscaling/scale-on-saturation) in Scaling
- [Run each scheduled job once at a time](https://agentwranglers.se/playbook/scaling/background-jobs-and-queues/single-job-runs) in Scaling

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/scaling/stateless-app-servers/web-and-worker-processes">Agent Wranglers scaling playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Start fast and warm up before taking traffic](https://agentwranglers.se/playbook/scaling/stateless-app-servers/fast-warm-start)
- Next: [Keep no state inside the app process](https://agentwranglers.se/playbook/scaling/stateless-app-servers/stateless-processes)
- [Stateless app servers](https://agentwranglers.se/playbook/scaling/stateless-app-servers)
