24
Microservices A brief introduction to services and microservices

Microservices

Embed Size (px)

Citation preview

Page 1: Microservices

MicroservicesA brief introduction to services and microservices

Page 2: Microservices

What is a service?“a mechanism to enable access to one or more capabilities, where the access is provided using a prescribed interface and is exercised consistent with constraints and policies as specified by the service description. “

OASIS Reference Model for Service Oriented Architecture

Page 3: Microservices

What is a service?“enable access to one or more capabilities”• Delegated functionality to specialists (no general specialist)

“access is provided using a prescribed interface ”• Enforces a distributed architecture, communicating by:

• REST, SOAP, AMQP, MSQM, JMS, etc..

” is exercised consistent with constraints and policies as specified by the service description. ”• Abides by the Service Contract

Page 4: Microservices

Service contract

Agreement between a service and its consumer that specifies inbound and outbound data as well as the format.

Page 5: Microservices

Service contractWe have to consider:

• Service availability• Service responsiveness• Circuit breaker pattern (if service is not in-memory/remote)

• Versioning (heterogeneous or homogeneous) • Security (e.g. authentication)• Transactions (ACID compliance)

Page 6: Microservices

Example• Sys AV Scanner• Enables access to a virus scanning service• Access is provided using REST• Responds using JSON

• Sys understands the communication protocol “inbound data”• Sys understands the response “outbound data”

Page 7: Microservices

Advantages• Scalable• Decoupled• Better control over development, testing and deployment• Easier maintenance

• and theoretically is costs less for the business [once it’s up and running]

Page 8: Microservices

Heterogeneous & Homogeneous VersioningHomogeneous versioning uses version numbers across the same contract.

Heterogeneous versioning uses different types of the same contract.

Page 9: Microservices

Disadvantages• Increased ancillary complexity• Increased time cost• ACID is difficult!• Latency• Mitigated by caching or another service / pre-empting requests

• Service contracts can be difficult• What happens if a service I need to connect to is no longer available?

Page 10: Microservices

Microservices

Characteristics&

Capabilities

Page 11: Microservices

Characteristics: TaxonomyMany functional services and private-shared infrastructure services

Page 12: Microservices

Characteristics: GranularityMicroservices are small, fine-grained services. They do one thing, and they do it well.

• Granularity affects performance!• Service Contract overhead can add 100ms to the total response time

• Can impede ACID compliance if services are too granular

Page 13: Microservices

Characteristics: Choreography / OrchestrationOrchestration: coordination with a central mediatorChoreography: coordination without a central mediator

Microservices favour orchestration over choreography

Too much choreography can lead to higher efferent coupling• The degree to which one component is dependent on other components to

complete a single business request

Page 14: Microservices

Characteristics: Choreography / Orchestration

Don’t be afraid to redefine services in a more coarsely-grained manner!

Page 15: Microservices

Characteristics: TopologyMicroservices have an API layer• Mediator in service orchestration• Server-access façade• Introduces abstraction • Context awareness (single bounded context)• Each service can share or have its own access to the infrastructure layer

Page 16: Microservices
Page 17: Microservices

Service 1:1 Data store• Eradicates different read/write patterns• Enables true separation between bounded contexts• Logical separation between subdomains• Now you have to consider how services will communicate• (and the CAP theorem)

Page 18: Microservices

Capabilities: Heterogeneous InteroperabilityThe ability to integrate different programming languages and platforms

• Microservices support protocol-aware-heteronegeous-interopability• Protocol between API layer and service MUST be the same

• SOA also supports protocol-agnostic-heterogeneous-interopability• Hallelujah for that protocol-transforming middleware

Page 19: Microservices

Microservices vs SOA

Contract decouplingMediation / Routing

Protocol TransformationInfrastructure

Page 20: Microservices

Contract decoupling• Allow services to consume a message that does not abide to the

service contract… the holy grail of abstraction

• Message Transformation• Convert XML to JSON

• Message Enhancement• Normalise date/time format

Page 21: Microservices

Mediation / Routing• Provides the ability to mediate (discover services) and route a request

• A service registry typically acts as the central service configuration repository

Page 22: Microservices

Protocol Transformation• Enables protocol agnostic heterogenous interopability• Potentially allows service optimisation• Service A can only communicate in SOAP, Service B is much faster at accepting

requests in REST

Page 23: Microservices

Infrastructure• Microservices are easier to deploy and build• Do not require dedicated enterprise business services (NO ESB/MB)• Microservices can use “lightweight” communication protocols,

whereas SOA prefers standards and “heavier” protocols: XML, SOAP

Page 24: Microservices

Summary• Loose coupling, high cohesiveness services• API layer coordinates between itself and the microservice• Each service is adequately insular