Doing asynchronous programming in PHP?
summary
Shows how to run PHP workers with RabbitMQ (AMQP) using the PECL amqp extension rather than a PHP-only library, and argues that publishing with non-blocking get plus a 200ms sleep loop outperforms consume callbacks. Covers practical fixes: intercept signals with pcntl so workers finish current jobs, use dead-letter queues with TTL retries for transient API failures, clear the Doctrine EntityManager to prevent memory leaks, tune Monolog bufferSize, and compares memory usage (Symfony full-stack workers ~50–60MB vs micro workers ~3–4MB) while using supervisor/upstart for monitoring.
AI-written summary · about
chapters (15)
- 0:00Async PHP intro
- 3:20Async programming benefits
- 5:07AMQP and RabbitMQ basics
- 10:07PHP to RabbitMQ
- 13:17Publish and consume messages
- 15:00Broker problems
- 17:45Graceful worker shutdown
- 20:12Memory leaks in consumers
- 22:17Retrying failed messages
- 24:44Doctrine memory management
- 27:11Monitoring workers
- 28:54Supervisor setup
- 30:17Slim vs full stack
- 32:09Tips and demos
- 33:53Q&A
