microservice-based software architecture

36
Microservice-based software architecture Michael Hackstein @mchacki November 23, 2014 www.arangodb.com

Upload: arangodb

Post on 09-Jul-2015

608 views

Category:

Software


1 download

DESCRIPTION

Following the classical software architecture patterns we tend to design large monolith of software applications. These monoliths are typically quite difficult to scale as they often require powerful machines, making the option to scale out very expensive. In most cases these monoliths of software are designed to run on a single machine only, hence scaling out is complicated or even impossible without refactoring large portions of the application. Therefore a new design pattern called microservices arose. The pattern of microservices keeps the need of a clustered server setup in mind and helps to keep the application very modular. This allows to simplify a scale out of your application and even allows to scale the bottlenecks of your application only and hence reducing the total cost for a scale out approach. In this talk I will introduce the concept of microservices, how they are defined and how to design an application with them. Furthermore I will show how to scale the application properly and why this is only possible due to the use of microservices. Also we will have a look at Node.js and why it is a perfect, though not the only, fit to this design strategy. However scaling is not the only purpose of microservices, they also increase the flexibility and maintainability of applications, this will also be discussed in the talk.

TRANSCRIPT

Page 1: Microservice-based software architecture

Microservice-based softwarearchitecture

Michael Hackstein@mchacki

November 23, 2014

www.arangodb.com

Page 2: Microservice-based software architecture

Michael Hackstein

ArangoDB Core TeamWeb FrontendGraph visualisationGraph features

Host of cologne.js

Master’s Degree(spec. Databases andInformation Systems)

1

Page 3: Microservice-based software architecture

Monolithic Applications

One large applicationIn most cases designed to run on one serverLoose coupling of objects due to object orientation

2

Page 4: Microservice-based software architecture

Drawbacks

Grows large over timeHard to maintain, refactoring expensiveTypically written in one language

Hard to scale-outProbably contains local state informationCan only be scaled as a whole“Hot-spots” require multi-threaded implementation

High basic hardware requirementsParts of the app is CPU intensiveParts of the app is RAM intensiveBoth have to be large

3

Page 5: Microservice-based software architecture

Drawbacks

Grows large over timeHard to maintain, refactoring expensiveTypically written in one languageHard to scale-out

Probably contains local state informationCan only be scaled as a whole“Hot-spots” require multi-threaded implementation

High basic hardware requirementsParts of the app is CPU intensiveParts of the app is RAM intensiveBoth have to be large

3

Page 6: Microservice-based software architecture

Drawbacks

Grows large over timeHard to maintain, refactoring expensiveTypically written in one languageHard to scale-out

Probably contains local state informationCan only be scaled as a whole“Hot-spots” require multi-threaded implementation

High basic hardware requirementsParts of the app is CPU intensiveParts of the app is RAM intensiveBoth have to be large

3

Page 7: Microservice-based software architecture

Microservices philosophy

“Bring object orientation to architecture”Designed to run in a cluster of serversDefine many services, each for one purpose onlyEach microservice offers a documented public APIA microservice can make use of other microservicesEach service should not have a large code base

“Smart endpoints and dumb pipes”BUT: Do not overdo it. (Function 6= Microservice)

4

Page 8: Microservice-based software architecture

Microservices philosophy

“Bring object orientation to architecture”Designed to run in a cluster of serversDefine many services, each for one purpose onlyEach microservice offers a documented public APIA microservice can make use of other microservicesEach service should not have a large code base“Smart endpoints and dumb pipes”

BUT: Do not overdo it. (Function 6= Microservice)

4

Page 9: Microservice-based software architecture

Microservices philosophy

“Bring object orientation to architecture”Designed to run in a cluster of serversDefine many services, each for one purpose onlyEach microservice offers a documented public APIA microservice can make use of other microservicesEach service should not have a large code base“Smart endpoints and dumb pipes”

BUT: Do not overdo it. (Function 6= Microservice)

4

Page 10: Microservice-based software architecture

Benefits and CostsImplemented indepen-dently from one anotherSingle-threaded implemen-tationEach might use a differentlanguageSeamless replacement bynew implementation“Hot-spots” individually scal-ableSpecific server configura-tion per serviceHighly flexible

Communication overheadRequires load balancingNeed to get used to Archi-tectureImprecise definition so far

5

Page 11: Microservice-based software architecture

Benefits and CostsImplemented indepen-dently from one anotherSingle-threaded implemen-tationEach might use a differentlanguageSeamless replacement bynew implementation“Hot-spots” individually scal-ableSpecific server configura-tion per serviceHighly flexible

Communication overheadRequires load balancingNeed to get used to Archi-tectureImprecise definition so far

5

Page 12: Microservice-based software architecture

Architecture

Application

6

Page 13: Microservice-based software architecture

Architecture

Application

6

Page 14: Microservice-based software architecture

Architecture

Load Balancer

µS µS µS

6

Page 15: Microservice-based software architecture

Architecture

Load Balancer

µS µS µS

µS µS µS

6

Page 16: Microservice-based software architecture

Architecture

Load Balancer

µS µS µS

µS µS µS

6

Page 17: Microservice-based software architecture

Scaling

µS µSµS

7

Page 18: Microservice-based software architecture

Scaling

µS µSµS

Load Balancer

7

Page 19: Microservice-based software architecture

Scaling

µS µSµS

Load Balancer

µS µS

7

Page 20: Microservice-based software architecture

Communication Layers

µS µS µS

µS µS µS

8

Page 21: Microservice-based software architecture

Communication Layers

µS µS µS

µS µS µS

Load Balancer

8

Page 22: Microservice-based software architecture

Communication Layers

µS µS µS

µS µS µS

Load Balancer

8

Page 23: Microservice-based software architecture

Advises

You pay with network trafficKeep the tree as flat as possibleRequest async. in parallel wherever possibleYou should always have a treeNo circles, no communication within the same layer

9

Page 24: Microservice-based software architecture

Node.js a perfect match?

Node.js can be set up fastFollows a single-threaded architectureGood tooling to build REST interfacesScaling pattern is equal

BUT Not the only option: Rails, Java, Erlang, . . .Select the language that fits best

10

Page 25: Microservice-based software architecture

Node.js a perfect match?

Node.js can be set up fastFollows a single-threaded architectureGood tooling to build REST interfacesScaling pattern is equalBUT Not the only option: Rails, Java, Erlang, . . .Select the language that fits best

10

Page 26: Microservice-based software architecture

The database Layer

There are several microservices that form a Data Access Layer.Very little logic in the service, basically data access.Abstraction is used to get more independent from DB technol-ogy.If you switch DB only reimplement this service and migrate data.

Life-cycle equal to the DB technology.Scales similar as the DB in terms of computation.Data content can scale differently.

11

Page 27: Microservice-based software architecture

The database Layer

There are several microservices that form a Data Access Layer.Very little logic in the service, basically data access.Abstraction is used to get more independent from DB technol-ogy.If you switch DB only reimplement this service and migrate data.Life-cycle equal to the DB technology.Scales similar as the DB in terms of computation.Data content can scale differently.

11

Page 28: Microservice-based software architecture

ArangoDB Cluster Setup

Coordinator Coordinator

DBServer DBServer DBServer

12

Page 29: Microservice-based software architecture

ArangoDB Cluster Setup

Coordinator Coordinator

DBServer DBServer DBServer

12

Page 30: Microservice-based software architecture

ArangoDB Cluster Setup

Coordinator Coordinator

DBServer DBServer DBServer

12

Page 31: Microservice-based software architecture

ArangoDB Cluster Setup

Coordinator Coordinator

DBServer DBServer DBServer

12

Page 32: Microservice-based software architecture

ArangoDB Foxx

Execute JavaScript code directly on the database.Extend ArangoDB API.Foxx is executed on coordinators.Move data access microservice into the DB.Scale data content and computation independently.Reduce the microservice tree by one level.

13

Page 33: Microservice-based software architecture

Architecture Revisited

Load Balancer

µS µS µS

µS µS µS

14

Page 34: Microservice-based software architecture

Architecture Revisited

Load Balancer

µS µS µS

µS

14

Page 35: Microservice-based software architecture

Architecture Revisited

Load Balancer

µS µS µS

µS

14

Page 36: Microservice-based software architecture

Thank you

Further Questions?Follow me on twitter/github: @mchackiWrite me a mail: [email protected] @arangodb on TwitterJoin our google group:https://groups.google.com/forum/#!forum/arangodb

Visit our blog https://www.arangodb.com/blogSlides available at https://www.slideshare.net/arangodb

15