All Episodes

NATS Supercluster: Cross-Cloud Geo-Affinity for High Availability and Low Latency

Episode 2

Liked this content? Check out the multi cluster consistency models article

Or you can Check out the repo to see how simple all of this is!

Managing communication between services in production environments demands solutions that go beyond development-stage approaches. When your system scales, high availability, reliability, and performance become mission-critical concerns. Traditional methods often leave you drowning in complexity—requiring intricate configurations across load balancers, service meshes, and more—just to keep your components talking. That’s where NATS shines. By providing a resilient, high-performance messaging system designed for distributed systems, NATS clustering delivers the robust communication foundation modern production environments demand, while dramatically simplifying your operational overhead and developer experience.


The Real-World Challenges of Production

When transitioning from development to production environments, your systems face complex challenges that demand robust solutions. The production landscape introduces critical considerations that development environments simply don’t prepare you for:

  • High Availability Imperative: Production environments demand services that remain operational despite unexpected failures. Your system needs to continue functioning even when components fail or entire regions experience outages.
  • Cross-Region Communication Complexity: As your services spread across geographic locations and cloud providers, communication between them becomes increasingly complex. You need to balance reliability with performance, ensuring messages reach their destination without introducing unacceptable latency.
  • Intelligent Failover Requirements: When service instances become unavailable, requests need to be intelligently rerouted to functioning alternatives—ideally without adding significant latency or requiring manual intervention.

Traditional Approaches vs. NATS

These challenges typically force organizations to implement complex infrastructure solutions when working with traditional HTTP-based or gRPC architectures:

  • Complex Routing Infrastructure - Traditional setups require load balancers, API gateways, and complex DNS configurations to route traffic across regions. gRPC adds additional complexity with keep-alive connections, connection management, and the need for specialized proxies that understand HTTP/2 protocol semantics for proper load balancing.

  • Manual Orchestration - Cross-region communication typically relies on direct HTTP or gRPC calls between services, requiring developers to manually implement retry logic, timeouts, and fallback mechanisms. While gRPC offers built-in support for streaming and bidirectional communication, it still requires explicit client-side load balancing or service mesh integration for effective cross-region failover.

  • Brittle Failure Modes - When services become unavailable, both HTTP and gRPC systems experience delays during failure detection. Though gRPC provides better streaming semantics and connection state awareness than HTTP/1.1, it still requires significant infrastructure for handling regional outages gracefully and often relies on complex sidecar proxies for advanced resilience patterns.


SuperClustering: NATS Elegant Solution

NATS solves these challenges through its SuperCluster capability. By connecting multiple NATS clusters - even across different cloud providers - you create a resilient communication fabric for your services.

What makes this approach powerful is its simplicity. There’s no need for complex external service meshes or additional infrastructure. NATS handles the communication, load balancing, and failover right in your code and/or configuration.

A SuperCluster gives you the best of both worlds: local performance when services are available, and seamless failover when they’re not. And the best part? Your service code doesn’t change at all.

  • Unified Communication Fabric: NATS SuperCluster deployment model connects multiple NATS clusters across different cloud providers, creating a resilient communication foundation without requiring complex external service meshes

  • Configuration-Driven Simplicity: The powerful approach requires no additional infrastructure, as NATS handles communication, load balancing, and failover directly through code and configuration

  • Transparent Performance Optimization: SuperClustering delivers both local performance when services are available and seamless failover when they’re not, without requiring any changes to service code


A Demonstration in Setting Up a Production-Ready Environment

Let’s walk through a practical example that Colin Lacy demonstrated in his video:

Scenario 1: Deploying a NATS Cluster

  • Setup: Getting started with NATS in production is surprisingly straightforward. Using the official Helm charts, you can deploy a complete NATS cluster with just a few commands.

  • Simple Configuration for Deployment: Configuration is handled through a simple values.yaml file that gives you control over all aspects of your deployment.

  • Outcome:
    The example shows three NATS servers running in AWS, networked together through a Kubernetes service that acts as the entry point for all client communications.


Scenario 2: Creating and Monitoring Services

  • Setup: The NATS Services Framework - i.e. nats micro - makes building production-ready services straightforward across multiple programming languages. Services register with metadata (name, region, and description) and expose endpoints on specific subjects, creating a clean mapping between functionality and access patterns.

  • Service Implementation: Implementation is remarkably simple - for example, the Python-based adder service listens on math.numbers.add, takes two input numbers, and returns their sum. The framework handles all communication details while you focus on business logic.

  • Outcome: The result is a collection of easily monitored services with built-in metrics for observability. Using commands like nats micro stats, you can track request handling across services and instances, allowing you to observe traffic distribution patterns and verify proper functioning of your microservice architecture.


Scenario 3: Cross-Region High Availability

  • Setup: NATS SuperCluster connects multiple NATS clusters across different cloud providers and regions, creating a resilient, globally distributed messaging system. The example shows clusters in AWS (US East) and Azure connected via NATS gateway links, forming a globally distributed and authenticated mesh.

  • Geographic Intelligence: The system demonstrates remarkable intelligence in request routing. When an AdderService was removed from the US East cluster, requests automatically routed to the equivalent service in the West cluster without any configuration changes or developer intervention.

  • Outcome: NATS provides true high availability with intelligent request routing that balances responsiveness and resilience. The geo-affinity feature ensures requests stay local when services are available locally (minimizing latency), while maintaining seamless failover capability when local services are unavailable - all completely transparent to the requesting applications.


Conclusion

Moving to a production-ready service architecture doesn’t have to mean adding layers of complexity. With NATS, you can build a resilient, performant communication system that scales with your needs while keeping your code clean and focused.

Whether you’re connecting services across regions, clouds, or just ensuring high availability within a single cluster, NATS provides the tools you need with the simplicity your team will appreciate.

Ready to get started? Check out the repo to see how simple all of this is!

Liked this content? Check out the multi cluster consistency models article