Wiki: Build a High-Performance Microservices Architecture with NATS.io & Golang

For agents: Markdown version · Wiki index · Explore

Written by an LLM from machine transcripts. It can contain errors. Check the transcript before you quote it.

Summary

The speaker shares architectural lessons learned while building a high-performance ride-sharing startup platform designed to handle hundreds of thousands of concurrent users with a rapid time-to-market. The talk explores the rationale for choosing Go as the primary programming language due to its lightweight green threads and hybrid I/O model. It also examines the implementation of a microservices messaging architecture using NATS to achieve extreme throughput and low latency. Ultimately, the audience learns how combining these technologies enables scalable distributed systems while carefully weighing trade-offs like eventual message loss.

Key points

  • 1:06 The project required handling hundreds of thousands of concurrent users from day one while maintaining a time-to-market of under a year.
  • 4:30 Microservices architecture provides decoupling between software components and teams, enabling faster time-to-market.
  • 11:51 Go concurrency is built on green threads called goroutines, which have a very low memory footprint compared to operating system threads.
  • 13:58 Go’s runtime handles synchronous-looking code asynchronously under the hood, simplifying concurrent programming without complex callback models.
  • 15:53 NATS is an open-source messaging system focused on high performance, capable of processing millions of messages per second by keeping data in-memory without persistence.
  • 17:55 NATS supports both pub-sub broadcasting and request-response patterns over topics, effectively eliminating the need for explicit service discovery and load balancer components.
  • 27:14 The lack of persistence in NATS means that messages can be lost if a service or the network drops, introducing architectural complexity that may require secondary messaging systems for reliable durability.
  • 30:16 Developers adopting Go must navigate a relatively young ecosystem with third-party libraries compared to languages with decades of maturity.

Takeaways

  • Use lightweight concurrency models like Go goroutines to scale to millions of concurrent operations without overwhelming the operating system.
  • Evaluate messaging systems like NATS when extreme high-performance and high-throughput are required, but understand the trade-offs of in-memory architecture without built-in persistence.
  • Combine publish-subscribe for event broadcasting and request-response semantics for synchronous-like service communication to simplify microservices design.

Questions this talk answers

  • How does Go handle concurrency efficiently compared to traditional OS threads?
  • When should an architecture use NATS instead of traditional HTTP or persistent message brokers?
  • How do you handle the lack of message persistence when using an in-memory messaging system like NATS?

Technologies

Go, NATS, HTTP, Amazon SQS, C, C++, Redis, Kafka

Tags

architecture, concurrency, golang, high performance, messaging, microservices, scalability