← Workshop

project · September 2024

Concurrent order processing in Go

A simulated shop where many people order at once, kept correct with goroutines and mutexes.

stack
Go, PostgreSQL

An e-commerce order system in miniature: lots of people place orders at the same time, and the system has to process them all without data races.

On the workbench

  • GoroutinesEach incoming order is handled concurrently, the way a real shop sees orders arrive.
  • MutexesGuard the shared inventory so two orders never sell the same last item.
  • PostgreSQLStores users, the product inventory and the order records.

Build log

  1. Sep 2024 My second Go project, built to get a real feel for the language and its concurrency.

What it taught me

  • Concurrency is easy to start and hard to get right: the shared inventory is where the bugs live.

Swipe, or tap the time before or after