micro-service architecture stylemicro-service architecture style ... reference microservices ......

57
Micro-service Architecture Style SMAC ERA… February 5, 2015 Nguyen Quang Tung Solution Architect M: 0127 666 0909 E: [email protected] [email protected]

Upload: truongdat

Post on 12-Feb-2018

238 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

Micro-service Architecture StyleSMAC ERA…

February 5, 2015

Nguyen Quang TungSolution Architect

M: 0127 666 0909

E: [email protected]

[email protected]

Page 2: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

2Copyright © 2014 by FPT Software

WHO AM I?

Nguyen Quang Tung

•E1: [email protected]

•E2: [email protected]

•M: +841276660909

Professional:

• Cán Bộ Công Nghệ FPT Lvl3 –System Architect

•7+ Solution Architect

•6+ Project Manager

•11+ Java/J2EE Development

Domain:

•Multi-media/Video Broadcasting

•Stock Market

•CMS & DMS

•Real Property Market.

•eGovernment

Bachelor of Science Master of Science Mini – MBA

Page 3: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

3Copyright © 2014 by FPT Software

Page 4: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

4Copyright © 2014 by FPT Software

WHO IS BIG PLAYER IN THIS GAME!

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

Page 5: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

5Copyright © 2014 by FPT Software

MICROSERVICE ARCHITECTURE - CONCEPTS

Concepts

Why?

How?

What?

•Concept

•Technology

Page 6: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

6Copyright © 2014 by FPT Software

SW Architecture in the Context of History

Page 7: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

7Copyright © 2014 by FPT Software

Concepts: WHAT ARE MICRO-SERVICERS?

The Micro-Service architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with

lightweight mechanisms, often an HTTP resource API.

These services are built around business capabilities and independently deployable by fully automated deployment machinery. There is a bare minimum of centralized

management of these services, which may be written in different programming languages and use different data storage technologies.

Page 8: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

8Copyright © 2014 by FPT Software

Concepts: SERVICE ORENTED ARCHITECTURE (SOA)?

Classic SOA

•Integrates different applications as a set of services

Microservices

•Architect a single application as a set of services

Yes, it’s SOA … but different implementation approach

Page 9: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

9Copyright © 2014 by FPT Software

Concepts: CLASSIC SOA vs MICROSERVICE

Classic SOA

• Integrates different applications as a set of services

Typical implementation solution

• Heavy-weight

• Orchestration

• ESB

• WS*/SOAP

• License-driven

• Intelligent Communication Layer

Target Problem

• Integrate (Legacy) Software

Page 10: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

10Copyright © 2014 by FPT Software

Concepts: CLASSIC SOA vs MICROSERVICE

MICROSERVICE

• Architect a single application as a set of services

Typical implementation solution

• Light-weight

• Choreography

• HTTP/REST/JSON

• Intelligent Services

• Dumb Communication Layer

Target Problem

• Architect new Business Platform

Page 11: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

11Copyright © 2014 by FPT Software

MICROSERVICE ARCHITECTURE – WHY?

Concepts

Why?

How?

What?

•Concept

•Technology

Page 12: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

12Copyright © 2014 by FPT Software

WHY: EVOLUTION OF SOFTWARE ARCHITECTURE

Page 13: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

13Copyright © 2014 by FPT Software

WHY: FROM MONOLITHIC TO CLOUD

Page 14: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

14Copyright © 2014 by FPT Software

WHY: THE CURSE OF THE MONOLITH

Simple to Develop Simple to Deploy Simple to Scale

Page 15: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

15Copyright © 2014 by FPT Software

WHY: THE CURSE OF THE MONOLITH

Hard to understand and modify

Overloaded IDE

Overloaded

Web Container

• Large Code Intimidates Developers

Development

Slows Down

Page 16: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

16Copyright © 2014 by FPT Software

WHY: THE CURSE OF THE MONOLITH

• Small Change - Big Impact

Any change requires full rebuild, test and deploy

Impact analysis is huge effort and takes long

Obstacle for frequent changes and deployments

Page 17: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

17Copyright © 2014 by FPT Software

WHY: THE CURSE OF THE MONOLITH

• Big Risk for Re-Write

No hard module boundaries

Quality and Modularity breaks down over time this enforces eventual need for re-write

Long term commitment to technology stack

Change or try-out new technology implies re-write

Re-write = complete re-write

No partial re-write

Page 18: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

18Copyright © 2014 by FPT Software

WHY: THE CURSE OF THE MONOLITH

• Little Resilience to Failure

Failure in monolith brings it down

Page 19: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

19Copyright © 2014 by FPT Software

WHY: THE CURSE OF THE MONOLITH

• Scaling can be difficult

Mostly Horizontal scaling many load balanced instances

Hard to scale to data growth cope with all data

Different components have different resource needs

Scaling development implies coordination overhead

Page 20: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

20Copyright © 2014 by FPT Software

WHY: TYPES OF SCALING

• The Scale Cube

Page 21: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

21Copyright © 2014 by FPT Software

WHY: TYPES OF SCALING

Page 22: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

22Copyright © 2014 by FPT Software

WHY: TYPES OF SCALING

V1

V2

Re-write a service in 2-3 weeks

Page 23: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

23Copyright © 2014 by FPT Software

WHY: ARCHITECTURAL BENEFITS

Small and focused on 1 capability

•Easier to understand

• IDE and deployment faster for 1 service

Independent

•Release and deployment

•Scaling

•Development

Loosely Coupled

•Through lightweight communication

Fault Isolation vs bring all down.

Allows try-out of new technologies.

Re-write can be limited to 1 service

• Impact Analysis stops at boundary

Provide firm module boundaries with explicit interface!

•Less risk on re-write

•Harder to violate boundary in development

Decentralized choreography

•vs central orchestration

•vs central point of failure

Decentralized data

•Polyglot persistence

Page 24: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

24Copyright © 2014 by FPT Software

WHY: ARCHITECTURE EVOLUTION

1 - Key (business) drivers guide architectural decisions

• Micro-services are organized around business capabilities

2 - Postpone decisions to Last Responsible Moment

• Micro-services allow delay of scaling and technological decisions

3 - Architect and develop for Evolvability

• Micro-services support evolution in technology, scaling, and features

Page 25: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

25Copyright © 2014 by FPT Software

MICROSERVICE ARCHITECTURE - HOW-TO?

Concepts

Why?

How?

What?

•Concept

•Technology

Page 26: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

26Copyright © 2014 by FPT Software

HOW-TO: PRINCIPLES OF MICROSERVICES

http://12factor.net/

Page 27: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

27Copyright © 2014 by FPT Software

HOW-TO: Big Picture!

Page 28: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

28Copyright © 2014 by FPT Software

HOW-TO: 7 PRINCIPLES OF MICROSERVICES

Principles Of Microservices

1. Modelled Around

Business Domain

2. Culture Of Automation

3. Hide Implementation

Details

4. DecentraliseAll The Things

5. Deploy Independently

6. Isolate Failure

7. Highly Observable

Page 29: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

29Copyright © 2014 by FPT Software

HOW-TO: 7 PRINCIPLES OF MICROSERVICES

1. Modelled Around Business Domain

Principles Of

Microservices

1. Modelled Around Business Domain

2. Culture Of Automation

3. Hide Implementatio

n Details

4. DecentraliseAll The Things

5. Deploy Independently

6. Isolate Failure

7. Highly Observable

Benefits

Domain modules can migrate independently to next version!

Database schema is internal to the domain bundle, i.e. NOT part of the API!

Persistence and/or database technology can differ between modules in one system!

Page 30: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

30Copyright © 2014 by FPT Software

HOW-TO: 7 PRINCIPLES OF MICROSERVICES

2. Culture Of Automation

Principles Of

Microservices

1. Modelled Around Business Domain

2. Culture Of Automation

3. Hide Implementatio

n Details

4. DecentraliseAll The Things

5. Deploy Independently

6. Isolate Failure

7. Highly Observable

Infrastructure Automation

Automated Testing

Continuous Delivery!

Page 31: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

31Copyright © 2014 by FPT Software

HOW-TO: 7 PRINCIPLES OF MICROSERVICES

3. Hide Implementation Details

Principles Of

Microservices

1. Modelled Around Business Domain

2. Culture Of Automation

3. Hide Implementatio

n Details

4. DecentraliseAll The Things

5. Deploy Independently

6. Isolate Failure

7. Highly Observable

DatabasesBusiness Partner

Vehicle Service

Business Partner Service

Transport Service

DatabasesVehicle Databases

Transport

DatabasesVehicle

Business PartnerTransport

Vehicle App

Business Partner App

Transport App

Vehicle ContextTransport Context

Business Partner Context

Hide Your Database!

Page 32: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

32Copyright © 2014 by FPT Software

HOW-TO: 7 PRINCIPLES OF MICROSERVICES

4. Decentralize All The Things

Principles Of

Microservices

1. Modelled Around Business Domain

2. Culture Of Automation

3. Hide Implementatio

n Details

4. DecentraliseAll The Things

5. Deploy Independently

6. Isolate Failure

7. Highly Observable

What is autonomy?

Giving people as much freedomas possible to do the job at hand

Autonomy!

Self Service

Share Governance

Owner Operator

Internal Open

Source

Dumb-Pipes, Smart

Endpoint

Page 33: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

33Copyright © 2014 by FPT Software

HOW-TO: 7 PRINCIPLES OF MICROSERVICES

5. Deploy Independently

Deployment

One Service

Per-Host

Consumer-Driven

Contracts

Co-Exist Point

Principles Of

Microservices

1. Modelled Around Business Domain

2. Culture Of Automation

3. Hide Implementatio

n Details

4. DecentraliseAll The Things

5. Deploy Independently

6. Isolate Failure

7. Highly Observable

Page 34: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

34Copyright © 2014 by FPT Software

HOW-TO: 7 PRINCIPLES OF MICROSERVICES

6. Isolate Failure

Principles Of

Microservices

1. Modelled Around Business Domain

2. Culture Of Automation

3. Hide Implementatio

n Details

4. DecentraliseAll The Things

5. Deploy Independently

6. Isolate Failure

7. Highly Observable

Page 35: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

35Copyright © 2014 by FPT Software

HOW-TO: 7 PRINCIPLES OF MICROSERVICES

7. Highly Observable

Principles Of

Microservices

1. Modelled Around Business Domain

2. Culture Of Automation

3. Hide Implementatio

n Details

4. DecentraliseAll The Things

5. Deploy Independently

6. Isolate Failure

7. Highly Observable

Correlation IDs

Aggregation

Page 36: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

36Copyright © 2014 by FPT Software

HOW-TO: MICROSERVICE CHALLENGES

Page 37: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

37Copyright © 2014 by FPT Software

HOW-TO: MICROSERVICE CHALLENGES

Communication Between Services

• Use case: New Order Received

Page 38: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

38Copyright © 2014 by FPT Software

HOW-TO: MICROSERVICE CHALLENGES

Handling Failures

• FALLBACK MESSAGE QUEUE

• PER-SERVICE THREAD POOLS

Page 39: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

39Copyright © 2014 by FPT Software

HOW-TO: MICROSERVICE CHALLENGES

Minimising Communicational Overhead

• API GATEWAY

Page 40: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

40Copyright © 2014 by FPT Software

HOW-TO: MICROSERVICE CHALLENGES

Handling Failures in Communication

• CIRCUIT BREAKER

Page 41: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

41Copyright © 2014 by FPT Software

MICROSERVICE ARCHITECTURE - WHAT?

Concepts

Why?

How?

What?

•Concept

•Technology

Page 42: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

42Copyright © 2014 by FPT Software

WHAT: TECHNOLOGY

Microservice Implementation Stack

Page 43: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

43Copyright © 2014 by FPT Software

WHAT: DEPLOYMENT

Deployment Options

Page 44: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

44Copyright © 2014 by FPT Software

WHAT: DEPLOYMENT

Docker - Build, Ship, and Run Any App, Anywhere

Page 45: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

45Copyright © 2014 by FPT Software

WHAT: DEPLOYMENT

Docker - Build, Ship, and Run Any App, Anywhere

Page 46: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

46Copyright © 2014 by FPT Software

WHAT: DEPLOYMENT

DOCKER SOLVES THE NxN PROBLEM

Page 47: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

47Copyright © 2014 by FPT Software

WHAT: DEPLOYMENT

Page 48: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

48Copyright © 2014 by FPT Software

WHAT: DEPLOYMENT

CI - Continuous Integration

Page 49: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

49Copyright © 2014 by FPT Software

WHAT: DEPLOYMENT

Deployment Options

Page 50: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

50Copyright © 2014 by FPT Software

WHAT: BALANCING LOAD

Page 51: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

51Copyright © 2014 by FPT Software

WHAT: METRIC & MONITORING

Page 52: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

52Copyright © 2014 by FPT Software

WHAT: METRIC & MONITORING

Page 53: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

53Copyright © 2014 by FPT Software

CONCLUSION

Advantages of Microservice Architecture

• Each micro service is small and focused on a specific feature / business requirement.

• Microservice can be developed independently by small team of developers (normally 2 to 5 developers).

• Microservice is loosely coupled, means services are independent, in terms of development and deployment both.

• Microservice can be developed using different programming language (Personally I don't suggest to do it).

• Microservice allows easy and flexible way to integrate automatic deployment with Continuous Integration tools (for e.g: Jenkins, Hudson, bamboo etc..).

• The productivity of a new team member will be quick enough.

• Microservice is easy to understand, modify and maintain for a developer because separation of code,small team and focused work.

• Microservice allows you to take advantage of emerging and latest technologies (framework, programming language , programming practice, etc.).

• Microservice has code for business logic only, No mixup with HTML,CSS or other UI component.

• Microservice is easy to scale based on demand.

• Microservice can deploy on commodity hardware or low / medium configuration servers.

• Easy to integrate 3rd party service.

• Every microservice has it's own storage capability but it depends on the project’s requirement, you can have common database like MySQL or Oracle for all services.

Page 54: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

54Copyright © 2014 by FPT Software

CONCLUSION

Disadvantages of Microservice Architecture

• Microservice architecture brings a lot of operations overhead.

• DevOps Skill required (http://en.wikipedia.org/wiki/DevOps).

• Duplication of Effort.

• Distributed System is complicated to manage .

• Default to trace problem because of distributed deployment.

• Complicated to manage whole products when number of services increases.

Page 55: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

55Copyright © 2014 by FPT Software

REFERENCE

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

Microservice architecture patterns and best practices - http://microservices.io/

InfoQ eMag: Microservices - http://www.infoq.com/minibooks/emag-microservices

Micro Services: Java, the Unix Way - http://www.infoq.com/presentations/Micro-Services

Microservices: Decomposing Applications for Deployability and Scalability -http://www.infoq.com/articles/microservices-intro

Microservice Architecture: A Quick Guide- http://java.dzone.com/articles/microservice-architecture

Making Architecture Work in Microservice Organizations -http://tech.gilt.com/post/102628539834/making-architecture-work-in-microservice

Life Preservation for Adaptable Software - https://github.com/russmiles/life-preserver-introductory-article-developer-magazine

The Art of Scalability - http://theartofscalability.com/

Page 56: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

56Copyright © 2014 by FPT Software

Q&A

Page 57: Micro-service Architecture StyleMicro-service Architecture Style ... REFERENCE Microservices ... Microservice architecture patterns and best practices -  · 2016-9-8

57Copyright © 2014 by FPT Software