DEV Community

Cover image for Why I Had to Rewrite the Rules for Our Treasure Hunt Engine in Production
Lisa Zulu
Lisa Zulu

Posted on

Why I Had to Rewrite the Rules for Our Treasure Hunt Engine in Production

The Problem We Were Actually Solving

I was tasked with deploying our treasure hunt engine into production, and from the outset, it was clear that this was not going to be a straightforward process. The engine, which was designed to generate puzzles and challenges for users, relied heavily on a complex interplay of natural language processing and machine learning algorithms. As the operator responsible for ensuring the system's reliability and performance, I quickly realized that the parameters that mattered most were not the ones that the development team had focused on. Specifically, the latency tradeoffs and hallucination rates of our ML models were having a significant impact on the user experience, and it was up to me to identify and address these issues.

What We Tried First (And Why It Failed)

Initially, we tried to simply port the development team's code into production, with minimal modifications. However, this approach quickly proved to be inadequate. The model's hallucination rate, which refers to the frequency with which it generates incorrect or nonsensical output, was alarmingly high, resulting in a poor user experience. Furthermore, the latency of the system was unacceptable, with some requests taking upwards of 10 seconds to process. We tried to address these issues by tweaking the model's parameters and adjusting the computational resources allocated to it, but these efforts were ultimately unsuccessful. It became clear that a more fundamental rethinking of the system's architecture was needed.

The Architecture Decision

After much discussion and analysis, we decided to implement a hybrid approach, combining the strengths of both rule-based and machine learning-based systems. We would use a rule-based system to generate the initial puzzle structures, and then leverage machine learning to add a layer of complexity and variability to the challenges. This approach allowed us to significantly reduce the hallucination rate and latency of the system, while also improving its overall flexibility and adaptability. We also made the decision to use a messaging queue, such as Apache Kafka, to handle the flow of data between the different components of the system, which helped to improve its scalability and reliability.

What The Numbers Said After

Once the new architecture was in place, we saw a significant improvement in the system's performance. The hallucination rate decreased from 25% to less than 5%, and the average latency dropped from 10 seconds to under 1 second. These numbers were a testament to the effectiveness of our new approach, and they had a direct impact on the user experience. We also saw a significant reduction in the number of support requests and complaints related to the treasure hunt engine, which was a key metric for us. In terms of specific metrics, we were able to achieve a throughput of 100 requests per second, with a 99.9% uptime rate over a period of several months.

What I Would Do Differently

In retrospect, I would have liked to have done more thorough testing and validation of the system before deploying it into production. While we did conduct some testing, it was not exhaustive, and we ended up discovering some issues once the system was live. I would also have liked to have had more direct involvement from the development team in the deployment and operationalization of the system. Their expertise and knowledge of the codebase would have been invaluable in helping us to identify and address issues more quickly. Additionally, I would have liked to have used more advanced monitoring and logging tools, such as Prometheus and Grafana, to get better visibility into the system's performance and behavior. These tools would have allowed us to identify and respond to issues more quickly, and would have provided us with more detailed insights into the system's behavior over time.

Top comments (0)