Valentin Viennot
on 20 December 2022
See for yourself: the benefits of chiselled Ubuntu images in action with an ASP.NET shop demo
Looking for a way to improve the performance and reliability of your online shopping and payment systems during the holiday season? Look no further than chiselled Ubuntu images! In this blog series, I’ve already discussed the benefits of using these lightweight and efficient images for your containerised applications. In this second part, I’ll show you how to put these benefits into action with a festive ASP.NET shopping application. Get ready to deck the halls (and your containers) with chiselled Ubuntu.
A festive shopping experience
Ready to start your holiday shopping? First, I’ll introduce the online shopping demo application, built using ASP.NET and chiselled Ubuntu containers. Then, I’ll also give you a tour of the environment used to perform the tests and comparisons.
For our demo application, I used the sample eShop ASP.NET Core 6.0 reference application created by the Microsoft team. The app is split into three components: an API server, a Web server, and a SQL server database.
I created two forks of this demo app, one using traditional Ubuntu containers and the other using our brand new chiselled Ubuntu containers for ASP.NET 6. I then compared the attributes and performance of the two versions using a cloned virtualised environment with limited resources.
My lab is a 4GB RAM, 20GB disk Multipass virtual machine with 2 vCPUs running Ubuntu 22.04. I used the same clean environment for both versions of our demo application to ensure a fair comparison. By using a cloned virtualised environment with limited resources, I was able to accurately compare the attributes and performance of the two versions without introducing bias. I also made sure to maintain (as much as I could) consistent operating conditions during the tests.
Let’s now unwrap the benefits of chiselled Ubuntu, demonstrating how they’ll make your holiday shopping experience faster, more secure, and more scalable.
Smaller size, bigger savings with chiselled Ubuntu
With no doubt, the top benefit using chiselled Ubuntu container images is their smaller size. And it’s probably the easiest one to illustrate! We will compare the size of container images used to deploy our online eShop demo, both using chiselled Ubuntu images and the usual Ubuntu base image.
The sizes, in megabytes, for the two main components’ uncompressed image are displayed in the table below:
Base image type | “API” image size | “Web” image size |
Ubuntu 22.04 LTS | 284MB | 317MB |
Chiselled Ubuntu 22.04 | 181MB (-36%) | 250MB (-21%) |
As you can see on the table above, chiselled Ubuntu-based images are up to 100MB smaller than traditional Ubuntu-based, saving on disk space and bandwidth when downloading and running the image. For applications that are deployed at scale and much more so in distributed and edge computing environments, this can result in significant storage and deployment cost savings.
While I hoped for even greater savings, the Web component of our demo application uses SqlClient from ASP.NET, which requires the Globalisation feature and its accompanying ICU globalisation package. As a result, I had to use a chiselled Ubuntu base that included the ICU packages, which is 40% larger than the chiselled Ubuntu for ASP.NET images available on MCR. However, I did notice faster build times thanks to the network bandwidth savings when pulling the smaller chiselled base images.
Stay safe and secure with chiselled Ubuntu
Chiselled Ubuntu images are created using high-quality components from the Ubuntu operating system and are updated in accordance with the same release cycle and with the same support guarantees. Ubuntu has a strong track record of receiving fixes for critical vulnerabilities in less than 24 hours. Furthermore, the smaller size of chiselled Ubuntu OCI images means that there are fewer opportunities for attackers to exploit (reduced attack surface).
In addition, chiselled Ubuntu images do not include any additional libraries, tools, or components that are typically found in Linux distributions. This means that there’s no package manager, shell, or other utilities for potential hackers to use. Finally, the prebuilt chiselled Ubuntu images for .NET and ASP.NET do not include the “root” user, suppressing privilege escalation for potential attackers.
Check out Rich Lander (@runfaster2000) and I’s joint talk at the 2022 .NET developers conference for a proof of concept of the improved security benefits of chiselled Ubuntu:
Run faster with chiselled Ubuntu
Chiselled Ubuntu images can boost performance for cloud and containerised apps in addition to being smaller and more secure.
The startup times and resource usage for each container type are displayed in the table below:
Base image type | Startup time | CPU usage | Memory usage | CPU (stressed Web server) | Memory (stressed Web server) |
Ubuntu | 4.608s | ~0.1% | 76-81MB | 115% | 218MB |
Chiselled Ubuntu | 3.721s | ~0.0% | 67-79MB | 118% | 172MB |
To measure the startup time, I timed the duration of the command docker-compose up -d
, with all images cached locally. This isn’t a perfect measure, it only considers the time for the container to create and bootstrap. But as you can see, it’s already a good indicator showing that chiselled images are faster to start up (almost 20% faster).
To measure the resource consumption, I simply used the docker stats command. I first compared memory and CPU usage after once the application was launched. Then I did due-diligence stress testing of the Web component, generating 500 requests with up to 5 in parallel using cURL (kudos to Ivo on dev.to for the advice). As you can see, adoption of chiselled Ubuntu containers drives down memory usage (7%) and particularly in stressed situations (21%).
This means that the application can be up and running more quickly, and it can run more efficiently on the host system. This means a faster, more responsive user experience for our Christmas-time online-shopper customers!
Celebrate the season with chiselled Ubuntu
In this blog series, I have shown the key advantages of using chiselled Ubuntu images in practice by building a simple online shopping application using the ASP.NET runtime. Although my measurements might not be the most accurate, the improvements going from Ubuntu to chiselled Ubuntu as base images for .NET/ASP.NET are quite impressive. All that with very little changes and a seamless continued developer experience.
As we look ahead to the new year, I encourage you to try out chiselled Ubuntu images for yourself and see the benefits for your own applications. Whether you are a developer, system administrator, or just interested in learning more about container technologies, chiselled Ubuntu images can provide you with a stable, efficient, and secure platform for deploying and running your applications.
So don’t let the holiday season be a pain in the elf; use chiselled Ubuntu images to keep your containerised applications running smoothly, and make sure your customers have a ho-ho-happy experience. Happy holidays, and happy containerising!
- Demo source code on GitHub (MIT License)
- Part 1: “Chiselled Ubuntu: The Perfect Present for Your Containerised and Cloud Applications”
- .NET developers conference 2022 joint talk with Rich Lander
- Microsoft and Canonical announce .NET availability in Ubuntu hosts and containers
- .NET for Ubuntu hosts and containers is now available on Arm-based platforms
- Last year holiday season’s blog: How to colourise black & white pictures: OpenVINO™ on Ubuntu containers demo (Part 1)