The problem is:
Direct database writes for execution logs in n8n create a significant performance bottleneck, limiting workflow throughput despite the number of workers and webhook instances.
Users must choose between having logs (with limited performance) or disabling logs entirely (losing crucial operational visibility).
The solution is:
Implement optional buffered logging to batch database writes, similar to how Nginx and other high-performance systems handle logs. This allows maintaining comprehensive logging while significantly improving throughput by reducing database I/O operations.
The idea is:
Implement an optional buffered logging system for execution logs (as a funtionality that can be enabled or disabled), to improve throughput while maintaining logging capabilities. The system would:
-
Buffer execution logs before writing to database:
- In-memory buffer with configurable size
- Configurable flush interval
- Optional Redis-based buffer for distributed setups
-
Configuration via environment variables:
DB_LOGGING_BUFFER_ENABLED=true
DB_LOGGING_BUFFER_SIZE=512k # Buffer size before flush
DB_LOGGING_FLUSH_INTERVAL=1m # Time-based flush interval
- Workflow-level configuration override:
My use case:
Running n8n in production on Kubernetes with high-throughput workflows where:
-
Current throughput is limited due to database logging overhead
-
Need to maintain execution logs for:
- Compliance requirements
- Debugging capabilities
- Performance monitoring
- Security auditing
-
Currently forced to choose between performance (disabling logs) or having logs (with limited throughput)
I think it would be beneficial to add this because:
-
Solves Critical Performance Issues:
- Reduces database write operations through batching
- Improves workflow execution throughput
- Reduces database connection pool pressure
- Maintains logging capabilities without performance penalty
-
Provides Flexibility:
- Configurable per workflow
- Different settings for webhook/worker/main processes
- Optional Redis support for distributed setups
-
Overall Features:
- Maintains compliance capabilities (logging, monitoring, etc.)
- Supports high-throughput scenarios
- No compromise between performance and logging
- Follows industry standard practices
Any resources to support this?
-
Current Performance Issue:
- Community discussion: N8N benchmarking throughput - max 30 req/s?
-
Similar Implementations:
- Nginx buffered logging: Module ngx_http_log_module
- Node.js Winston logger buffering: GitHub - winstonjs/winston: A logger for just about everything.
- Database write-behind logging patterns
-
Architecture Support:
- Works with n8n’s existing queue mode (Configuring queue mode | n8n Docs)
- Compatible with both standalone and distributed setups
- Optional Redis integration for distributed scenarios
The implementation could start with in-memory buffering and later add Redis support for distributed setups, providing a scalable solution that grows with users’ needs.