Microservices reativos usando a stack do Netflix na AWS

58
Microservices reativos usando a stack do Netflix na AWS Diego Pacheco Principal Software Architect at ilegra.com @diego_pacheco

Transcript of Microservices reativos usando a stack do Netflix na AWS

Page 1: Microservices reativos usando a stack do Netflix na AWS

Microservices reativos usando a stack do Netflix na AWS

Diego PachecoPrincipal Software Architect at ilegra.com@diego_pacheco

Page 2: Microservices reativos usando a stack do Netflix na AWS
Page 3: Microservices reativos usando a stack do Netflix na AWS

www.ilegra.com

Page 4: Microservices reativos usando a stack do Netflix na AWS

NetflixOSS Stack

Page 5: Microservices reativos usando a stack do Netflix na AWS

Why Netflix?

Billions Requests Per Day 1/3 US internet

bandwidth ~10k EC2 Instances Multi-Region 100s Microservices Innovation + Solid

Service SOA, Microservices and

DevOps Benchmark

Social Product Social Network Video Docs Apps Chat

ScalabilityDistributed Teams Could reach some Web Scale

Netflix My Problem

Page 6: Microservices reativos usando a stack do Netflix na AWS

AWS

Page 7: Microservices reativos usando a stack do Netflix na AWS

Cloud Native

Page 8: Microservices reativos usando a stack do Netflix na AWS

Principles

Stateless Services Ephemeral Instances Everything fails all the

time Auto Scaling / Down

Scaling Multi AZ and multi

Region No SPOF Design for Failure

(expected)

SOA Microservices No Central Database NoSQL Lightweight Serializable

Objects Latency tolerant

protocols DevOps Enabler

Immutable Infrastructure Anti-Fragility

Page 9: Microservices reativos usando a stack do Netflix na AWS

Right Set of Assumptons

Page 10: Microservices reativos usando a stack do Netflix na AWS

Microservices

Page 11: Microservices reativos usando a stack do Netflix na AWS

Reactive

Page 12: Microservices reativos usando a stack do Netflix na AWS

Java Drivers X REST

X

Page 13: Microservices reativos usando a stack do Netflix na AWS

Simple View of the Architecture

Zuul

UI

Microservice

Cassandra Cluster

Page 14: Microservices reativos usando a stack do Netflix na AWS

Stack

Page 15: Microservices reativos usando a stack do Netflix na AWS

OSS

Page 16: Microservices reativos usando a stack do Netflix na AWS

Zuul

Page 17: Microservices reativos usando a stack do Netflix na AWS

Zuul

Page 18: Microservices reativos usando a stack do Netflix na AWS

Karyon: Microbiology - Nucleus

Page 19: Microservices reativos usando a stack do Netflix na AWS

Reactive Extensions + Netty Server Lower Latency under Heavy Load Fewer Locks, Fewer Thread Migrations Consumes Less CPU Lower Object Allocation Rate

RxNetty

Page 20: Microservices reativos usando a stack do Netflix na AWS

Karyon: CODE

Page 21: Microservices reativos usando a stack do Netflix na AWS

Karyon: Reactive

Page 22: Microservices reativos usando a stack do Netflix na AWS

Karyon: Reactive

Page 23: Microservices reativos usando a stack do Netflix na AWS

Eureka and Service Discovery

http://microservices.io/patterns/server-side-discovery.html

Page 24: Microservices reativos usando a stack do Netflix na AWS

Eureka

AWS Service Registry for Mid-tier Load balancing and Failover REST based Karyon and Ribbon Integration

Page 25: Microservices reativos usando a stack do Netflix na AWS

Eureka

Page 26: Microservices reativos usando a stack do Netflix na AWS

Eureka and Service Discovery

Page 27: Microservices reativos usando a stack do Netflix na AWS

Availability

Page 28: Microservices reativos usando a stack do Netflix na AWS

Histryx

Page 29: Microservices reativos usando a stack do Netflix na AWS

IPC Library Client Side Load Balancing Multi-Protocol (HTTP, TCP, UDP) Caching* Batching Reactive

Ribbon

Page 30: Microservices reativos usando a stack do Netflix na AWS

RibbonCODE

Page 31: Microservices reativos usando a stack do Netflix na AWS

RibbonCODE

Page 32: Microservices reativos usando a stack do Netflix na AWS

Reactive Extension of the JVM Async/Event based programming Observer Pattern Less 1mb Heavy usage by Netflix OSS Stack

RX-Java

Page 33: Microservices reativos usando a stack do Netflix na AWS

Archaius

Configuration Management Solution Dynamic and Typed Properties High Throughtput and Thread Safety Callbacks: Notifications of config changes JMX Beans Dynamic Config Sources: File, Db, DynamoDB, Zookeper Based on Apache Commons Configuration

Page 34: Microservices reativos usando a stack do Netflix na AWS

Archaius + Git

MicroserviceMicroservice Slave Side Car

CentralInternal GIT Property

Files

File System

MicroserviceMicroservice Slave Side Car

File System

MicroserviceMicroservice Slave Side Car

File System

Page 35: Microservices reativos usando a stack do Netflix na AWS

Asgard

Page 36: Microservices reativos usando a stack do Netflix na AWS

Asgard

Page 37: Microservices reativos usando a stack do Netflix na AWS

Packer

JOB Create

Bake/Provision

Launch

Deploys

Page 38: Microservices reativos usando a stack do Netflix na AWS

Dynomite: Distributed Cache

https://github.com/Netflix/dynomite

Page 39: Microservices reativos usando a stack do Netflix na AWS

Dynomite

Implements the Amazon DynamoSimilar to Cassandra, Riak and DynamoDB

Strong Consistency – Quorum-like – No Data LossPluggable ScalableRedis / MemcachedMulti-Clients with DynoCan use most of redis commandsIntegrated with Eureka via Prana

Page 40: Microservices reativos usando a stack do Netflix na AWS

Dynomite: Internals

Page 41: Microservices reativos usando a stack do Netflix na AWS

Oregon D1

Oregon D2

N California D3

Eureka Server

Eureka Server

Prana

Prana

Prana

Multi-Region Cluster

Page 42: Microservices reativos usando a stack do Netflix na AWS

Dynomite: CODE

Page 43: Microservices reativos usando a stack do Netflix na AWS

Dynomite Contributions

https://github.com/Netflix/dynomite

https://github.com/Netflix/dynomite/pull/207

https://github.com/Netflix/dynomite/pull/200

Page 44: Microservices reativos usando a stack do Netflix na AWS

Caos Engineering

Page 45: Microservices reativos usando a stack do Netflix na AWS

Isolate Failure – Avoid cascading Redundancy – NO SPOF Auto-Scaling Fault Tolerance and Isolation Recovery Fallbacks and Degraded Experience Protect Customer from failures – Don’t throw Failures ->

Failures VS Errors

Chaos / Failure

Page 46: Microservices reativos usando a stack do Netflix na AWS

Gatling

Stress Testing ToolScala DSLRun on top of AkkaSimple to use

Page 47: Microservices reativos usando a stack do Netflix na AWS

Chaos Arch

Zuul

Microservice N1 Microservice N2

Cassandra Cluster

Zuul

EurekaELB

Page 48: Microservices reativos usando a stack do Netflix na AWS

Running…

Page 49: Microservices reativos usando a stack do Netflix na AWS

Chaos Results and Learnings

Retry configuration and Timeouts in Ribbon Right Class in Zuul 1.x (default retry only SocketException)

RequestSpecificRetryHandler (Httpclient Exceptions) zuul.client.ribbon.MaxAutoRetries=1 zuul.client.ribbon.MaxAutoRetriesNextServer=1 zuul.client.ribbon.OkToRetryOnAllOperations=true

Eureka Timeouts It Works Everything needs to have redudancy ASG is your friend :-) Stateless Service FTW

Page 50: Microservices reativos usando a stack do Netflix na AWS

Microservice Producer

Kafka / Storm :: Event System

Page 51: Microservices reativos usando a stack do Netflix na AWS

Chaos Results and Learnings

Before: Data was not in Elastic Search Producers was loosing data

After:

No Data Loss It Works

Changes: No logging on Microservice :( (Log was added) Code that publish events on a try-catch Retry config in kafka producer from 0 to 5

Page 52: Microservices reativos usando a stack do Netflix na AWS
Page 53: Microservices reativos usando a stack do Netflix na AWS

Main Challenges

Page 54: Microservices reativos usando a stack do Netflix na AWS

Hacker Mindset

Page 55: Microservices reativos usando a stack do Netflix na AWS
Page 56: Microservices reativos usando a stack do Netflix na AWS

Next Steps

IPC Spinnaker Containers Client side Aggregation DevOps 2.0 -> Remediation / Skynet

Page 57: Microservices reativos usando a stack do Netflix na AWS

Pocs

https://github.com/diegopacheco/netflixoss-pocs

http://diego-pacheco.blogspot.com.br/search/label/netflix?max-results=30

Page 58: Microservices reativos usando a stack do Netflix na AWS

Microservices reativos usando a stack do Netflix na AWS

Diego PachecoPrincipal Software Architect at ilegra.com@diego_pacheco

Obrigado!