Golang Dojo Project II - Distributed Counter

Introduction

I recently took a stab at a scalable distributed counter implementation. The inspiration comes from an common System Design interview question: “Design a distributed counter that can handle millions of events per second and provide near real-time read access to the current count.”

I read some about it in theory and design interview questions, but I never actually see it in action. Thanks to the advance of AI, a lot of the implementation burden can be handed off to an AI agent, while I focus more on the overall design.

So now I added it to the Golang Dojo project as I thought it could be a fun and education project to deepen my understanding of distributed systems, and also to explore how AI can assist in such process.

Source code is at: https://github.com/hxy9243/go-dojo/tree/main/src/counter

Read More

Golang Channel Idioms

While learning Golang, I was fascinated with the power Golang’s goroutines and channels. Channel is a powerful tool to tackle synchronization problems in asynchronous programs. It acts as a bridge between async goroutines and can describe some complicated logic expressively. Together they can be powerful weapons in building async applications. On the other hand, when misused, they can be a nightmare to debug.

Here I’ve summarized a few of the valuable idioms of using Golang routines from multiple references as well as my own experience. They can serve as a helpful toolbox that comes in handy for similar problems. So that you don’t have to design them from scratch, which might help you avoid synchronization errors.

Read More