Overview
PyWorkflow includes built-in safeguards to prevent runaway workflows from consuming excessive resources. These limits help ensure system stability and predictable behavior.Event History Limits
Since PyWorkflow uses event sourcing, every workflow action is recorded as an event. To prevent unbounded growth and memory issues, there are limits on the number of events a workflow can generate.Soft Limit (Warning)
When a workflow reaches 10,000 events, PyWorkflow logs a warning:
Hard Limit (Failure)
When a workflow reaches 50,000 events, it is terminated with an
EventLimitExceededError:
Why These Limits Exist
- Memory Protection: Each event consumes memory. Unbounded event growth can exhaust system resources.
- Replay Performance: When workflows resume, all events are replayed. Large event logs slow down resumption.
- Storage Costs: Events are persisted to storage. Excessive events increase storage requirements.
- Bug Detection: Hitting limits often indicates bugs like infinite loops or improper workflow design.
Best Practices
Configuring Limits
If you must change the limits:Configuration Options
Transient Mode
Event limits only apply to durable workflows. Transient workflows (withdurable=False) do not record events and are not subject to these limits.
Transient workflows sacrifice durability for performance. They cannot be resumed after crashes or restarts.
Monitoring Event Counts
You can monitor event counts using the storage backend:Handling Limit Errors
When the hard limit is reached, anEventLimitExceededError is raised. This error inherits from FatalError, meaning it will not be retried.
Next Steps
Events
Learn how event sourcing works in PyWorkflow.
Configuration
See all available configuration options.