Skip to content

0x370 Foundation

1. Data Model

2. Communication

2.1. REST

REST:

  • use URLs for identifying resources
  • use HTTP features for cache control, authentication and content type negotiation

API of RESTful can be defined using OpenAPI.

REST is popular in the context of cross-organizational service and often associated with microservices

SOAP

  • XML-based protocol
  • it can be independent from HTTP and avoid using most HTTP features

API of SOAP is described using a language called WSDL (WebServices Description Language)

2.2. RMI (Remote Method Invocation)

using distributed object

CORBA

Protocol (DCOM, distributed COM) It is an extension of the COM

2.3. RPC (Remote Procedure Call)

using procedure (RPC) instead of objects (RMI), check this article

Check this article why distributed objects (in RMI) should be avoided in microservice

Protocol (gRPC, stubby) based on Google's internal stubby framework

Microsoft's doc has a good comparison between REST-based API and RPC

grpc

2.4. Message Passing

Message Passing dataflow or Pub/Sub is a form of asynchronous service-to-service communication used in serverless and microservices architectures.

Work flow:

  • A message (just a sequence of bytes) is delivered to an intermediary called a message broker (or message queue) which stores the message temporarily.
  • The message is then delivered to subscriber.

It has several advantages over RPC:

  • act as a buffer when recipient is unavailable
  • will redeliver when failed
  • sender does not need to know the IP/port of receiver
  • decouples sender from receiver

3. Naming

4. Coordination

4.1. Paxos

Paxos Made Simple

4.2. Consistency Models

Consistency model is a contract between process and a data store. It says that if processes agree to obey certain ruless, the store promises to work correctly

4.2.1. strong consistency model

Model (strict consistency) the strongest consistency model

it returns a value corresponding to the latest write (due to message latency, not possible in a distributed system)

  • Unix file system guarantees this.
  • NFS/AFS approximates this
  • S3 makes no real attempt to approximate it

Model (sequential consistency)

The result execution is the sequential consistent if we can find a sequential order of execution by all processes subject to the execution order in each process.

4.2.2. weak consistency model

Model (eventual consistency)

If no new updates are made to a given data item, eventually, all accesses to that item will return the last updated value

Example

  • DNS

4.3. CAP Theorem

Two out of three C/A/P can be satisfied

  • consistency: every read receives most recent write
  • availability: every request receives a (non-error) response, without the guarantee it contains the latest write
  • partition tolerance: the system continues to operate despite the network failure

cap

Reference: https://www.quora.com/What-Is-CAP-Theorem-1