SpringBoot + Drools in AKS

27 views
Skip to first unread message

Yeshwanth Ramesh

unread,
Jun 6, 2024, 9:50:56 AMJun 6
to Drools Usage
After transitioning our application from Docker to AKS, we encountered issues with rule execution consistency. Upon investigation, we discovered that when adding new rules via the API, the working memory of one pod which the request hit was being updated, resulting in inconsistent results across pods. When requesting other pods to execute the new rules, they were failing as the rule didn't get loaded into the working memory of other pods.
Can anyone suggest existing solutions or best practices for implementing a Drools application in AKS?

Ajay Chowdary Kandula

unread,
Jun 7, 2024, 8:08:36 AMJun 7
to drools...@googlegroups.com, Yeshwanth Ramesh
Maintaining consistency across multiple pods when using Drools in a Kubernetes environment like AKS can be challenging. Here are some potential solutions and best practices:

1. **Centralized Rule Repository**: Instead of adding rules dynamically via the API, consider storing your rules in a centralized repository (e.g., Git, database) and loading them during application startup. This ensures that all pods have the same set of rules loaded into their working memory. You can use Kubernetes ConfigMaps or Secrets to store and distribute the rules across pods.

2. **Rule Synchronization**: If you need to dynamically update rules, implement a rule synchronization mechanism across pods. One approach is to use a message queue (e.g., RabbitMQ, Kafka) or a distributed cache (e.g., Redis) to broadcast rule updates to all pods. Each pod can subscribe to the message queue or cache and update its working memory accordingly.

3. **Stateless Rule Execution**: Consider designing your Drools application to be stateless, where each request is processed independently without relying on a shared state across pods. This way, you can load the rules into the working memory for each request and discard the session after processing, ensuring consistency across pods.

4. **Sticky Sessions**: If your application requires stateful rule execution, you can use Kubernetes' sticky sessions feature to ensure that subsequent requests from the same client are routed to the same pod. This way, the client interacts with the same instance of the Drools engine, maintaining session state. However, this approach can lead to uneven load distribution across pods.

5. **External Rule Engine**: Instead of embedding Drools within your application pods, you could consider deploying a separate Drools engine service in Kubernetes. Your application pods would then communicate with this external rule engine service to execute rules, ensuring consistency across all pods.

6. **Monitoring and Alerting**: Implement monitoring and alerting mechanisms to detect inconsistencies in rule execution across pods. This can help you identify and address issues promptly.

The best solution depends on your specific requirements, such as the need for dynamic rule updates, stateful or stateless rule execution, and the complexity of your rule set. It's also essential to consider factors like performance, scalability, and fault tolerance when designing your Drools application for a Kubernetes environment.

Thanks and Regards!!!
Ajay C. Kandula


On Thu, Jun 6, 2024 at 9:50 AM Yeshwanth Ramesh <yesh.ra...@gmail.com> wrote:
After transitioning our application from Docker to AKS, we encountered issues with rule execution consistency. Upon investigation, we discovered that when adding new rules via the API, the working memory of one pod which the request hit was being updated, resulting in inconsistent results across pods. When requesting other pods to execute the new rules, they were failing as the rule didn't get loaded into the working memory of other pods.
Can anyone suggest existing solutions or best practices for implementing a Drools application in AKS?

--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/0558c6da-dccb-4b5f-9bd4-0cc90bda012cn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages