Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Designing Microservices Platforms with NATS

You're reading from  Designing Microservices Platforms with NATS

Product type Book
Published in Nov 2021
Publisher Packt
ISBN-13 9781801072212
Pages 356 pages
Edition 1st Edition
Languages
Concepts
Author (1):
Chanaka Fernando Chanaka Fernando
Profile icon Chanaka Fernando

Table of Contents (15) Chapters

Preface 1. Section 1: The Basics of Microservices Architecture and NATS
2. Chapter 1: Introduction to the Microservice Architecture 3. Chapter 2: Why Is Messaging Important in the Microservice Architecture? 4. Chapter 3: What Is NATS Messaging? 5. Section 2: Building Microservices with NATS
6. Chapter 4: How to Use NATS in a Microservice Architecture 7. Chapter 5: Designing a Microservice Architecture with NATS 8. Chapter 6: A Practical Example of Microservices with NATS 9. Chapter 7: Securing a Microservices Architecture with NATS 10. Chapter 8: Observability with NATS in a Microservices Architecture 11. Section 3: Best Practices and Future Developments
12. Chapter 9: How Microservices and NATS Coexist with Integration Platforms 13. Chapter 10: Future of the Microservice Architecture and NATS 14. Other Books You May Enjoy

Setting up the NATS server cluster

NATS servers can be clustered to support high-volume systems and to provide better availability. NATS uses a simple clustering protocol to connect with other servers via gossiping and connecting to all the servers that a particular server is aware of. Once clients connect to a given server, the clients are informed about the current cluster members. We discussed NATS clustering in detail in Chapter 3, What Is NATS Messaging?. For this chapter, let's create a three-node cluster to try out our OPD microservice application.

Starting up the three-node NATS server cluster

Let's start a three-node cluster by specifying the client port and the cluster port, as shown here:

  1. Start the first server as the seed server:
    $ nats-server -p 4222 -cluster nats://localhost:4248 -D
  2. Start the second server by specifying the cluster URL of the first (seed) server:
    $ nats-server -p 5222 -cluster nats://localhost:5248 -routes nats://localhost:4248...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}