وبلاگ بلیان

NATS کاربردی: از مبتدی تا حرفه‌ای

Practical NATS : From Beginner to Pro

معرفی کتاب «NATS کاربردی: از مبتدی تا حرفه‌ای» (با عنوان لاتین Practical NATS : From Beginner to Pro) نوشتهٔ Waldemar Quevedo، منتشرشده توسط نشر Apress : Imprint: Apress در سال 2018. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است.

Learn to use NATS and messaging as a solution for communication between services. The NATS project has been around since 2010, but it has become more popular in recent years due to how well it fits into the paradigm of cloud native applications and microservices architectures. It’s fast becoming a very attractive option thanks to its great performance characteristics--a single server can push millions of messages per second--and overall simple design. First you will learn the fundamentals of NATS, such as its design, protocol and the styles of communications it enables, internals of the NATS clients, and how to use the basic API provided by all the official clients. You will also understand how to setup and configure NATS servers using the configuration file. Next you'll work with real-world projects and see how to develop a production-ready cloud native application using NATS as the control plane over which clients communicate. Finally you’ll learn advanced usage of the NATS clients, such as implementing heartbeats based failure detectors, tracing or collecting multiple responses from a single request. Perhaps you are familiar with REST-style APIs, and want to make the transition into a messaging-based approach instead. __Practical NATS__ is the perfect place to start. **What You'll Learn** * Use NATS to build applications which use it as the control plane for communication among components * Explore the fundamentals of NATS such as how the protocol works under the hood to more advanced communication styles which are possible with the basic building blocks provided by the client * Setup, operate, and configure NATS servers, as well as how to troubleshoot common failure scenarios **Who This Book Is For** Anyone looking for a solution for some of the problems which come along with microservices and cloud native application development, such as service discovery, low latency requests, load balancing, tracing and monitoring for example. Also adopters of NATS who need further help getting started using it. Ideally you should have some familiarity with Go as that is the language of the code examples. Table of Contents 5 About the Author 11 About the Technical Reviewer 12 Acknowledgments 13 Foreword 14 Chapter 1: Introduction to NATS 16 Using NATS for Messaging 17 Messaging Over the REST 19 Do Not Assume the Audience 20 NATS As an Always Available Dial Tone 23 Delivery Guarantees 25 Is NATS a Message Broker or a Message Queue? 26 A Brief History of NATS 27 Roots in Ruby 27 I Wanna Go Fast! 29 Cloud-Native NATS 31 Summary 33 Chapter 2: The NATS Protocol 34 Overview of the Protocol 34 Why Not a Binary Protocol Instead? 35 Setting Up the Environment 36 Connecting to NATS 37 PING and PONG 39 Sending and Receiving Messages 41 Publishing Messages with PUB 41 Registering Interest in a Subject with SUB 43 Subject Names and Wildcards 46 Creating Queue Subscriptions for Load Balancing 49 Limiting Interest in a Subject with UNSUB 51 Publishing Requests 53 Lowest Latency Response 55 Summary 56 Chapter 3: The NATS Clients 57 Features of a NATS Client 57 Using Connect 59 Customizing a Connection 61 Authorization Credentials 64 Using Publish and Subscribe 65 Using Publish 66 Using Subscribe 68 Using QueueSubscribe 71 Removing a Subscription 72 Using Flush 76 Using Request 77 The Classic Request/Response 79 The New Style Request/Response 81 A Note on Asynchronous I/O 81 States of a NATS Connection 87 Clients Reconnection Logic 91 Event Callbacks 94 Using Close 96 Summary 98 Chapter 4: Setting Up NATS 99 Server Configuration 99 Exposed Ports 102 Server Logging 108 Logging Outputs 111 Configuring Authorization 112 Extending the Authorization Deadline 114 TLS Options 115 Tuning the Defaults 116 Increasing the Maximum Payload Size 116 Extending the Deadline for Slow Consumers Handling 117 Tuning the Keepalive Interval 118 Tuning the Maximum Number of Connections 118 Server Reloading 119 Reloading to Activate Tracing On-the-Fly 119 Reducing the Number of Live Connections 121 Running NATS in Docker 122 Summary 123 Chapter 5: High Availability with NATS Clustering 124 The NATS Cluster Network Topology 124 Configuring a NATS Cluster from the CLI 127 Setting Up Clustering via the Configuration File 132 Explicitly Setting a Server Pool in the Client 134 Disabling Random Reconnection Ordering 135 Bootstrapping a Cluster Using Autodiscovery 136 Monitoring a NATS Cluster State 137 On Autodiscovery and Load Balancers 139 Setting Up a NATS Cluster Behind a Load Balancer 140 Summary 143 Chapter 6: Developing a Cloud-­Native NATS Application 144 The NATS Rider Application 144 Scaffolding the Application 146 Defining a Base Component 150 Customizing the Connection to NATS 152 Enabling Components Discovery 154 The NATS Rider API 158 The Load Balanced Rider Manager 167 The Driver Agent 174 Summary 180 Chapter 7: Monitoring NATS 181 Server Instrumentation 181 The /varz Endpoint 182 The /connz Endpoint 187 Showing Client Subscriptions 192 Sorting and Limiting Query Results 194 About /routez 199 About /subsz 204 Using nats-top for Monitoring 205 Summary 208 Chapter 8: Securing NATS 209 Connecting Securely to NATS 209 Configuring TLS in the Server 211 Securing the Monitoring Endpoint 212 Tuning the Authorization Timeout 213 Setting a Certificate Authority 213 Require Clients to Provide a Certificate 214 Setting Up a Secure NATS Environment from Scratch 214 Installing cfssl for Certs Creation 215 Defining the Security Roles 215 Creating a Custom Root CA 217 Securing the Connections from the Clients 218 Securing the Monitoring Endpoint 220 Securing the Routes from the Cluster 221 Caveats from NATS TLS Support 223 Not Possible to Use TLS Right Away 223 Limitations of Configuring TLS from the Command Line 224 Auto Discovery and Routes TLS 225 Summary 228 Chapter 9: Troubleshooting NATS 229 Types of Slow Consumer Errors 229 Troubleshooting Slow Consumer Protocol Errors 231 Subscriptions in Slow Consumer State 238 Routes as Slow Consumers in a NATS Cluster 240 Summary 243 Chapter 10: Advanced NATS Techniques 244 Using Inbox Subscriptions 244 Subscriptions with Heartbeats 257 Gathering Multiple Responses 264 Summary 267 Index 268
دانلود کتاب NATS کاربردی: از مبتدی تا حرفه‌ای