98
Microservice Architectures Angelo Corsaro, PhD Chief Technology Officer [email protected] with Part-I

Micro services Architecture with Vortex -- Part I

Embed Size (px)

Citation preview

Page 1: Micro services Architecture with Vortex -- Part I

Microservice Architectures

AngeloCorsaro,PhDChiefTechnologyOfficer

[email protected]

with

Part-I

Page 2: Micro services Architecture with Vortex -- Part I

Microservice architectures are one of the latest buzz in software architectures

Let’s try to understand what microservices are and how to build microservice architectures

Page 3: Micro services Architecture with Vortex -- Part I

microserviceS “Microservices are small, autonomous services that work together.” [1]

Page 4: Micro services Architecture with Vortex -- Part I

microservice Architectural

style

“The microservice 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.” [2]

Page 5: Micro services Architecture with Vortex -- Part I

Monolith vs.

microservice

A good way of getting the gist of the microservice architectural style is to

compare it to the more traditional monolithic approach

Page 6: Micro services Architecture with Vortex -- Part I

Monolithic Architectures

Page 7: Micro services Architecture with Vortex -- Part I

Monolithic Architectures

Traditional 3 -Tier architectures with

decomposition based on Technology / Skills

boundaries and modularisation based on

libraries

Client Tier (UI)

Server Tier

Data Tier

Page 8: Micro services Architecture with Vortex -- Part I

Monolithic Architectures

A monolithic applications merges multiple

functionalities in the same executable

Server Tier

Process

Functionality

Page 9: Micro services Architecture with Vortex -- Part I

ChallengesScaling monolithic

applications is challenging as we have just one degree

of freedom to scale out

The same challenge applies to replication

Server Tier

Load Balancer

Page 10: Micro services Architecture with Vortex -- Part I

Server Tier

ChallengesInnovation is constrained by the fact that we cannot

easily mix different technologies for

implementing the various functionalities

Same Technology Stack

Page 11: Micro services Architecture with Vortex -- Part I

Server Tier

ChallengesIncremental Change is

constrained by the fact that can’t incrementally

deploy new functionalities . We need

to redeploy an entire subsystem. Hard to hide internal

details and limit dependencies

Page 12: Micro services Architecture with Vortex -- Part I

ChallengesLoose Coupling and High

Cohesion are harder to achieve and especially to

preserve as the “barriers” between functionalities are

very thin

Server Tier

Module / Library Boundaries

Page 13: Micro services Architecture with Vortex -- Part I

Microservice Architectures

Page 14: Micro services Architecture with Vortex -- Part I

Server Tier

ProcessFunctionality

Microservice ArchitecturesIndividual functionalities

become unit of deployment and run in

their own process

Page 15: Micro services Architecture with Vortex -- Part I

Microservice Architectures

Microservices communicate through

some lightweight mechanism

Server Tier

ProcessFunctionality

Page 16: Micro services Architecture with Vortex -- Part I

Server Tier

BenefitsScaling microservice

applications is easier as we can scale out individual

functionalities

Page 17: Micro services Architecture with Vortex -- Part I

BenefitsUnconstrained Innovation

as we choose the technologies stack that

makes the most sense for implementing a given

feature

Server Tier

ProcessFunctionality

Page 18: Micro services Architecture with Vortex -- Part I

Incremental Change is facilitated allowing

incremental deployment of new functionalities.

Potentially different version of the same micro service could be running at the same time!

Benefits Server Tier

ProcessFunctionality

Page 19: Micro services Architecture with Vortex -- Part I

Loose Coupling and High Cohesion are easier to

achieved to preserve as the “barriers” between functionalities are very

thick

Server Tier

Process Boundary / Share Nothing

Benefits

Page 20: Micro services Architecture with Vortex -- Part I

Performance of microservice architectures

may be degraded by the higher cost of

communication if the right technology is not used

Server Tier

ChallengesMonolithic

Implementation

Microservice Implementation

In-Process Communication

Inter-Process/Host Communication

Page 21: Micro services Architecture with Vortex -- Part I

Deployment and Operation of systems

based on the microservice architectures is inherently more complex, especially

at scale and when the right technologies are not used

Server Tier

ChallengesMonolithic

Implementation

Microservice Implementation

Page 22: Micro services Architecture with Vortex -- Part I

Designing Microservice Architectures

Page 23: Micro services Architecture with Vortex -- Part I

Identifying Microservices

Microservices are supposed to capture business and not

technical features of a system

Microservices

Page 24: Micro services Architecture with Vortex -- Part I

Identifying Microservices

When a monolithic systems is already existing, micro

services can be created by separating the various

features

Microservices

Page 25: Micro services Architecture with Vortex -- Part I

When a system does not exist we can use the Bounded Context as defined in [3]

System Objectives

Microservices

Identifying Microservices Bounded Context

Page 26: Micro services Architecture with Vortex -- Part I

Bounded ContextDomain-Driven Design (DDD) divides a complex domain into a series of

Bounded Context. Where a context means a specific system responsibility, and a bounded context means that responsibility is

enforced with explicit boundaries.

Each bounded context has its own canonical model and communication between bounded context happens through a system-

canonic al model

Page 27: Micro services Architecture with Vortex -- Part I

Microservices are ideally mapped to Bounded Context.

Each Bounded context has potentially its own canonical model

Communication between Bounded Context uses the system-wide

canonical model

Microservicesbounded context

micro-service canonical model

system canonical model

Page 28: Micro services Architecture with Vortex -- Part I

A consequence of applying the Bounded Context technique is

that data management in micro services architectures is

decentralised

Decentralised Data Management

bounded context

micro-service canonical model

system canonical model

Page 29: Micro services Architecture with Vortex -- Part I

Every microservice owns and manages its data without relying

on a shared data-base.

Consequently microservice architectures are build under

eventual consistency assumptions

Decentralised Data Management

bounded context

micro-service canonical model

system canonical model

Page 30: Micro services Architecture with Vortex -- Part I

Any organisation that designs a system (defined broadly) will produce a design whose structure is a copy of the organization's communication structure.

— M. Conway, 1967

Conway’s Law

Page 31: Micro services Architecture with Vortex -- Part I

Conway’s tells us that to be successful in applying

microservice architectures we should have cross-functional

teams organised around business capabilities

Conway’s LAW Implications

image curtesy of M. Fowler http://martinfowler.com/articles/microservices.html

Page 32: Micro services Architecture with Vortex -- Part I

(This is an adaptation of a Figure from [1])

Microservices small autonomous

services

Modelled around business concepts

Highly AutomatedHide internal implementation

details

DecentralisedIndependent Deployment

Failure Isolation

Highly Observable

Stateless

Page 33: Micro services Architecture with Vortex -- Part I

Vortex Overview

Page 34: Micro services Architecture with Vortex -- Part I

Vortex's Coordination Model

Page 35: Micro services Architecture with Vortex -- Part I

Applications can autonomously and asynchronously read and

write data enjoying spatial and temporal decoupling

DDS Global Data Space

...

Data Writer

Data Writer

Data Writer

Data Reader

Data Reader

Data Reader

Data Reader

Data Writer

TopicAQoS

TopicBQoS

TopicCQoS

TopicDQoS

Global Data Space

Page 36: Micro services Architecture with Vortex -- Part I

Built-in dynamic discovery isolates applications from

network topology and connectivity details

DDS Global Data Space

...

Data Writer

Data Writer

Data Writer

Data Reader

Data Reader

Data Reader

Data Reader

Data Writer

TopicAQoS

TopicBQoS

TopicCQoS

TopicDQoS

Dynamic Discovery

Page 37: Micro services Architecture with Vortex -- Part I

Topic

Page 38: Micro services Architecture with Vortex -- Part I

A domain-wide information’s class A Topic defined by means

of a <name, type, qos>

TopicDDS Global Data Space

...

Data Writer

Data Writer

Data Writer

Data Reader

Data Reader

Data Reader

Data Reader

Data Writer

TopicAQoS

TopicBQoS

TopicCQoS

TopicDQoS

TopicTypeName

QoS

Page 39: Micro services Architecture with Vortex -- Part I

Topic Types

Page 40: Micro services Architecture with Vortex -- Part I

Topic Types: Language Independent

Definitions

Page 41: Micro services Architecture with Vortex -- Part I

Topic types can be expressed using different syntaxes,

including IDL and ProtoBuf

Topic Type struct CarDynamics { string cid; long x; long y; float dx; long dy; } #pragma keylist CarDynamics cid

IDL

Page 42: Micro services Architecture with Vortex -- Part I

Topic types can be expressed using different syntaxes,

including IDL and ProtoBuf

Topic Type message CarDynamics { option (.omg.dds.type) = {name: "CarDynamics"}; required string cid = 0 [(.omg.dds.member).key = true]; required long x = 1; required long y = 2; required float dx = 3; required long dy = 4; }

ProtoBuf

Page 43: Micro services Architecture with Vortex -- Part I

Topic Types: Language Specific

Definitions

Page 44: Micro services Architecture with Vortex -- Part I

Topic types can be expressed using different syntaxes,

including IDL and ProtoBuf

Topic Type class CarDynamics: constructor: (@cid, @x, @y, @dx, @dy) ->

CoffeeScript

Page 45: Micro services Architecture with Vortex -- Part I

Topic types can be expressed using different syntaxes,

including IDL and ProtoBuf

Topic Type public struct CaDynamics { public string cid { get; set; } public int x { get; set; } public int y { get; set; } public int dx { get; set; } public int dy { get; set; } public CaDynamics (string cid, int x, int y, int dx, int dy) { this.cid = cid; this.x = x; this.y = y; this.dx = dx; this.dy = dy; } }

C#

Page 46: Micro services Architecture with Vortex -- Part I

Topic types can be expressed using different syntaxes,

including IDL and ProtoBuf

Topic Type @KeyList ( topicType = "CarDynamics", keys = {"cid"})public class CarDynamics { public String cid; public int x; public int dx; public int y; public int dy; public CarDynamics(String s, int a, int b, int c,int d) { this.cid = s; this.x = a; this.dx = b; this.y = c; this.dy = d; } @Override public String toString() { … }}

Java

Page 47: Micro services Architecture with Vortex -- Part I

TopicAQoS

TopicCQoS ...

TopicBQoS

TopicDQoS

PartitionsThe Global Data Space can be

divided in to arbitrary partitions

The source and destination of data is identified by means of “Partition/Topic” expressions

“Red”

“Blue”

Page 48: Micro services Architecture with Vortex -- Part I

QoS policies allow to express temporal and availability

constraints for data

DDS Global Data Space

...

Data Writer

Data Writer

Data Writer

Data Reader

Data Reader

Data Reader

Data Reader

Data Writer

TopicAQoS

TopicBQoS

TopicCQoS

TopicDQoS

QoS - Enabled

Page 49: Micro services Architecture with Vortex -- Part I

A collection of policies that control non-

functional properties such as reliability,

persistence, temporal constraints and priority

QoS

HISTORY

LIFESPAN

DURABILITY

DEADLINE

LATENCY BUDGET

TRANSPORT PRIO

TIME-BASED FILTER

RESOURCE LIMITS

USER DATA

TOPIC DATA

GROUP DATA

OWENERSHIP

OWN. STRENGTH

LIVELINESS

ENTITY FACTORY

DW LIFECYCLE

DR LIFECYCLE

PRESENTATION

RELIABILITY

PARTITION

DEST. ORDER

RxO QoS Local QoS

Page 50: Micro services Architecture with Vortex -- Part I

QoS Policies controlling end-to-end properties

follow a Request vs. Offered

QoS Domain

Participant

DURABILITY

OWENERSHIP

DEADLINE

LATENCY BUDGET

LIVELINESS

RELIABILITY

DEST. ORDER

Publisher

DataWriter

PARTITION

DataReader

Subscriber

DomainParticipant

offered QoS

Topicwrites reads

Domain Idjoins joins

produces-in consumes-from

RxO QoS Policies

requested QoS

Page 51: Micro services Architecture with Vortex -- Part I

Interacting with the Data Cache

Page 52: Micro services Architecture with Vortex -- Part I

Each Data Reader is associated with a Cache

The Cache stores the last n∊𝜨∞ samples for each

relevant instance

Data Cache

DataReader Cache

DataReader

...

Samples

Instances

Cache

Where: 𝜨∞=𝜨 ∪ {∞}

Page 53: Micro services Architecture with Vortex -- Part I

The action of reading samples for a Reader Cache

is non-destructive.

Samples are not removed from the cache

Reading Data

DataReader Cache

DataReader

...

DataReader Cache

DataReader

...read

Page 54: Micro services Architecture with Vortex -- Part I

The action of taking samples for a Reader Cache

is destructive.

Samples are removed from the cache

Taking Data

DataReader Cache

DataReader

...

DataReader Cache

DataReader

...take

Page 55: Micro services Architecture with Vortex -- Part I

Samples can be selected using composable content

and status predicates

Sample Selectors

DataReader Cache

DataReader

...

Page 56: Micro services Architecture with Vortex -- Part I

Filters allow to control what gets into a DataReader

cache

Filters are expressed as SQL where clauses or as

Java/C/JavaScript predicates

Content-Filtering

DataReader Cache

DataReader

...

Filter

Application

Network

Page 57: Micro services Architecture with Vortex -- Part I

Content Filters can be used to project on the

local cache only the Topic data

satisfying a given predicate

Content Filters structCarDynamics{

@keystringcid;longx;longy;floatdx;longdy;}

cid x y dx dyGR 33N GO 167 240 45 0LO 00V IN 65 26 65 0AN 637 OS 32 853 0 50AB 123 CD 325 235 80 0

“dx>50ORdy>50”

Type

CarDynamics

cid x y dx dyLO 00V IN 65 26 65 0AB 123 CD 325 235 80 0

Reader Cache

Page 58: Micro services Architecture with Vortex -- Part I

Queries allow to control what gets out of a

DataReader Cache

Queries are expressed as SQL where clauses or as

Java/C/JavaScript predicates

Content-Based Selection

DataReader Cache

DataReader

...

Query

DataReader Cache

DataReader

...

Application

Network

Page 59: Micro services Architecture with Vortex -- Part I

Reader Cache

Queries can be used to select out of the local cache

the data matching a given predicate

QueriesstructCarDynamics{@keystringcid;longx;longy;floatdx;longdy;}

cid x y dx dyGR 33N GO 167 240 45 0LO 00V IN 65 26 65 0AN 637 OS 32 853 0 50AB 123 CD 325 235 80 0

“dx>50ORdy>50”

Type

CarDynamics

cid x y dx dyGR 33N GO 167 240 45 0LO 00V IN 65 26 65 0AN 637 OS 32 853 0 50AB 123 CD 325 235 80 0

cid x y dx dyLO 00V IN 65 26 65 0AB 123 CD 325 235 80 0

query

Page 60: Micro services Architecture with Vortex -- Part I

State based selection allows to control what gets out of a DataReader Cache

State base selectors predicate on samples meta-

information

State-Based Selection

DataReader Cache

DataReader

...

State Selector

DataReader Cache

DataReader

...

Application

Network

Page 61: Micro services Architecture with Vortex -- Part I

Selector Example

// == ISO C++ DDS API ==

auto data = dr.select() .content(query) .state(data_state) .instance(handle) .read();

Page 62: Micro services Architecture with Vortex -- Part I

your first vortex app

Page 65: Micro services Architecture with Vortex -- Part I

Cop

yrig

ht P

rism

Tech

, 201

5

Reading Data in C++#include <dds.hpp>

int main(int, char**) {

DomainParticipant dp(0); Topic<Meter> topic(”SmartMeter”); Subscriber sub(dp); DataReader<Meter> dr(dp, topic);

LambdaDataReaderListener<DataReader<Meter>> lst; lst.data_available = [](DataReader<Meter>& dr) { auto samples = data.read(); std::for_each(samples.begin(), samples.end(), [](Sample<Meter>& sample) { std::cout << sample.data() << std::endl; } } dr.listener(lst); // Print incoming data up to when the user does a Ctrl-C std::this_thread::join(); return 0; }

enumUtilityKind{ ELECTRICITY, GAS, WATER};structMeter{ stringsn; UtilityKindutility; floatreading; floaterror;};#pragmakeylistMetersn

Page 70: Micro services Architecture with Vortex -- Part I

Vortex Technology Stack

Page 71: Micro services Architecture with Vortex -- Part I

Device implementations optimised for OT, IT and

consumer platforms

Native support for Cloud and Fog Computing Architectures

Device-2-DeviceDevice-2-Cloud

Fog-2-Cloud

Device-2-Fog

Cloud-2-Cloud

Fog-2-Fog

infra

stru

ctur

esd

k

Page 72: Micro services Architecture with Vortex -- Part I

Vortex-Based Microservices

Page 73: Micro services Architecture with Vortex -- Part I

Microservices are ideally mapped to Bounded Context.

Each Bounded context has potentially its own canonical model

Communication between Bounded Context uses the system-wide

canonical model

Bounded contextbounded context

micro-service Vortex Data Model

system canonical Vortex Data model

Page 74: Micro services Architecture with Vortex -- Part I

micro-service partition

system partition

micro-service data model

system (inter-svc) data model

Page 75: Micro services Architecture with Vortex -- Part I

Benefits

Page 76: Micro services Architecture with Vortex -- Part I

Decentralised Infrastructure

Page 77: Micro services Architecture with Vortex -- Part I

The relevant portion of the data space is projected on the

application address space. Each typed projection is commonly called

a Cache

No single point of failure or bottleneck

No central server to configure/ manage

Decentralised Data Space

Data Writer

Data Writer

Data Writer

Data Reader

Data Reader

Data Reader

Data Writer

TopicAQoS

TopicBQoS

TopicCQoS

TopicDQoS

TopicDQoS

TopicDQoS

TopicAQoS

Page 78: Micro services Architecture with Vortex -- Part I

Persistence

Page 79: Micro services Architecture with Vortex -- Part I

Vortex provides a high performance distributed

durability service that can be used to achieve different level

of temporal decoupling

Durability Services take ownership for “Partition/Topic “

expressions

Distributed Durability

Page 80: Micro services Architecture with Vortex -- Part I

Performance

Page 81: Micro services Architecture with Vortex -- Part I

High Performance 30 μs peer-to-peer latency

7 μs inter-core latency

4+ Mmsgs/sec p2p throughput

Device-2-DeviceDevice-2-Cloud

Fog-2-Cloud

Device-2-Fog

Cloud-2-Cloud

Fog-2-Fog

infra

stru

ctur

esd

k

Page 82: Micro services Architecture with Vortex -- Part I

<10 μs fog/cloud routing latency

High Performance Device-2-DeviceDevice-2-Cloud

Fog-2-Cloud

Device-2-Fog

Cloud-2-Cloud

Fog-2-Fog

infra

stru

ctur

esd

k

Page 83: Micro services Architecture with Vortex -- Part I

Deployment Fexibility

Page 84: Micro services Architecture with Vortex -- Part I

Microservice deployment

The common guideline for Microservices is to deploy

them across different hosts to limit the impact of a

failing machine

Page 85: Micro services Architecture with Vortex -- Part I

Microservice deployment

The one micro-service per host rule can be

constraining in terms of performance

Page 86: Micro services Architecture with Vortex -- Part I

Microservice deployment

Vortex location transparency and intra-host

communication optimisation allow to exploit the benefits

of micro-service architectures without major

performance costsUltra-Low Latency

Inter-Process Comm

Page 87: Micro services Architecture with Vortex -- Part I

Technology Agnostic

Page 88: Micro services Architecture with Vortex -- Part I

Vortex is a Polyglot and Interoperable across

Programming Languages Device-2-DeviceDevice-2-Cloud

Fog-2-Cloud

Device-2-Fog

Cloud-2-Cloud

Fog-2-Fog

infra

stru

ctur

esd

k

Page 89: Micro services Architecture with Vortex -- Part I

Fully Independent of the Cloud Infrastructure

Private Clouds

Device-2-DeviceDevice-2-Cloud

Fog-2-Cloud

Device-2-Fog

Cloud-2-Cloud

Fog-2-Fog

infra

stru

ctur

esd

k

Page 90: Micro services Architecture with Vortex -- Part I

Native Integration with the hottest real-time analytics

platforms and CEP Device-2-DeviceDevice-2-Cloud

Fog-2-Cloud

Device-2-Fog

Cloud-2-Cloud

Fog-2-Fog

infra

stru

ctur

esd

k

Page 91: Micro services Architecture with Vortex -- Part I

Integration with mainstream Dashboard Technologies

Device-2-DeviceDevice-2-Cloud

Fog-2-Cloud

Device-2-Fog

Cloud-2-Cloud

Fog-2-Fog

infra

stru

ctur

esd

k

Page 92: Micro services Architecture with Vortex -- Part I

Native Support for Microservices

Patterns

Page 93: Micro services Architecture with Vortex -- Part I

TimeoutAs a general rule Vortex APIs

are non-blocking

Blocking API calls are all equipped with timeout

#include <dds.hpp>

int main(int, char**) {

DomainParticipant dp(0); Topic<Meter> topic(“SmartMeter”); Publisher pub(dp); DataWriter<Meter> dw(pub, topic);

while (!done) { auto value = readMeter() dw.write(value); std::this_thread::sleep_for(SAMPLING_PERIOD); }

return 0; }

Page 94: Micro services Architecture with Vortex -- Part I

Worker PatternVortex provides several ways of supporting the

worker pattern

Page 95: Micro services Architecture with Vortex -- Part I

CIRCUIT BREAKERVortex communications primitive implement the

circuit breaker pattern thus reducing the complexity of

adopting it

Page 96: Micro services Architecture with Vortex -- Part I

Microservices architectures bring several architectural benefits

Vortex ensures that the operational and performance cost of adopting micro services architectures if minimised

In Summary

Page 98: Micro services Architecture with Vortex -- Part I

Cop

yrig

ht P

rism

Tech

, 201

5