Micro service architecture @Ctrip v1.1

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

description

Case study showing how we decomposed Ctrip mobile backend into microservice architecture for system decoupling, deployability and scalability.

Transcript of Micro service architecture @Ctrip v1.1

Page 1: Micro service architecture @Ctrip v1.1

MicroService Architecture @Ctrip

William Yang(杨波)

Dev Manager & Architect @Ctrip.com

Page 2: Micro service architecture @Ctrip v1.1

Problem Domain

• System decoupling for deployability and scalability

• Evolutionary architecture and adaptive organization

• Mobile Backend Architecture

Page 3: Micro service 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: Micro service architecture @Ctrip v1.1

Initial Ctrip Mobile Backend Architecture

Monolithic Mobile Service

SBU A SBU B SBU C SBU D

SOA/ESB

Page 5: Micro service architecture @Ctrip v1.1

Pros & Cons

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

• Later …huge, complex, monolithic mobile service

Page 6: Micro service 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: Micro service 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: Micro service architecture @Ctrip v1.1

Who has Migrated to MicroService

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

Page 9: Micro service architecture @Ctrip v1.1

New Mobile Backend Arch @Ctrip

Page 10: Micro service 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: Micro service architecture @Ctrip v1.1

MicroService Framework @Ctrip

Page 12: Micro service architecture @Ctrip v1.1

Service Metrics Monitoring

Page 13: Micro service 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: Micro service architecture @Ctrip v1.1

Service Dependency

Page 15: Micro service architecture @Ctrip v1.1

Single Dependency Delay

Page 16: Micro service architecture @Ctrip v1.1

Cascading Failure at Peak Hour

Page 17: Micro service architecture @Ctrip v1.1

Basics of Service Fault Tolerance

• Circuit Breaker(Fuse Blow)

• Isolation

• Rate Limiting

• Fallback

Page 18: Micro service architecture @Ctrip v1.1

Hystrix Circuit Breaker

http://github.com/netflix/hystrix

Page 19: Micro service architecture @Ctrip v1.1

Ctrip Gateway Hystrix Dashboard

Page 20: Micro service architecture @Ctrip v1.1

MicroService Gateway

Page 21: Micro service 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: Micro service architecture @Ctrip v1.1

Filter Management

Page 23: Micro service architecture @Ctrip v1.1

Advanced Usage of Gateway

• Surgical debugging

• Stress testing

• Canary testing

• Service migration

• Load shedding

• Active/Active traffic management

Page 24: Micro service architecture @Ctrip v1.1

Migration to MicroServiceAchievement @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: Micro service architecture @Ctrip v1.1

What We Have Learned One

• Smooth Migration

– Give buffer to user for migration

Page 26: Micro service 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: Micro service 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: Micro service 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: Micro service architecture @Ctrip v1.1

Future – Soft Load Balancing

Page 30: Micro service architecture @Ctrip v1.1

Future – Cross Data Centers

Page 31: Micro service architecture @Ctrip v1.1

About Me

• William Yang(杨波)

• Dev Manager & Architect @Ctrip Middleware Team @Shanghai

We are

hiring!

Page 32: Micro service architecture @Ctrip v1.1

谢谢