4 Data management for microservices

 

This chapter covers

  • Using Docker Compose to build and run our microservices application for development and testing
  • Adding file storage to our application
  • Adding a database to our application

When building any application, we’ll typically need to deal with data, files, and sometimes both. Microservices are no different. We need a database to store dynamic data that’s generated and updated by the application, and we need a place to store assets that are served by the application or uploaded to it.

In this chapter, we add both file storage and a database to our FlixTube example application. First, we’ll add file storage so FlixTube has a location to store its videos. We want to have distinct areas of responsibility in our application for streaming and video storage. That implies that we’ll need to add another microservice to our application, and, in this chapter, we’ll create our second microservice.

Then, we’ll add a database to record the metadata for each video. Currently, that’s only the path to video, but this is just an excuse to get a database in place because, once we have it, we can continue to use it for the ongoing data storage for all of our microservices.

4.1 New tools

4.2 Getting the code

4.3 Developing microservices with Docker Compose

4.3.1 Why Docker Compose?

4.3.2 Creating our Docker Compose file

4.3.3 Booting our microservices application

4.3.4 Working with the application

4.3.5 Shutting down the application

4.3.6 Why Docker Compose for development, but not production?

4.4 Adding file storage to our application

4.4.1 Using Azure Storage

4.4.2 Updating the video-streaming microservice

4.4.3 Adding our new microservice to the Docker Compose file

4.4.4 Testing the updated application