microservices architecture @ ctrip v1.1

32
MicroService Architecture @Ctrip William Yang( 杨杨 ) Dev Manager & Architect @Ctrip.com

Upload: william-yang

Post on 21-Apr-2017

1.624 views

Category:

Internet


1 download

TRANSCRIPT

Page 1: MicroServices architecture @ Ctrip v1.1

MicroService Architecture @Ctrip

William Yang(杨波 )Dev Manager & Architect

@Ctrip.com

Page 2: MicroServices architecture @ Ctrip v1.1

Problem Domain

• System decoupling for deployability and scalability

• Evolutionary architecture and adaptive organization

• Mobile Backend Architecture

Page 3: MicroServices architecture @ Ctrip v1.1

Agenda

• The curse of the monolith• Case study – decomposing Ctrip mobile

backend into microservice• Microservice best practice• What we have learned

Page 4: MicroServices architecture @ Ctrip v1.1

Initial Ctrip Mobile Backend Architecture

Monolithic Mobile Service

SBU A SBU B SBU C SBU D

SOA/ESB

Page 5: MicroServices architecture @ Ctrip v1.1

Pros & Cons

• At the beginning …simple to develop, test, deploy and scale

• Later …huge, complex, monolithic mobile service

Page 6: MicroServices architecture @ Ctrip v1.1

The Curse of the Monolith• Bloated codebase• Communication and coordination cost• Obstacle for frequent deployments• Little resilience to failure• Commitment to a single technology stack• Hindering innovation

Page 7: MicroServices architecture @ Ctrip v1.1

MicroService Architecture Style

• Decomposing a single app as a suite of services• Communicating with lightweight mechanism• Built around business capabilities• Independently deployable• Minimum of centralized management• May be written in different programming languages

and use different storages

http://martinfowler.com/articles/microservices.html

Page 8: MicroServices architecture @ Ctrip v1.1

Who has Migrated to MicroService

http://microservices.io/patterns/microservices.html

Page 9: MicroServices architecture @ Ctrip v1.1

New Mobile Backend Arch @Ctrip

Page 10: MicroServices architecture @ Ctrip v1.1

Key MicroService Infrastructure

• Service– Service framework, gateway, registry

• Monitoring– Logging, tracing, metrics

• Deployment– TEST/UAT/PROD environments– CI/CD

• Push common concerns to technical infrastructure

Page 11: MicroServices architecture @ Ctrip v1.1

MicroService Framework @Ctrip

Page 12: MicroServices architecture @ Ctrip v1.1

Service Metrics Monitoring

Page 13: MicroServices architecture @ Ctrip v1.1

MicroService Availability

• Assume a monolithic service with 99.99% availability, what if you have ~30 microservices each with 99.99% availability??

• Combined effective availability== 2 HOURS of downtime per month== 99.7% uptime!!

Page 14: MicroServices architecture @ Ctrip v1.1

Service Dependency

Page 15: MicroServices architecture @ Ctrip v1.1

Single Dependency Delay

Page 16: MicroServices architecture @ Ctrip v1.1

Cascading Failure at Peak Hour

Page 17: MicroServices architecture @ Ctrip v1.1

Basics of Service Fault Tolerance

• Circuit Breaker(Fuse Blow)• Isolation• Rate Limiting• Fallback

Page 18: MicroServices architecture @ Ctrip v1.1

Hystrix Circuit Breaker

http://github.com/netflix/hystrix

Page 19: MicroServices architecture @ Ctrip v1.1

Ctrip Gateway Hystrix Dashboard

Page 20: MicroServices architecture @ Ctrip v1.1

MicroService Gateway

Page 21: MicroServices architecture @ Ctrip v1.1

Gateway Filtering Mechanism

Origin Server

“ pre” filters “ routing” filter(s) “ post” filters

“ error” filters

HTTP Request

Http Request Http Response

https://github.com/Netflix/zuul

Page 22: MicroServices architecture @ Ctrip v1.1

Filter Management

Page 23: MicroServices architecture @ Ctrip v1.1

Advanced Usage of Gateway

• Surgical debugging• Stress testing• Canary testing• Service migration• Load shedding• Active/Active traffic management

Page 24: MicroServices architecture @ Ctrip v1.1

Migration to MicroService Achievement @Ctrip

• System decoupled and domain ownership clarified

• Business innovation speed accelerated• Overall system reliability improved• Decentralized architecture w/o SPOF• Develop, test, deploy and scale independently• Evolutionary architecture

Page 25: MicroServices architecture @ Ctrip v1.1

What We Have Learned One

• Smooth Migration– Give buffer to user for migration

Page 26: MicroServices architecture @ Ctrip v1.1

What We Have Learned Two

• Follow Architecture & Design Best Practice– Single responsibility & separation of concerns– Dependency inversion– Dependency isolation– Rate limiting & circuit breaker– Dynamic deployable & re-configurable

• Top-Level Design– Fit service into infra, not fit infra into service

Page 27: MicroServices architecture @ Ctrip v1.1

What We Have Learned Three

• Conway’s Law– “Any organization that design a system(defined

broadly) will produce a design whose structure is a copy of the organization’s communication structure” – Melvin Conway, 1968

– “Those system then constrain the options for organizational change” – Dan North

Page 28: MicroServices architecture @ Ctrip v1.1

Caveat

• MicroService is not a Free Lunch– Significant operations overhead– Substantial DevOps skills required– Implicit interface– Duplication of effort– Distributed system complexity– Testability challenges

http://highscalability.com/blog/2014/4/8/microservices-not-a-free-lunch.html

Page 29: MicroServices architecture @ Ctrip v1.1

Future – Soft Load Balancing

Page 30: MicroServices architecture @ Ctrip v1.1

Future – Cross Data Centers

Fallback

Page 31: MicroServices architecture @ Ctrip v1.1

About Me

• William Yang(杨波 )• Dev Manager & Architect @Ctrip Middleware

Team @Shanghai

We are hiring!

Page 32: MicroServices architecture @ Ctrip v1.1

谢谢