Cloud Native Service Communication Patterns L100

Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

Service Communication Patterns

Prasenjit Sarkar
Oracle Cloud Infrastructure
February 2020

Copyright © 2019 Oracle and/or its affiliates.


Safe harbor statement

The following is intended to outline our general product direction. It is intended for information
purposes only, and may not be incorporated into any contract. It is not a commitment to deliver
any material, code, or functionality, and should not be relied upon in making purchasing
decisions.

The development, release, timing, and pricing of any features or functionality described for
Oracle’s products may change and remains at the sole discretion of Oracle Corporation.

Copyright © 2019 Oracle and/or its affiliates.


Objectives
After completing this lesson, you should be able to;

• Understand the Service Communication Patterns


• Protocols and their benefits in the communication pattern

Copyright © 2019 Oracle and/or its affiliates.


Service Communication

Copyright © 2019 Oracle and/or its affiliates.


Service Communication
External communication (North-South)

Communication from/to external services

Internal communication (East-West)

Service-to-service communication (e.g. within a cluster)

Copyright © 2019 Oracle and/or its affiliates.


Synchronous and Asynchronous

Copyright © 2019 Oracle and/or its affiliates.


Integrating services

• Minimize the communication between internal services


• Try not to depend on sync communication
• Use async between services (propagate data asynchronously)
• Orchestration vs. choreography

Copyright © 2019 Oracle and/or its affiliates.


Protocols (1/2)
HTTP

• Textual protocol
• Most popular, not the most performant

HTTP/2

• Binary protocol instead of textual.

• Designed for low latency

• It is fully multiplexed

• More client data transfer on the wire

Copyright © 2019 Oracle and/or its affiliates.


Protocols (2/2)

WebSockets

• Persistent connection between client/server

• Based on HTTP

• Low-latency, for transferring large volumes of data

gRPC

• Binary format, small payloads

• Uses HTTP/2 as transport protocol

• Uses protocol buffers to define & serialize


structured data into binary format

Copyright © 2019 Oracle and/or its affiliates.


Messaging Protocols
Message Queue Telemetry Transport (MQTT)

• Simple and lightweight binary protocol


• Designed for low-bandwidth/high-latency environments (e.g. dial-up lines, embedded systems)
• Focuses on Pub/Sub messaging

Advanced Message Queuing Protocol (AMQP)

• Binary protocol with rich set of features

• Reliable queuing, topic-base pub/sub, routing, security

• Battle-tested and proven to be reliable

both use WebSockets over TCP

Copyright © 2019 Oracle and/or its affiliates.


Publisher/Subscriber - Considerations
Message order is not guaranteed (default)
• Design for idempotent operations
If ordering is needed:
• Use messaging systems ordering functionality
• Priority queue pattern
Use poison message queue (for errors/crashes)

Copyright © 2019 Oracle and/or its affiliates.


Service Communication - Idempotency (1/2)

Run an operation multiple times, without changing the result

Messages can be received and processed more than once


• Retry policies, failures etc.

Two approaches:
• Exactly-once approach is hard
• Use at-least-once approach

Copyright © 2019 Oracle and/or its affiliates.


Service Communication - Idempotency (2/2)

Natural idempotency
• No need to do anything special

Not naturally idempotent


• Add unique identifier to the message
• Service checks if the message was processed or not

Copyright © 2019 Oracle and/or its affiliates.


Service Communication - Serialization
JSON

• Readable, self-contained

• Large memory footprint

• Expensive serialization/deserialization with


a lot of data

Protobuf

• Binary format - needs a generator

• Schema defined in .proto files

Copyright © 2019 Oracle and/or its affiliates.


Oracle Cloud always free tier:
oracle.com/cloud/free/

OCI training and certification:


cloud.oracle.com/en_US/iaas/training
cloud.oracle.com/en_US/iaas/training/certification
education.oracle.com/oracle-certification-path/pFamily_647

OCI hands-on labs:


ocitraining.qloudable.com/provider/oracle

Oracle learning library videos on YouTube:


youtube.com/user/OracleLearning

Copyright © 2019 Oracle and/or its affiliates.


Thank you

You might also like