Release 1.12: Online Multiplayer

Published on 2021-02-09 by Stuart Spence

Today I'm incredibly excited to announce a test release of ChessCraft with online multiplayer! If you are a beta tester on Google Play, you'll soon get the latest version 1.12 which allows you to play your friends online.

Just like release 1.4 where you could share your designs, this release is also going to need lots of play-testing and feedback before I release to all ChessCraft players. If you play an online game during this test period, there's a chance I will make thousands of copies of you to load test my web services. Neat!

This newsletter is basically all about this new online play feature and its technical design. If that interests you, read on!

chesscraft screenshot

Room codes, not matchmaking

When you create an online room, you can give your friend a room code like "AB3" and now they can join and play you from anywhere in the world. Currently, there's no matchmaking or discovery. You need to communicate with your friend outside of the game.

I'd love to make matchmaking and discovery one day, but as you may know I have a full time job and ChessCraft is simply a hobby project I make for fun. Personally, I know that this simple online play is more than enough for me to have a blast playing with friends and family.

Baby Steps

Online play requires the existing feature of sharing your designs online. That's why sharing came first a year ago. Similarly, online matchmaking requires simple online multiplayer. So this simple online play is a step towards online matchmaking.

I'm enjoying building all this from scratch. This means it's lightweight, cheap, and fairly well built, however it also takes me more time.

Software development is all about breaking down your problem into smaller pieces. If I tried to make all multiplayer features at once it would be a mess. Instead I'm building systems that can be re-used for later. For example, when you create an online room with a board you've never shared online, it is automatically shared online behind the scenes. This happens seamlessly in 1.12 and it re-uses the exact same code I wrote for 1.4. Neat!


At the time of writing, I actually have little sense of how many concurrent ChessCraft games my servers can handle. I think it's a lot, but I don't know yet. I want to adjust to handle a spike in traffic, instead of grind to a halt. This is called load balancing.

When considering load balancing solutions, I had to consider many factors:

  • my time
  • my money
  • how quickly my system can scale up to handle more traffic (seconds, hours, days?)
  • how much my system can easily scale up
  • how easy is it to completely change to a different load balancing strategy
  • levels of automation

To help me find the right balance, my wife Alexandra patiently listened to me ramble about the problem even though she has little interest in software backends. Much like rubber duck debugging, this one-way conversation was helpful to me. Thanks Alex!

Today's Solution

Here's the balance I chose.

There is one central server and potentially many multiplayer servers. The central server runs the HTTPS website, design sharing, and core database. Whereas the multiplayer servers handle the high frequency online play traffic. Once an online game starts, the central server is never contacted again. For now there are no logins, no server-side move authentication, and no game outcome logging. This means the load and complexity is small. The two devices are in charge of running the game, and the multiplayer servers simply relay messages.

Currently when you ask the central server for its list of available multiplayer servers it returns... itself. So right now, the central server is also a multiplayer server. They share the same code base. Later, the central server might only be a central server, with a different one or many multiplayer servers. I update the list manually. That means that today, I can keep my infrastructure costs to a minimum, but I still have a plan to manually scale quickly if I need to.

The overall bottleneck is probably how many designs can be uploaded/downloaded at once on the central MongoDB database. That's a lot.

This solution is low cost, low time cost, and scales up/down manually in minutes, however I'll need to do a lot more work if I later need proper load balancing tools and automation.

Prometheus and Grafana Monitoring

During this 1.12 beta test period I will be monitoring performance using the FOSS monitoring platforms Prometheus and Grafana. I also use these tools for my full time job. That's one of many great things about open source software; at work I learn skills to help with my hobby projects, and my hobby projects make me better at my job. Win win!

If my servers start to struggle, I'm considering an automatic queue system. For example: "There are 623 people ahead of you in line to create a game. Please wait." This gives me buffer time to consider adding more capacity. We'll see!

Not Multiplayer

Oh right, 1.12 isn't just about online multiplayer. There are also many bug fixes, UI improvements, and new piece sprites (mostly thanks to the ChessCraft community). You can also turn off the visual changes for special days of the year.


Let me know what features you'd like next. I have plenty of ideas - tho I prioritize requests if lots of people ask.

Thanks so much for reading!

white griffin sprite