prismtech microservice architectures with vortex part 2

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

Upload: prismtech

Post on 16-Apr-2017

584 views

Category:

Software


1 download

TRANSCRIPT

Page 1: PrismTech Microservice Architectures with Vortex Part 2

Microservice Architectures

AngeloCorsaro,PhDChiefTechnologyOfficer

[email protected]

with

Part-II

Page 2: PrismTech Microservice Architectures with Vortex Part 2

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 3: PrismTech Microservice Architectures with Vortex Part 2

Microservice Architectures

Page 4: PrismTech Microservice Architectures with Vortex Part 2

Server Tier

ProcessFunctionality

Microservice ArchitecturesIndividual functionalities

become unit of deployment and run in

their own process

Page 5: PrismTech Microservice Architectures with Vortex Part 2

Microservice Architectures

Microservices communicate through

some lightweight mechanism

Server Tier

ProcessFunctionality

Page 6: PrismTech Microservice Architectures with Vortex Part 2

Server Tier

BenefitsScaling microservice

applications is easier as we can scale out individual

functionalities

Page 7: PrismTech Microservice Architectures with Vortex Part 2

BenefitsUnconstrained Innovation

as we choose the technologies stack that

makes the most sense for implementing a given

feature

Server Tier

ProcessFunctionality

Page 8: PrismTech Microservice Architectures with Vortex Part 2

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 9: PrismTech Microservice Architectures with Vortex Part 2

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 10: PrismTech Microservice Architectures with Vortex Part 2

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 11: PrismTech Microservice Architectures with Vortex Part 2

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 12: PrismTech Microservice Architectures with Vortex Part 2

Designing Microservice Architectures

Page 13: PrismTech Microservice Architectures with Vortex Part 2

Identifying Microservices

Microservices are supposed to capture business and not

technical features of a system

Microservices

Page 14: PrismTech Microservice Architectures with Vortex Part 2

Identifying Microservices

When a monolithic systems is already existing, micro

services can be created by separating the various

features

Microservices

Page 15: PrismTech Microservice Architectures with Vortex Part 2

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

System Objectives

Microservices

Identifying Microservices Bounded Context

Page 16: PrismTech Microservice Architectures with Vortex Part 2

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 17: PrismTech Microservice Architectures with Vortex Part 2

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 18: PrismTech Microservice Architectures with Vortex Part 2

Case Study

Page 19: PrismTech Microservice Architectures with Vortex Part 2

microcosmos

Page 20: PrismTech Microservice Architectures with Vortex Part 2

Let’s imagine that we are part of a team that has to

design the next massive online gaming platform

For simplicity we’ll consider a 2D adventure game

microcosmos

Page 21: PrismTech Microservice Architectures with Vortex Part 2

requirements

Page 22: PrismTech Microservice Architectures with Vortex Part 2

Scalability The architecture should be designed to promote scale-out as opposed to scale up

Page 23: PrismTech Microservice Architectures with Vortex Part 2

Loose Coupling Features should be completely isolated from each other in time and space

Page 24: PrismTech Microservice Architectures with Vortex Part 2

Unconstrained Innovation

Innovation should not be constrained with respect to supporting new input kinds, new target platforms, new visualisation engines, new strategies, game engines, etc.

Additionally, functionalities should be implemented in the most effective programming language

Page 25: PrismTech Microservice Architectures with Vortex Part 2

Incremental Change

The gaming platform should be as modular as possible to facilitate the individual functionalities updates and upgrade

Additionally, adding new features should be as much as possible transparent for the currently running system

Page 26: PrismTech Microservice Architectures with Vortex Part 2

Performance The game should be able to run at 60 frames per second

Page 27: PrismTech Microservice Architectures with Vortex Part 2

Fault-Tolerance The gaming platform should be self-healing

Page 28: PrismTech Microservice Architectures with Vortex Part 2

identifying functionalities

Page 29: PrismTech Microservice Architectures with Vortex Part 2

Physics Engine Load Balancing

User Input Game Output Strategy

Bodies

Scene Analytics …

Page 30: PrismTech Microservice Architectures with Vortex Part 2

Variability Analysis

User Input

Keyboard

Mouse

Gyro + Accelerometer

Joystick

Page 31: PrismTech Microservice Architectures with Vortex Part 2

Variability Analysis

Game Output

PC Screen

Hololens

Mobile APP

Web App

Page 32: PrismTech Microservice Architectures with Vortex Part 2

Variability Analysis

Load Balancing

Density-Based

Random

Geographical

Page 33: PrismTech Microservice Architectures with Vortex Part 2

Load BalancingThe run-time gaming

platform configuration should reflect the load and optimise against it

Page 34: PrismTech Microservice Architectures with Vortex Part 2

Physics Engine

Physics Engine

Physics Engine

Physics Engine

Physics Engine

Physics Engine

Physics Engine

Physics Engine

Physics Engine

Physics Engine

Load BalancingAs an example

frequency based load balancing may partition

the game space depending on frequency

of users in a give n area

Page 35: PrismTech Microservice Architectures with Vortex Part 2

system canonical model

Page 36: PrismTech Microservice Architectures with Vortex Part 2

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 37: PrismTech Microservice Architectures with Vortex Part 2

Physics Engine Load Balancing User Input

Game Output Strategy

Bodies

Scene Analytics …

Canonical Data Model

Page 38: PrismTech Microservice Architectures with Vortex Part 2

Modeling Idioms

Page 39: PrismTech Microservice Architectures with Vortex Part 2

A state that is periodically updated

Examples are the reading of a sensor (e.g. Temperature Sensor), the

position of a vehicle, etc.

Soft StateReliability=>BestEffortDurability=>VolatileHistory=>KeepLast(n)Deadline=>updatePeriodLatencyBudget=>updatePeriod/3DestinationOrder=>SourceTimestamp

Page 40: PrismTech Microservice Architectures with Vortex Part 2

A state that is sporadically updated and that often has temporal

persistence requirements

Examples are system configuration, a price estimate, etc.

Hard StateReliability=>ReliableDurability=>Transient|PersistentHistory=>KeepLast(n)DestinationOrder=>SourceTimestamp

Page 41: PrismTech Microservice Architectures with Vortex Part 2

The occurrence of something noteworthy for our system

Examples are a collision alert, the temperature beyond a given

threshold, etc.

EventsReliability=>ReliableDurability=>anyHistory=>KeepAllDestinationOrder=>SourceTimestamp

Page 42: PrismTech Microservice Architectures with Vortex Part 2

Data-centric design leverage the same principle of Feedback-control

loops to assert a state

In other terms, the desired state is asserted by writing a topic and the

actual state is monitored.

A control action is taken when the desired and the actual state differ

Feedback Control Loop

Page 43: PrismTech Microservice Architectures with Vortex Part 2

Data-centric design leverage the same principle of Feedback-control

loops to assert a state

In other terms, the desired state is asserted by writing a topic and the

actual state is monitored.

A control action is taken when the desired and the actual state differ

Feedback Control Loop Hard State

Soft State

microservice

Page 44: PrismTech Microservice Architectures with Vortex Part 2

Data Model

Page 45: PrismTech Microservice Architectures with Vortex Part 2

struct UUID { long long low; long long high; }; enum FixtureKind { CAPSULE_KIND, CIRCLE_KIND, E_TRIANGLE_KIND, I_TRIANGLE_KIND, R_TRIANGLE_KIND, RECTANGLE_KIND }; struct Circle { float radius; }; struct Rectangle { float widht; float height; }; struct Capsule { float widht; float height; }; struct RightTriangle { float base; float height; }; struct IsoscelesTriangle { float base; float height; }; struct EquilateralTriangle { float side; };

One of the class of concepts we need to represent in our Canonical Data

Model are the graphical entities that we may use to define the “world” as well as the bodies/objects that are

rendered and animated within the “world”

To keep our example simple, we will assume that our game can be built

with simple geometrical shapes

Geometry

union Fixture switch (FixtureKind) { case CAPSULE_KIND: Capsule capsule; case CIRCLE_KIND: Circle circle; case E_TRIANGLE_KIND: EquilateralTriangle etriangle; case I_TRIANGLE_KIND: IsoscelesTriangle itriangle; case R_TRIANGLE_KIND: RightTriangle rtriangle; case RECTANGLE_KIND: Rectangle rectangle; }; struct Color { long r; long g; long b; }; struct Vector2 { float x; float y; };

Hard State

Page 46: PrismTech Microservice Architectures with Vortex Part 2

Worlds need to be discovered and Body have to be defined

Body and World struct World { UUID worldId; Vector2 p0; Vector2 p1; }; #pragma keylist World worldId.low worldId.high struct Body { UUID bodyId; UUID worldId; float mass; Vector2 ipos; // initial position Fixture fixture; Color color; }; #pragma keylist Body bodyId.low bodyId.high

Hard State

Page 47: PrismTech Microservice Architectures with Vortex Part 2

Action need to be performed such as adding bodies to a world, removing

them or moving those around

Another example is applying forces to body, or causing change in their fixture

(e.g. as a result of a collision)

Actuation struct Body { UUID bodyId; UUID worldId; float mass; Vector2 ipos; // initial position Fixture fixture; Color color; }; #pragma keylist Body bodyId.low bodyId.high

struct BodyAction { UUID bodyId; Vector2 value; }; #pragma keylist BodyTelemetry bodyId.low bodyId.high

Page 48: PrismTech Microservice Architectures with Vortex Part 2

The state of the system has to be sensed in order to react to it.

Different telemetry topics are defined, such as BodyPos, BodyVelocity,

BodyForce, etc. that rely on the same underlying type

Sensing

struct BodyTelemetry { UUID bodyId; Vector2 value; }; #pragma keylist BodyTelemetry bodyId.low bodyId.high

Soft State

Page 49: PrismTech Microservice Architectures with Vortex Part 2

Relevant events also need to be modelled to allow for appropriate

actions to be taken.

Events struct CollisionEvent { UUID a; UUID b; Vector2 contact; }; #pragma keylist CollisionEvent

Event

Page 50: PrismTech Microservice Architectures with Vortex Part 2

Physics Engine Load Balancing User InputBodies

Game Output StrategyScene Analytics …

Cano

nica

l Dat

a Mod

el

microcosmos:telemetrymicrocosmos:actuationBody

WorldWorldClock

BodySpeed

BodyPosition

BodySpeed

BodyPosition

BodyForce

microcosmos:telemetry

CollisionBegin

CollisionEnd

Page 51: PrismTech Microservice Architectures with Vortex Part 2

Live Demo

Page 52: PrismTech Microservice Architectures with Vortex Part 2

Physics Engine Load Balancing User InputBodies

Game Output StrategyScene Analytics …

Cano

nica

l Dat

a Mod

el microcosmos:telemetrymicrocosmos:actuationBody

WorldWorldClock

BodySpeed

BodyPosition

BodySpeed

BodyPosition

BodyForce

microcosmos:telemetry

CollisionBegin

CollisionEndBodyForce

Page 53: PrismTech Microservice Architectures with Vortex Part 2

Vortex-Based Microservices Key Benefits

Page 54: PrismTech Microservice Architectures with Vortex Part 2

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 55: PrismTech Microservice Architectures with Vortex Part 2

Decentralised Infrastructure

Page 56: PrismTech Microservice Architectures with Vortex Part 2

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 57: PrismTech Microservice Architectures with Vortex Part 2

Persistence

Page 58: PrismTech Microservice Architectures with Vortex Part 2

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 59: PrismTech Microservice Architectures with Vortex Part 2

Performance

Page 60: PrismTech Microservice Architectures with Vortex Part 2

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 61: PrismTech Microservice Architectures with Vortex Part 2

<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 62: PrismTech Microservice Architectures with Vortex Part 2

Deployment Fexibility

Page 63: PrismTech Microservice Architectures with Vortex Part 2

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 64: PrismTech Microservice Architectures with Vortex Part 2

Technology Agnostic

Page 65: PrismTech Microservice Architectures with Vortex Part 2

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 66: PrismTech Microservice Architectures with Vortex Part 2

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 67: PrismTech Microservice Architectures with Vortex Part 2

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 68: PrismTech Microservice Architectures with Vortex Part 2

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 69: PrismTech Microservice Architectures with Vortex Part 2

Native Support for Microservices

Patterns

Page 70: PrismTech Microservice Architectures with Vortex Part 2

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 71: PrismTech Microservice Architectures with Vortex Part 2

Worker PatternVortex provides several ways of supporting the

worker pattern

Page 72: PrismTech Microservice Architectures with Vortex Part 2

CIRCUIT BREAKERVortex communications primitive implement the

circuit breaker pattern thus reducing the complexity of

adopting it

Page 73: PrismTech Microservice Architectures with Vortex Part 2

Microservices architectures bring several architectural benefits

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

In Summary

Page 75: PrismTech Microservice Architectures with Vortex Part 2

Cop

yrig

ht P

rism

Tech

, 201

5