This is an old revision of the document!
1️⃣ Worker Pool with Goroutines and Channels Problem
Write a program that:
Takes a list of jobs (integers).
Starts N worker goroutines to process the jobs concurrently.
Each job simulates work using time.Sleep and returns jobID * 2.
Collects and prints results safely (no data races).
What this tests
Goroutines and channels
sync.WaitGroup
Concurrency design (worker pool pattern)
Senior extensions
Add context.Context to support cancellation
Handle job timeouts
Graceful shutdown
📘 Notes
Worker pool /ˈwɜːrkər puːl/: a fixed number of workers processing tasks from a queue
Data race /ˈdeɪtə reɪs/: concurrent access to shared data without synchronization
2️⃣ Rate Limiter (Token Bucket) Problem
Implement a rate limiter that:
Allows at most X requests per second
Blocks or rejects requests when the limit is exceeded
Is safe for concurrent use
What this tests
Time-based logic
Concurrency safety
Understanding of rate-limiting algorithms
Senior extensions
Use time.Ticker
Support burst traffic
Make it configurable
📘 Notes
Rate limiter /reɪt ˈlɪmɪtər/: controls how frequently an action can happen
Token bucket /ˈtoʊkən ˈbʌkɪt/: algorithm using tokens to allow requests
3️⃣ Concurrent URL Fetcher with Error Handling Problem
Write a function that:
Accepts a list of URLs
Fetches them concurrently
Limits concurrency to N requests at a time
Returns results and errors separately
What this tests
Goroutine orchestration
Channel fan-in / fan-out
Error handling in concurrent systems
Senior extensions
Add retry with backoff
Use context.Context for cancellation
Stop early if too many failures occur
📘 Notes
Fan-in / Fan-out /fæn ɪn | fæn aʊt/: merging and splitting concurrent flows
Backoff /ˈbækˌɔːf/: waiting longer between retries
4️⃣ Thread-safe In-Memory Cache with TTL Problem
Implement an in-memory cache that:
Stores key-value pairs
Supports TTL (time to live)
Is safe for concurrent reads and writes
What this tests
sync.Mutex / sync.RWMutex
Data consistency
Time-based eviction
Senior extensions
Background cleanup goroutine
LRU eviction strategy
Metrics (hits/misses)
📘 Notes
TTL (time to live) /ˌtiː tiː ˈɛl/: how long data stays valid
Eviction /ɪˈvɪkʃən/: removing old data
5️⃣ Graceful HTTP Server Shutdown Problem
Create an HTTP server that:
Handles requests normally
Listens for OS signals (SIGINT, SIGTERM)
Shuts down gracefully without dropping in-flight requests
What this tests
Real-world Go server knowledge
Signal handling
http.Server.Shutdown
Senior extensions
Add request context cancellation
Log active connections during shutdown
Add timeout handling
📘 Notes
Graceful shutdown /ˈɡreɪsfəl ˈʃʌtdaʊn/: stopping without breaking active work
In-flight request /ɪn flaɪt rɪˈkwɛst/: a request currently being processed
