Golang / GoLang System Architecture and Testing Interview Questions
What microservice design patterns are most important to understand for Go interviews?
Senior Go interviews probe whether you can design systems that are resilient, observable, and maintainable at scale. These patterns recur across every production Go microservice.
| Pattern | Problem Solved | Go Implementation |
|---|---|---|
| Circuit Breaker | Prevent cascade failures when a downstream is slow/dead | sony/gobreaker or custom state machine |
| Bulkhead | Isolate failures — one slow dependency shouldn't affect others | Separate goroutine pools / semaphores per dependency |
| Retry + Backoff | Transient failures in distributed systems | grpc RetryPolicy or manual exponential backoff |
| Saga / Outbox | Distributed transactions without 2PC | Event sourcing + idempotent consumers |
| Sidecar | Cross-cutting concerns without modifying service | Envoy/Linkerd proxies, Dapr |
| Health Check Aggregator | K8s readiness = all dependencies healthy | Custom /readyz checking DB, cache, downstream |
| Strangler Fig | Gradual migration from monolith | Route by feature flag; run old+new in parallel |
// Circuit breaker with sony/gobreaker
import "github.com/sony/gobreaker"
type UserClient struct {
grpc pb.UserServiceClient
cb *gobreaker.CircuitBreaker
}
func NewUserClient(grpc pb.UserServiceClient) *UserClient {
cb := gobreaker.NewCircuitBreaker(gobreaker.Settings{
Name: "user-service",
MaxRequests: 3, // requests in half-open state
Interval: 10 * time.Second, // reset window for counting
Timeout: 30 * time.Second, // how long to stay open
ReadyToTrip: func(c gobreaker.Counts) bool {
return c.ConsecutiveFailures >= 5
},
})
return &UserClient{grpc: grpc, cb: cb}
}
func (c *UserClient) GetUser(ctx context.Context, id int64) (*pb.User, error) {
result, err := c.cb.Execute(func() (any, error) {
return c.grpc.GetUser(ctx, &pb.GetUserRequest{Id: id})
})
if err != nil {
if errors.Is(err, gobreaker.ErrOpenState) {
return nil, fmt.Errorf("user service unavailable (circuit open): %w", err)
}
return nil, err
}
return result.(*pb.User), nil
}
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
