6 Data ownership and data storage

 

This chapter covers

  • Which data microservices store
  • Understanding how data ownership follows business capabilities
  • Using data replication for speed and robustness
  • Building read models from event feeds with event subscribers
  • Implementing data storage in microservices

Software systems create, use, and transform data. Without the data, most software systems wouldn’t be worth much, and that’s true for microservice systems, too. In this chapter, you’ll learn where a piece of data should be stored and which microservice should be responsible for keeping it up to date. Furthermore, you’ll learn how you can use data replication to make your microservice system both more robust and faster.

6.1 Each microservice has a data store

One of the characteristics of microservices identified in chapter 1 is that each microservice should own its data store. The data in that data store is solely under the control of the microservice, and it’s exactly the data the microservice needs. First, it’s data that belongs to the capability the microservice implements, but it’s also supporting data, like cached data and read models created from event feeds.

The fact that each microservice owns a data store means you don’t need to use the same database technology for all microservices. You can choose a database technology that’s suited to the data that each microservice needs to store.

A microservice typically needs to store three types of data:

6.2 Partitioning data between microservices

 
 
 
 

6.2.1 Rule 1: Ownership of data follows business capabilities

 
 

6.2.2 Rule 2: Replicate for speed and robustness

 
 
 

6.2.3 Where does a microservice store its data?

 
 

6.3 Implementing data storage in a microservice

 
 
 
 

6.3.1 Preparing a development setup

 

6.3.2 Storing data owned by a microservice

 
 
 

6.3.3 Storing events raised by a microservice

 
 

6.3.4 Setting cache headers in HTTP responses

 

6.3.5 Reading and using cache headers

 

Summary

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest