DEV Community

Naval Kishor Upadhyay
Naval Kishor Upadhyay

Posted on

12-Factor App Principle #6: Processes

Principle #6: Processes

Goal: Run the app as one or more stateless processes, with no data or state stored inside the processes themselves, so they can be started, stopped, and scaled at any time.


What It Means

  • Stateless: Processes don’t remember anything between requests — all data is stored in external services like databases or caches.
  • Share-nothing: Processes don’t share memory or files with each other.
  • Independent: Each process can be run, scaled, and restarted without affecting others.
  • Port binding: Processes expose services via a port so they can receive requests directly.

Why It Matters

  • Scalability: You can add more processes to handle more load without rewriting code.
  • Resilience: If one process fails, others keep running.
  • Flexibility: Easier to distribute workloads across different machines or containers.
  • Simplicity: Clear separation between compute (processes) and storage.

Example

An e-commerce site has separate processes for:

  • Handling web requests (web process)
  • Processing background jobs like sending emails (worker process)
  • Generating reports (reporting process)

All these processes store their data in a shared PostgreSQL database and Redis cache, never in local memory.

Top comments (0)