Picnic works smarter, not harder, with a RabbitMQ-powered Rule Engine, part 2

In the first part of this series, we explored the infrastructure of online grocery giant Picnic and how RabbitMQ became the core of its event-driven architecture. This section dives deeper into a specific example of how Picnic utilizes RabbitMQ within its operations.

With Picnic’s rapid expansion came an increased demand for agility and efficiency in its business logic implementation. Before, requests for new features or automations had to go through engineering teams, such as sending a customer email after a poor shopping experience. This led to lengthy development cycles, as tech teams had to prioritize features, scope solutions, and fit them into a roadmap, often taking months before deployment.

The solution? Enabling analysts and business teams to define and implement rules, without developer intervention. This required a robust platform capable of real-time processing events, connecting services dynamically, and executing rules based on predefined conditions.

The solution: A rule engine powered by RabbitMQ

Picnic’s engineering team developed the Rule Engine, a platform that allows business users to create and manage workflows based on system-generated events. The Rule Engine listens to RabbitMQ messages and enables analysts to define business logic using familiar languages such as JavaScript and Python.

How it works:

  1. Various services across Picnic’s ecosystem emit events, such as "order placed," "delivery completed," or "customer left a poor rating."
  2. These events are published to RabbitMQ, ensuring reliable, asynchronous message delivery.
  3. The Rule Engine subscribes to RabbitMQ queues and evaluates incoming events against the rules defined by the business teams.
  4. matching Rule maps an event to one of a curated set of actions that the Picnic backend can perform, such as sending an email, issuing a voucher, or adjusting inventory.
  5. Outcomes are measured so business teams can evaluate their rules and iterate fast without having to involve the development teams.

Asynchronous processing & fault tolerance

By leveraging RabbitMQ, Picnic achieves event-driven, decoupled communication between services. This prevents system failures from cascading and enables services to handle varying workloads without disruption.

With CloudAMQP managing the infrastructure, Picnic’s engineers can focus on optimizing the Rule Engine rather than maintaining messaging infrastructure. Business teams can roll out experiments and optimizations in real-time, significantly reducing time to market.

Real-world impact: A/B testing for enhanced customer experience

One real-world application of the Rule Engine is customer engagement optimization. For example, Picnic wanted to test whether including a physical

  1. Analysts defined a rule in the system: If order = first order, then add a booklet.
  2. The Rule Engine listens for the "order placed" event via RabbitMQ.
  3. When triggered, the system enriched the delivery order by adding the booklet.
  4. Data was collected and analyzed in a Snowflake data warehouse to measure impact.

Thanks to RabbitMQ’s reliability, Picnic could implement, test, and optimize this campaign with minimal engineering involvement.

Lessons Learned & Future Plans

While RabbitMQ has proven to be a robust backbone for Picnic’s event-driven architecture, the team has learned valuable lessons along the way:

  • Observability is key: Unexpected message volumes can impact performance, so proactive monitoring is crucial.
  • Handling race conditions: Messages arriving out of order require careful design to ensure consistency.
  • Balancing synchronous & asynchronous actions: While events are best handled asynchronously, some operations require synchronous calls for immediate feedback.

Conclusion: The Power of CloudAMQP & RabbitMQ

Picnic’s success story highlights how RabbitMQ, paired with CloudAMQP’s managed services, enables businesses to build flexible, scalable, and efficient event-driven architectures. Picnic has accelerated innovation by decoupling services and empowering business teams while maintaining reliability and performance.

CloudAMQP - industry leading RabbitMQ as a service

Start your managed cluster today. CloudAMQP is 100% free to try.

13,000+ users including these smart companies