AITeky Learn

AiTeky Original Interactive Learning & Practice Intermediate

Go: shared counters, worker pools and cancellation

See how two goroutines updating one counter can lose updates and how a lock or a channel fixes it, how a pool of workers turns a queue of jobs into throughput, and how forgotten cancellation leaves goroutines piling up.

Go is a language built for networked services that do many things at once. Its goroutines are very cheap lightweight tasks, and its channels let them pass messages to each other. That makes concurrency easy to start, and easy to get wrong in three classic ways: races on shared data, workers and queues sized badly, and goroutines that never stop.

This course models those ideas with small Python programs you can run in your browser. Python stands in for Go: the code is not Go, and it is deterministic (we choose the order in which steps interleave, so the results are repeatable), but the behaviour it shows is real. Check the Go documentation for exact syntax and the race detector. All numbers are made up.

  • Learn lessons explain one idea at a time and let you run it.
  • Industry ready lessons decide and justify, and end with interview questions.

No Go experience is assumed. Basic Python helps.

Locked. Sign up free

Learn

Understand each idea with everyday examples. No coding background needed.

  1. 00 25 min 🔒 AiTeky Pass Start here: doing several things at once Picture a kitchen with several cooks, see why they must not write on the same notepad at the same moment, and learn what a goroutine and a channel are for.
  2. 01 30 min Free sample 🔒 AiTeky Pass Two workers, one counter Model two tasks that each add one to a shared counter by reading it, adding, and writing back, list every way their steps can interleave, see which orders lose an update, and fix it by making the read-add-write a single protected step.
  3. 02 30 min 🔒 AiTeky Pass A pool of workers and a queue Simulate a queue of jobs served by a fixed number of workers, find how completion time and idle time change with the number of workers, see where extra workers stop helping, and see what a forgotten channel close does to workers that wait forever.

Industry ready

Real problems from real jobs, and the questions interviewers ask about them.

  1. 03 35 min 🔒 AiTeky Pass On the job: the service that leaked goroutines A Go service's memory climbs steadily and its goroutine count grows into the hundreds of thousands. Model request handlers that call a slow dependency without a deadline, count the goroutines left waiting, compare four fixes (a context with a timeout, a bounded worker pool, a buffered result channel, restarting) by effect and risk, choose, and write the incident note.

We use essential cookies to run the site. With your permission we also set one anonymous ID to count unique visitors, and analytics cookies to see which pages help learners. Cookie notice

Join AiTeky Learn. It's free.

Create a free account to track your progress, save items for later and get study suggestions.

Sign up free Log in