Containerized Services

In the previous chapter, we ran our different microservices directly in the host operating system--so, all the dependencies and data that your application uses were installed directly on the system.

Most of the time, it is fine to do so, because running a Python application in a virtual environment downloads and installs dependencies inside a single directory. However, if the application requires a database system, you need that database to run on your system, unless it is just an SQLite file. For some Python libraries, you might also need some system headers to compile extensions.

In no time, your system is going to have various software running, which were installed along the way when developing your microservices. It is not a problem for your development environment as long as you don’t need to work with different versions of a service you are working on. However, if some potential contributors try to install your applications locally, and are forced to install much of the software at the system level, it could be a dealbreaker.

That is where VMs are a great solution to run your applications. In the past ten years, many software projects that required an elaborate setup to run started to provide ready-to-run VMs, using tools such as VMWare or VirtualBox. Those VMs included the whole stack, like prefilled databases. Demos became easily runnable on most platforms with a single command. That was progress.

However, some of those tools were not fully open source, and they were very slow to run, and greedy in memory and CPU and terrible with disk I/O. It was unthinkable to run them in production, and they were mostly used for demos.

The big revolution came with Docker, an open source virtualization tool, which was first released in 2013, and became hugely popular. Moreover, unlike VMWare or VirtualBox, Docker can run your applications ;in production at native speed.

In other words, creating images for your application is not only for demonstration and development purposes anymore. It can be used for real deployments.

In this chapter, we present Docker, and explain how to run Flask-based microservices with it. Then, we look at some of the tools in the Docker ecosystem. We conclude the chapter by an introduction to clusters.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset