Hi,
We are currently in the process of gradually migrating our projects to Cloudflare Workers. Our plan was to complete the testing phase and then transition to the Paid plan before finalizing the production deployments. Throughout this process, we have encountered several errors; while we have resolved most of them, we remain concerned about a few recurring issues:
- Worker exceeded memory limit -> 2026-03-10 17:19:47.915 GMT+3
- Query Timeout -> 2026-03-10 16:55:25.213 GMT+3
- Connection lost: The server closed the connection. -> 2026-03-10 16:56:34.210 GMT+3
We need assistance on how to effectively minimize these occurrences. For our database, we are using a managed MariaDB service via Elestio. Following several support tickets, the Elestio team implemented the following configuration changes on the database server:
Database Configuration (Elestio MariaDB):
- max_connections: 500
- tcp_keepalive: time: 60, intvl: 10, probes: 6
- wait_timeout / interactive_timeout: 600
- connect_timeout: 30 seconds
- InnoDB buffer pool: 2 GB
- Connection backlog: 256
- Query Cache: Enabled (64 MB) for repeated reads
- Temp Table Size: Increased from 16 MB to 64 MB (previously 37% were spilling to disk)
- InnoDB Log File Size: 256 MB
- I/O Capacity: 1000 (SSD-optimized)
- innodb_flush_log_at_trx_commit: 2 (for better write performance)
- Network Timeouts: net_read: 60s, net_write: 120s
- Slow Query Logging: Enabled (threshold: 2s)
Despite these optimizations, we continued to receive Query Timeout and Connection Lost errors during our stress tests.
Upon auditing our code, we noticed that among the three endpoints we were testing, one performed two separate queries while the others performed only one. When we implemented caching in the middleware for the additional query in that specific endpoint, we finally achieved an error-free stress test result.