An overview of Microservices architecture

The Golden Rule : Database-per-Service

  • Each service has its own database
  • One service never reach into other service’s database
  • Each service is running independently of other services, so we can significantly increase the up time of our application.
  • It’s a lot easier to scale a database dedicated to certain service which need extra capacity or throughput, instead of scaling a big common database served all services, which could be a challenging task.
  • We can choose different type of database, e.g. SQL or noSQL, to best serve for different service’s functionality.

Communication between services

  • Service A: Implement feature to add a user
  • Service B: Implement feature to add a book
  • Service C: Implement feature for a user to borrow a book

Sync communications — direct request

  • Send queryUser request to Service A, get result and store userId in its own database.
  • Send queryBook request to Service B, get result and store bookId in its own database.
  • It introduces a dependency between services, which is the thing we always try to avoid in microservice architecture.
  • Th entire request performance depends upon each inter-services communication.
  • We may step into a complicated web of inter-services requests. For example, when Service C calls Service A, behind the scene Service A may calls Service K and then Service K may calls another Service, and so on.

Async communications — event broker

  • When Service A add a user into its database, simultaneously it emit an userCreated event to the broker. The broker will then forward the event to Service C, for it to insert the userId into its own database.
  • The same flow applies to Service B.
  • So the database C will have a portion of replication data from Database A and B with zero inter-services dependency.
  • And Service C’s performance can be best optimized since it doesn’t need to wait for the response from other services in order to complete its functionality.




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Scraping the Littlefield Simulation with Python

Hot town, summer in the city

How Should I Backup MongoDB Databases?

Building a Live Chat with GraphQL + MongoDB + NodeJs + Docker

API Design Best Practices by Alibaba Researcher Gu Pu

Configuring Health Check for Redundant Physical Connection Access on Express Connect

Three Useful Applications of Google Tag Manager

Throttling JMS Messages in your Enterprise Integration

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adela Chao

Adela Chao

More from Medium

Learn Protocol Buffers (Protobuf) for serializing structured data — Part 2


1. Microservices foundation

Missing the point with Microservices