Loading s7nsa_11_images...

enib_small.png S7-NSA 11_images — Container image reduction

The purpose of this tutorial is to raise awareness of the size of the images that must be downloaded and loaded into memory when developing an application based on multiple containers.
Approaches for significantly improving this situation are then presented.

As each tutorial is independent, it is recommended that you create a separate directory on your workstation in which to save your work for this tutorial.
This will allow you to retrieve the state of your work on each tutorial you have completed.

Do not hesitate to use any external help available, including your favourite LLM, to obtain explanations.
Of course, the session supervisor is here to help in any case.

You are strongly encouraged to take notes during your observations so that you can review them before the quizzes.
{1 #app } Initial application
{2 #frontend } Custom frontend image
{3 #db } Custom database image
{4 #backend } Compiled backend

Additional activity: recompile PostgreSQL

You have seen that, without taking any particular precautions, a container-based application can very easily consume vastly more resources than are actually required for the service it provides.
Indeed, the host operating system must download, store, and run numerous other complete runtime environments, each embedding numerous optional features, whereas in many cases only a few megabytes should be sufficient for the application's essential functionality.
Although the layer-based image format allows common filesystem layers to be shared between images, the size of each individual image remains largely unchanged, and you have seen that the benefit is relatively small in practice.

On the other hand, with a basic understanding of how things work, it is possible to build container images on demand that are much more closely tailored to the actual requirements; you have seen this with the frontend and database softwares.
As for the backend, which implements the application's business logic, the choice of programming language and the separation of development and runtime images provide enormous opportunities for resource savings (a factor of 50.48 was achieved in the simplified example presented here).
Overall, in the scenario tested, the size of the application was reduced by a factor of 9.38 (48.882MB instead of 458.304MB) with no greater difficulty than understanding how to install standard software in an operating system and mastering the process of building a program using a suitably chosen programming language.
Smaller images do not merely reduce storage and bandwidth requirements; they also shorten download times, accelerate deployments, reduce the startup time of new instances, and often improve security by eliminating unnecessary software components.

Such resource-saving precautions may seem unnecessary for occasional use, as is the case in this tutorial.
However, containerised applications are often intended for large-scale distribution or deployment.
Either many individuals download the images from a registry to run the application on their own machines, or the applications are deployed at scale, particularly using orchestration techniques.
As soon as you move beyond occasional personal use, it becomes increasingly worthwhile to avoid unnecessary resource consumption, even though the ease of use provided by such techniques inevitably tends to encourage the opposite.

Make sure you review your understanding of what has been covered so far so that you can approach the quizzes with confidence.
Some examples of possible questions