Problem: web application slows down due to background tasks
Your application freezes when a user sends 1000 emails? PDF generation blocks the server response for 30 seconds? Clients leave because of slow loading? Typical picture in startups and enterprise: an HTTP request must wait for all operations to complete. The solution is to offload heavy tasks from the synchronous cycle to async workers via a message broker. RabbitMQ is an industrial broker on the AMQP protocol, handling tens of thousands of messages per second with latency under 100 microseconds. Over the years, our team has configured queues for over 70 projects: from online stores to fintech services. We deploy RabbitMQ turnkey for web applications in PHP, Node.js, Python, and Go — with full-stack integration and monitoring.
What we solve with queues
- Blocking operations — email sending, report generation, image recognition go to workers. Response time reduced by 80%; the user doesn't wait.
- Message loss — when a worker crashes, the message remains in the queue. Dead Letter Queue catches "broken" tasks.
- Scaling — add workers horizontally without changing code. Prefetch count (e.g., 3) regulates load.
Why RabbitMQ over a custom queue?
A custom queue on MySQL or Redis often loses to RabbitMQ on three parameters: delivery guarantees, routing flexibility, and monitoring. RabbitMQ uses the AMQP protocol — an industry standard with acknowledgments (ack/nack), dead-lettering, and transactions. Unlike Redis queues, RabbitMQ does not lose data on restart thanks to persistent storage. Flexible routing via topic exchange allows directing different task types into separate queues by routing key: emails.welcome → email queue, notifications.push → push queue. One exchange serves all task types without code duplication.
| Exchange type | Routing | Example use case |
|---|---|---|
| direct | Exact match on routing key | Critical tasks with high priority |
| topic | Patterns * and # |
Flexible distribution by type (emails.*) |
| fanout | All subscribers | Broadcast notifications |
| headers | By message headers | Complex logic based on metadata |
How to configure Dead Letter Queue for reliability?
DLQ is a queue for messages that failed processing after exhausting retries. Configure x-dead-letter-exchange and x-dead-letter-routing-key arguments when declaring the main queue. If a worker rejects a message (nack with requeue=false) or TTL is exceeded, the message moves to DLQ. There it can be analyzed and manually re-sent. We use DLQ in all projects — it's a mandatory reliability element. Also useful is x-message-ttl for expiring tasks.
More about cluster configuration for fault tolerance
For high availability, we deploy a cluster of 3 RabbitMQ nodes. Use queue mirroring policies (ha-mode: exactly, ha-params: 2). Then if one node fails, messages are not lost, and clients automatically reconnect via long AMQP connections. Configure health checks and alerts in Grafana/Slack. Failure detection time — under 5 seconds. The cluster handles up to 30,000 messages/sec with 99.99% uptime.
What's included in turnkey RabbitMQ setup
- Installation and configuration of RabbitMQ (Docker Compose or bare metal)
- Creation of exchanges, queues, bindings for your business logic
- Configuration of Dead Letter Queue and retry policies
- Integration with your code (PHP, Node.js, Python, Go)
- Monitoring via Management UI and alerts (Grafana + Slack)
- Documentation: topology diagram, queue descriptions, developer guide
- Team training: how to add new tasks
Producer and consumer implementation: PHP (php-amqplib) and Node.js (amqplib)
Here is working code for two popular languages. The producer publishes a message to an exchange with a routing key, the consumer listens to the queue and acknowledges processing.
// PHP: Publish message (shortened)
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;
class RabbitMQPublisher
{
private $channel;
public function __construct()
{
$this->channel = (new AMQPStreamConnection(
config('rabbitmq.host'), 5672,
config('rabbitmq.user'), config('rabbitmq.password'),
config('rabbitmq.vhost', '/')
))->channel();
$this->setup();
}
private function setup(): void
{
$this->channel->exchange_declare('myapp.exchange', 'topic',
durable: true, auto_delete: false);
$this->channel->queue_declare('myapp.emails', durable: true,
arguments: new \PhpAmqpLib\Wire\AMQPTable([
'x-dead-letter-exchange' => '',
'x-dead-letter-routing-key' => 'myapp.dlq',
'x-message-ttl' => 86400000,
]));
$this->channel->queue_bind('myapp.emails', 'myapp.exchange', 'emails.*');
}
public function publish(string $routingKey, array $payload): void
{
$msg = new AMQPMessage(json_encode($payload), [
'delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT,
'content_type' => 'application/json',
]);
$this->channel->basic_publish($msg, 'myapp.exchange', $routingKey);
}
}
$publisher = new RabbitMQPublisher();
$publisher->publish('emails.welcome', ['user_id' => 42, 'email' => '[email protected]']);
// Node.js: Consumer (shortened)
import amqp from 'amqplib';
async function consume() {
const conn = await amqp.connect({
hostname: process.env.RABBITMQ_HOST,
username: process.env.RABBITMQ_USER,
password: process.env.RABBITMQ_PASS,
vhost: process.env.RABBITMQ_VHOST,
});
const ch = await conn.createChannel();
await ch.prefetch(5);
await ch.consume('myapp.emails', async (msg) => {
if (!msg) return;
try {
const payload = JSON.parse(msg.content.toString());
// process email
await sendEmail(payload);
ch.ack(msg);
} catch (e) {
console.error(e);
ch.nack(msg, false, false); // send to DLQ
}
});
}
Integration with Laravel: easy path
Use package vladimir-yuldashev/laravel-queue-rabbitmq. Configure in .env and config/queue.php. Then work with standard Jobs — Laravel automatically publishes them to the RabbitMQ queue.
QUEUE_CONNECTION=rabbitmq
RABBITMQ_QUEUE=myapp.jobs
RABBITMQ_EXCHANGE=myapp.exchange
RABBITMQ_EXCHANGE_TYPE=topic
RABBITMQ_ROUTING_KEY=jobs.*
How we deploy RabbitMQ: Docker Compose and security
We use the official image rabbitmq:3.13-management-alpine. It includes Management UI on port 15672 — for real-time queue monitoring.
# docker-compose.yml
services:
rabbitmq:
image: rabbitmq:3.13-management-alpine
environment:
RABBITMQ_DEFAULT_USER: myapp
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD}
RABBITMQ_DEFAULT_VHOST: myapp
volumes:
- rabbitmq_data:/var/lib/rabbitmq
ports:
- "5672:5672" # AMQP
- "15672:15672" # Management UI
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "ping"]
interval: 10s
timeout: 5s
retries: 5
volumes:
rabbitmq_data:
Work stages: step-by-step plan
- Analysis — study your business logic, identify bottlenecks, design queue topology.
- Deployment — install RabbitMQ (Docker or bare metal), configure cluster for fault tolerance.
- Integration — write producers and consumers, connect DLQ, configure prefetch.
- Monitoring — set up Management UI, configure alerts in Slack/Telegram.
- Load testing — check throughput (typically up to 10,000 msg/s on a single node).
Estimated timelines and cost
| Task | Time | Average Cost |
|---|---|---|
| RabbitMQ + basic producer/consumer | 2–3 days | $500 |
| Laravel Queue integration | 1–2 days | $300 |
| Dead Letter Queue + monitoring | +1–2 days | $200 |
| HA RabbitMQ cluster (3 nodes) | 3–4 days | $1,200 |
Our setup reduces operational costs by 40% compared to manual configuration, and typical project cost starts from $800.
RabbitMQ vs Kafka: when to choose what?
RabbitMQ is 3x faster to set up than Kafka for small to medium web applications. RabbitMQ is better for web applications with different task types and flexible routing. Kafka is for data streams with high throughput (millions of events/sec) and long-term storage. In a typical web project, RabbitMQ is simpler to set up and maintain. According to the official RabbitMQ documentation, the broker provides latency under 100 µs at low load. We guarantee stable queue operation under load up to 10,000 messages/s without loss.
Our experience and guarantees
Over the years, we have configured queues for projects of various scales: from startups (1,000 messages/day) to enterprise (1M+ messages/day). Experience with PHP, Node.js, Python, Go. All projects undergo load testing and memory leak checks. We guarantee correct topology operation and no message loss under standard scenarios.
To assess your project, contact us — we will prepare a configuration within 1 day. Get a consultation on RabbitMQ integration for your application.







