万本电子书0元读

万本电子书0元读

顶部广告

TypeScript Microservices电子书

售       价:¥

11人正在读 | 0人评论 9.8

作       者:Parth Ghiya

出  版  社:Packt Publishing

出版时间:2018-05-30

字       数:55.1万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Build robust microservice-based applications that are distributed, fault tolerant, and always available About This Book ? Learn to build message-driven services for effective communication ? Design microservices API using Reactive programming design patterns ? Deploy, scale and monitor microservices for consistent high performance Who This Book Is For This book is for JavaScript developers seeking to utilize their Node.js and Typescript skills to build microservices and move away from the monolithic architecture. Prior knowledge of TypeScript and Node.js is assumed. What You Will Learn ? Get acquainted with the fundamentals behind microservices. ? Explore the behavioral changes needed for moving from monolithic to microservices. ? Dive into reactive programming, Typescript and Node.js to learn its fundamentals in microservices ? Understand and design a service gateway and service registry for your microservices. ? Maintain the state of microservice and handle dependencies. ? Perfect your microservice with unit testing and Integration testing ? Develop a microservice, secure it, deploy it, and then scale it In Detail In the last few years or so, microservices have achieved the rock star status and right now are one of the most tangible solutions in enterprises to make quick, effective, and scalable applications. The apparent rise of Typescript and long evolution from ES5 to ES6 has seen lots of big companies move to ES6 stack. If you want to learn how to leverage the power of microservices to build robust architecture using reactive programming and Typescript in Node.js, then this book is for you. Typescript Microservices is an end-to-end guide that shows you the implementation of microservices from scratch; right from starting the project to hardening and securing your services. We will begin with a brief introduction to microservices before learning to break your monolith applications into microservices. From here, you will learn reactive programming patterns and how to build APIs for microservices. The next set of topics will take you through the microservice architecture with TypeScript and communication between services. Further, you will learn to test and deploy your TypeScript microservices using the latest tools and implement continuous integration. Finally, you will learn to secure and harden your microservice. By the end of the book, you will be able to build production-ready, scalable, and maintainable microservices using Node.js and Typescript. Style and approach This book will be a step by step easy to follow guide with focused examples for building microservices with Typescript.
目录展开

Title Page

Copyright and Credits

TypeScript Microservices

Packt Upsell

Why subscribe?

PacktPub.com

Contributors

About the author

About the reviewer

Packt is searching for authors like you

Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Download the color images

Conventions used

Get in touch

Reviews

Debunking Microservices

Debunking microservices

Rise of microservices

Wide selection of languages as per demand

Easy handling of ownership

Frequent deployments

Self-sustaining development units

What are microservices?

Principles and characteristics

No monolithic modules

Dumb communication pipes

Decentralization or self-governance

Service contracts and statelessness

Lightweight

Polyglot

Good parts of microservices

Self-dependent teams

Graceful degradation of services

Supports polyglot architecture and DevOps

Event-driven architecture

Bad and challenging parts of microservices

Organization and orchestration

Platform

Testing

Service discovery

Microservice example

Key considerations while adopting microservices

Service degradation

Proper change governance

Health checks, load balancing, and efficient gateway routing

Self-curing

Cache for failover

Retry until

Microservice FAQs

Twelve-factor application of microservices

Microservices in the current world

Netflix

Walmart

Spotify

Zalando

Microservice design aspects

Communication between microservices

Remote Procedure Invocation (RPI)

Messaging and message bus

Protobufs

Service discovery

Service registry for service-service communication

Server-side discovery

Client-side discovery

Registration patterns – self-registration

Data management

Database per service

Sharing concerns

Externalized configuration

Observability

Log aggregation

Distributed tracing

Microservice design patterns

Asynchronous messaging microservice design pattern

Backend for frontends

Gateway aggregation and offloading

Proxy routing and throttling

Ambassador and sidecar pattern

Anti-corruption microservice design pattern

Bulkhead design pattern

Circuit breaker

Strangler pattern

Summary

Gearing up for the Journey

Setting up primary environment

Visual Studio Code (VS Code)

PM2

NGINX

Docker

Primer to TypeScript

Understanding tsconfig.json

compilerOptions

include and exclude

extends

Understanding types

Installing types from DefinitelyTyped

Writing your own types

Using the dts-gen tool

Writing your own *.d.ts file

Debugging

Primer to Node.js

Event Loop

Understanding Event Loop

Node.js clusters and multithreading

Async/await

Retrying failed requests

Multiple requests in parallel

Streams

Writing your first Hello World microservice

Summary

Exploring Reactive Programming

Introduction to reactive programming

Why should I consider adopting reactive programming?

Reactive Manifesto

Responsive systems

Resilient to errors

Elastic scalable

Message-driven

Major building blocks and concerns

Observable streams

Subscription

emit and map

Operator

Backpressure strategy

Currying functions

When to react and when not to react (orchestrate)

Orchestration

Benefits

Disadvantages

Reactive approach

Benefits

Disadvantages

React outside, orchestrate inside

Reactive coordinator to drive the flow

Synopsis

When a pure reactive approach is a perfect fit

When pure orchestration is a perfect fit

When react outside, orchestrate inside is a perfect fit

When introducing a reactive coordinator is the perfect fit

Being reactive in Node.js

Rx.js

Bacon.js

HighLand.js

Key takeaways

Summary

Beginning Your Microservice Journey

Overview of shopping cart microservices

Business process overview

Functional view

Deployment view

Architecture design of our system

Different microservices

Cache microservice

Service registry and discovery

Registrator

Logger

Gateway

Design aspects involved

Microservice efficiency model

Core functionalities

Supporting efficiencies

Infrastructure role

Governance

Implementation plan for shopping cart microservices

What to do when the scope is not clear

Schema design and database selection

How to segregate data between microservices

Postulate 1 – data ownership should be regulated via business capabilities

Postulate 2 – replicate the database for speed and robustness

How to choose a data store for your microservice

Design of product microservices

Microservice predevelopment aspects

HTTP code

1xx – informational

2xx – success

3xx – redirections

4xx – client errors

5xx – server errors

Why HTTP code is vital in microservices?

Auditing via logs

PM2 process manager

Tracing requests

Developing some microservices for a shopping cart

Itinerary

Development setup and prerequisite modules

Repository pattern

Configuring application properties

Custom health module

Dependency injection and inversion of control

Inversify

Typedi

TypeORM

Application directory configurations

src/data-layer

src/business-layer

src/service-layer

src/middleware

Configuration files

Processing data

Ready to serve (package.json and Docker)

package.json

Docker

Synopsis

Microservice design best practices

Setting up proper microservice scope

Self-governing functions

Polyglot architecture

Size of independent deployable component

Distributing and scaling services whenever required

Being Agile

Single business capability handler

Adapting to shifting needs

Handling dependencies and coupling

Deciding the number of endpoints in a microservice

Communication styles between microservices

Specifying and testing the microservices contract

Number of microservices in a container

Data sources and rule engine among microservices

Summary

Understanding API Gateway

Debunking API Gateway

Concerns API Gateway handles

Security

Dumb gateways

Transformation and orchestration

Monitoring, alerting, and high availability

Caching and error handling

Service registry and discovery

Circuit breakers

Versioning and dependency resolution

API Gateway design patterns and aspects

Circuit breakers and its role

Need for gateway in our shopping cart microservices

Handle performance and scalability

Reactive programming to up the odds

Invoking services

Discovering services

Handling partial service failures

Design considerations

Available API Gateways options

HTTP proxy and Express Gateway

Zuul and Eureka

API Gateway versus reverse proxy NGINX

RabbitMQ

Designing our gateway for shopping cart microservices

What are we going to use?

Summary

Service Registry and Discovery

Introduction to the service registry

What, why, and how of service registry and discovery

The why of service registry and discovery

How service registry and discovery?

Service registration

Service resolution

The what of service registry and discovery

Maintaining service registry

Timely health checks

Service discovery patterns

Client-side discovery pattern

Server-side discovery pattern

Service registry patterns

Self-registration pattern

Third-party registration pattern

Service registry and discovery options

Eureka

Setting up the Eureka server

Registering with Eureka server

Discovering with Eureka server

Key points for Eureka

Consul

Setting up the Consul server

Talking with Consul server

Registering a service instance

Sending heartbeats and doing a health check

Deregistering an application

Subscribing to updates

Key points for Consul

Registrator

Key points for Registrator

How to choose service registry and discovery

If you select Consul

If you select Eureka

Summary

Service State and Interservice Communication

Core concepts – state, communication, and dependencies

Microservice state

Interservice communication

Commands

Queries

Events

Exchanging data formats

Text-based message formats

Binary message formats

Dependencies

Communication styles

NextGen communication styles

HTTP/2

gRPC with Apache Thrift

Versioning microservices and failure handling

Versioning 101

When a developer's nightmare comes true

Client resiliency patterns

Bulkhead and retry pattern

Client-side load balancing or queue-based load leveling pattern

Circuit breaker pattern

The fallback and compensating transaction pattern

Case Study – The NetFlix Stack

Part A – Zuul and Polyglot Environment

Part B – Zuul, Load balancing and failure resiliency

Message queues and brokers

Introduction to pub/sub pattern

Sharing dependencies

The problem and solution

Getting started with bit

The problem of shared data

Cache

Blessing and curse of caching

Introduction to Redis

Setting up our distributed caching using redis

Summary

Testing, Debugging, and Documenting

Testing

What and how to test

The testing pyramid – what to test?

System tests

Service tests

Contract tests

Unit tests

Hands-on testing

Our libraries and test tool types

Chai

Mocha

Ava

Sinon

Istanbul

Contract tests using Pact.js

What is consumer-driven contract testing?

Introduction to Pact.js

Bonus (containerizing pact broker)

Revisiting testing key points

Debugging

Building a proxy in between to debug our microservices

Profiling process

Dumping heap

CPU profiling

Live Debugging/Remote Debugging

Key points for debugging

Documenting

Need of Documentation

Swagger 101

Swagger Editor and Descriptor

Key points for Swagger and Descriptor

Swagger Editor

Swagger Codegen

Swagger UI

Swagger Inspector

Possible strategies to use Swagger

Top-down or design-first Approach

Bottom-up approach

Generating a project from a Swagger definition

Summary

Deployment, Logging, and Monitoring

Deployment

Deciding release plan

Deployment options

DevOps 101

Containers

Containers versus Virtual Machine (VMs)

Docker and the world of containers

Docker components

Docker concepts

Docker command reference

Setting up Docker with NGINX, Node.js, and MongoDB

WebHooks in our build pipeline

Serverless architecture

Logging

Logging best practices

Centralizing and externalizing log storage

Structured data in logs

Identifiers via correlational IDs

Log levels and logging mechanisms

Searchable logs

Centralized custom logging solution implementation

Setting up our environment

Distributed tracing in Node.js

Monitoring

Monitoring 101

Monitoring challenges

When to alert and when not to alert?

Monitoring tools

PM2 and keymetrics

Keymetrics to monitor application exceptions and runtime problems

Adding custom metrics

Simple metrics

Counter metric

Meter

Prometheus and Grafana

Production-ready microservice criteria

Summary

Hardening Your Application

Questions you should be asking while applying security

Core application/core microservice

Middleware

API Gateway

Team and operational activities

Security best practices for individual services/applications

Checking for known security vulnerabilities

Auditjs

Snyk.io

Preventing brute force attacks or flooding by adding rate limiters

Protecting against evil regular expressions

Blocking cross-site request forgeries

Tightening session cookies and effective session management

Adding helmet to configure security headers

Avoiding parameter pollution

Securing transmission

Preventing command injection/SQL injection

TSLint/static code analyzers

Security best practices for containers

Securing container builds and standardizing deployments

Securing containers at runtime

Security checklist

Service necessities

Service interactions

Development phase

Deployment

Operations

Scalability

AWS Load Balancer

Benefits of using a load balancer

Fault tolerance

High availability

Flexibility

Security

Health check parameters

Unhealthy threshold

Healthy threshold

Timeout

Health check protocol

Health check port

Interval

Configuring a load balancer

Autoscaling – practical hands on with AWS

Creating the launch configuration

Creating an autoscaling group and configuring it with autoscaling policies

Creating an application load balancer and adding a target group

Time to test

Scaling with Kubernetes

What problem does Kubernetes solve?

Kubernetes concepts

Summary

Other Books You May Enjoy

Leave a review - let other readers know what you think

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部