Workflow Engine: The Conductor for Your Business Logic
A workflow engine conducts your business logic, ensuring complex tasks run in the right order. It's for multi-step processes like order fulfillment or data pipelines. The footgun is building one from scratch—you'll poorly reinvent state management and retries.
WHY IT EXISTS: Complex business processes often involve multiple steps spread across different services. Managing this sequence, handling failures, and knowing the current state of a process is incredibly difficult. Ad-hoc solutions using database flags and message queues quickly become brittle, untestable, and impossible to debug.
THE MENTAL MODEL: Think of a workflow engine as an orchestra conductor for your application's business logic. It doesn't perform the tasks itself (the services are the musicians), but it tells each service when to act, what to do next, and how to handle errors, ensuring the entire process plays out correctly from start to finish.
HOW IT WORKS: A workflow engine's core is a durable persistence layer, typically a database. You define a workflow as a sequence of steps. When a workflow starts, the engine writes its initial state to the database. It then dispatches the first task to a worker. When the worker finishes, it reports back. The engine records the result, updates the workflow's state in the database, and determines the next step. Because the state is durably stored, workflows can be paused, resumed, and survive server restarts.
WHEN TO USE IT: Use a workflow engine for any stateful, multi-step process that needs to be reliable. This includes processes that are long-running (hours or days), require retries with backoff, involve branching logic, or need to wait for external events or human input. Good examples are data processing pipelines (ETL), CI/CD automation, and user onboarding sequences.
WHEN NOT TO USE IT: A workflow engine is overkill for simple, stateless tasks or synchronous request/response patterns. If a process is very simple, runs inside a single service, and can be managed with a database transaction, you don't need a workflow engine. It's a tool for coordinating distributed, asynchronous work, not for low-latency RPC.
ONE CANONICAL EXAMPLE: An e-commerce order fulfillment process. An order kicks off a workflow with these steps: first, charge the credit card; second, if successful, decrement inventory; third, send a request to the shipping service; fourth, wait for a tracking number; fifth, email the customer. The engine manages the state, retries a failed payment, and can wait days for the shipping service to respond, all while providing visibility into where each order is in the process.
Read the original → en.wikipedia.org
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.