A key component in load balancing our Docker application is to have a farm of servers to send our application's requests to. In the case of our infrastructure, this involves preparing a farm of Docker hosts to deploy our application to. The scalable way to do this is to have a common base configuration that is managed by configuration management software, such as Chef, as we previously covered in Chapter 3, Automating Docker Deployments with Chef.
After preparing the farm of Docker hosts, it is time to prepare the application that we will run. In this chapter, we will scale a simple NodeJS application. The rest of this section will describe how this application works.
The web application is a small NodeJS application written in a file called app.js
. For the purpose of visualizing how our application load balances, we will also log some information about our application and the Docker host it is running in. The app.js
file will contain the following code:
var http...