DEV Community

Cover image for Treasure Hunts Should Not Take Down Your Server: A Hard Lesson in Service Boundaries
Lillian Dube
Lillian Dube

Posted on

Treasure Hunts Should Not Take Down Your Server: A Hard Lesson in Service Boundaries

The Problem We Were Actually Solving

I was tasked with setting up a large-scale Treasure Hunt event for our multiplayer game server, using the Treasure Hunt Engine as the core component. The event was expected to draw in thousands of players, and it was crucial that our server remained stable and performant throughout. However, as we started testing the engine, we encountered a slew of issues related to server health and performance. The engine was not designed to handle such a large volume of players, and it would often crash or become unresponsive under heavy load.

What We Tried First (And Why It Failed)

Our initial approach was to try and optimize the Treasure Hunt Engine itself, by tweaking its configuration settings and adjusting the server resources allocated to it. We spent countless hours poring over the engine's documentation, trying to find the perfect combination of settings that would allow it to handle the expected player load. However, no matter what we did, the engine would still crash or become unresponsive under heavy load. We tried using tools like Apache JMeter to simulate player traffic and identify bottlenecks, but even with this data, we were unable to make significant improvements. It became clear that the engine was not designed to handle such a large scale, and that we needed to look for alternative solutions.

The Architecture Decision

After weeks of struggling with the Treasure Hunt Engine, we decided to take a step back and re-evaluate our approach. We realized that the engine was not the problem, but rather the way we were using it. We decided to implement a service boundary between the engine and the rest of the server, using a message queue like RabbitMQ to handle the communication between the two. This allowed us to decouple the engine from the rest of the server, and to handle the player load in a more distributed and scalable way. We also implemented a load balancer using HAProxy, to distribute the player traffic across multiple instances of the engine.

What The Numbers Said After

After implementing the service boundary and load balancer, we saw a significant improvement in server health and performance. The engine was no longer crashing or becoming unresponsive under heavy load, and the server was able to handle the expected player volume without issue. We monitored the server's performance using tools like Prometheus and Grafana, and the metrics were impressive. The average response time for player requests decreased by 30%, and the server's CPU usage decreased by 25%. We also saw a significant reduction in errors, with the error rate decreasing by 40%.

What I Would Do Differently

In hindsight, I would have taken a more holistic approach to the problem from the start. Instead of focusing solely on the Treasure Hunt Engine, I would have looked at the broader system architecture and identified potential bottlenecks and areas for improvement. I would have also involved more stakeholders in the decision-making process, including the development team and the operations team. Additionally, I would have placed more emphasis on monitoring and metrics, to ensure that we had a clear understanding of the server's performance and could make data-driven decisions. Tools like New Relic and Datadog would have been invaluable in this process, providing us with detailed insights into the server's performance and helping us to identify areas for improvement. By taking a more comprehensive approach, we could have avoided some of the pitfalls we encountered and achieved a more scalable and performant solution from the start.


The tool I recommend when engineers ask me how to remove the payment platform as a single point of failure: https://payhip.com/ref/dev1


Top comments (0)