I Ran A Simple Test On My LXD And VM Servers And Here’s What I Found Out

When it comes to setting up a home server, there are four distinct options available: a real server, a VM server running on type 1 hypervisor (e.g., Proxmox or VMWare ESXi), an LXD container, and a Docker container. Each of these offers unique benefits and drawbacks, and it’s important to understand the differences between them before making a decision. My preference has always been given to VMs and I’ve never considered LXD containers to be used instead, until I ran one simple test. I’d like to present its results first and then compare different server implementation options and weigh the pros and cons of each, so that you can make an informed decision about the best environment for your home server.

The Test

I have Proxmox installed on my home lab server: it’s a true lab since I create, experiment, delete, then create again and so on virtual machines on it regularly. One of Proxmox’s strong features is that it is able to create and run LXD containers naturally without any additional components installed. It has a number of images among which you choose what container’s purpose will be and then just create it and start it. So, I create a file server in LXD container that had Samba set up out from the box. And I created a VM running on Debian Server 12 and set up Samba on it. Virtual hardware for both of these machines was similar: a two-core CPU and 2 Gb of RAM. So, I started both these new servers, and I also started another VM running on Fedora Desktop. On this Fedora VM, I connected to both of those file servers and copied a 2 Gb file from LXD server to VM server and then vice versa. Then, in Proxmox, I checked Summary tab for both file servers and here’s what I found out.

So, I was copying a 2 GB file from LXD container (read operation) to VM (write operation).

LXD file server CPU usage during read operation (first peak)
VM file server CPU usage during write operation (first peak)
LXD file server RAM usage during read operation
VM file server RAM usage before copy operation
VM file server RAM usage during write operation and beyond

Next, I was copying a 2 GB file from VM (read operation) to LXD container (write operation).

LXD file server CPU usage during write operation (second peak)
VM file server CPU usage during read operation (second peak)
LXD file server RAM usage during write operation
VM file server RAM usage during read operation

Some analytics

Before the test was started, the LXD server was consuming around 0.025% of CPU time and 81 MB of RAM, while the VM server was consuming around 0.2% of CPU time (10 times more than LXD server) and 256 MB of RAM (3 times more than LXD server).

When the copy operation from LXD server to VM started, CPU usage of the first jumped to 1.48% and of the last to 4.25%. LXD’s RAM usage remained the same while VM’s sky rocketed to 1.83 GB and stayed there till the end of the test.

When the copy operation from VM to LXD started, LXD’s CPU usage jumped to 2.4%, VM’s — to 3.74%. LXD’s RAM usage raised a little bit to 141 MB.

What we see is that a file server in an LXD container consumes much less resources than the one on a VM — a good reason to think twice when choosing between LXD and VM.

Below is the promised comparison of different environmental options to implement a home server — you can still read it if you need some more food for thought.

Real Servers

When it comes to setting up a home server, one of the options available is to use a real server. This means having a physical machine dedicated to running your server applications. There are several advantages and disadvantages to consider when choosing this option.

One of the biggest advantages of using a real server is the level of control it provides. With a physical machine, you have full access to all hardware resources and can customize it to meet your specific needs. You can choose the components you want, upgrade them as necessary, and optimize the server for performance. This level of control is especially beneficial if you have specific requirements or if you need to run resource-intensive applications.

Another advantage of using a real server is the reliability it offers. Since there are no layers of virtualization or containerization involved, there is less risk of compatibility issues or software conflicts. You have a dedicated machine solely focused on running your server applications, which can result in improved stability and uptime.

However, there are also some disadvantages to consider when using a real server. One of the main drawbacks is the cost. Setting up a real server can be more expensive upfront, as you need to purchase the hardware and possibly pay for additional software licenses. There are also ongoing costs such as electricity and maintenance.

Another disadvantage is the physical space required. Real servers are typically larger and take up more space compared to virtual machines or containers. This can be a limitation if you have limited space available or if you prefer a more compact setup.

Virtual Machines

Virtual machines (VMs) offer a popular option for setting up a home server. With VMs, you can run multiple operating systems on a single physical machine, creating virtual environments that are isolated from each other. This allows for better resource management and improved security. However, there are pros and cons to consider when choosing to use VMs for your home server.

One of the biggest advantages of using VMs is their flexibility. Since VMs are essentially software emulations of physical hardware, you can easily create, delete, and modify virtual machines as needed. This makes it convenient to test different setups, experiment with different operating systems, and try out new software without impacting the stability of your main server environment. VMs also make it easier to scale your server resources by adding or removing virtual machines as your needs change.

Another advantage of VMs is their ability to provide better isolation and security. Each virtual machine operates independently from the others, meaning that if one VM is compromised, it does not affect the others. This allows you to run potentially risky applications or test new software without worrying about compromising the security of your main server environment. Additionally, VMs offer features such as snapshots and checkpoints, which allow you to easily backup and restore virtual machines to a previous state.

However, there are also some drawbacks to using VMs. One of the main disadvantages is the overhead associated with virtualization. Since VMs require their own operating systems and resources, there is additional overhead in terms of CPU, memory, and disk space. This can result in reduced performance compared to running applications directly on the host machine. Additionally, VMs can be resource-intensive, requiring a powerful server with plenty of memory and processing power to run smoothly.

Another disadvantage is the complexity of managing multiple virtual machines. Each VM requires its own configuration, updates, and maintenance. This can become overwhelming, especially if you have a large number of virtual machines running different operating systems or applications.

LXD Containers

LXD containers offer a unique option for setting up a home server. With LXD, you can create lightweight, isolated environments for your applications. These containers share the host operating system, which allows for efficient resource utilization and minimal overhead. However, there are both benefits and drawbacks to consider when choosing LXD containers for your home server.

One of the biggest advantages of using LXD containers is their performance. Since containers share the host kernel, they require less system resources compared to virtual machines. This means that you can run more containers on a single server without sacrificing performance. Additionally, LXD containers have faster startup times compared to virtual machines, making them ideal for applications that require quick response times.

Another benefit of LXD containers is their scalability. You can easily create, start, stop, and delete containers as needed, allowing for flexible resource allocation. This makes it convenient to add or remove services without affecting the overall server environment. Additionally, LXD containers support live migration, which means you can move containers between hosts without any downtime.

LXD containers also provide excellent isolation. Each container operates independently, with its own file system and network stack. This isolation ensures that if one container is compromised, it does not affect the others. It also allows for better security and easier troubleshooting, as any issues can be contained within the specific container.

One of the main disadvantages is the limited operating system support. LXD containers are currently only available for Linux operating systems. You can use LXD containers if you install Ubuntu on Windows or access LXD service via network, but they may be pretty complex tasks for an average user. This means that if you require Windows or macOS, LXD containers may not be the best option for you.

Docker Containers

Docker containers have become increasingly popular in recent years for setting up home servers. These lightweight, isolated environments provide numerous benefits for hosting your applications. However, there are also some drawbacks to consider before jumping into the world of Docker containers.

One of the biggest advantages of using Docker containers is their portability. With Docker, you can package your application and all its dependencies into a single container, which can then be easily moved between different machines or environments. This makes it convenient to deploy your applications on different servers or even switch hosting providers without the hassle of reconfiguring everything from scratch.

Another benefit of Docker containers is their efficiency. Unlike virtual machines, Docker containers share the host operating system, which means they require fewer system resources. This allows you to run more containers on a single server, making efficient use of your hardware. Additionally, Docker containers have fast startup times, allowing your applications to be up and running in no time.

Docker also provides excellent scalability. You can easily scale your applications by running multiple containers of the same image, each handling a portion of the workload. This horizontal scaling approach allows you to handle increased traffic or resource demands without disrupting the overall server environment.

However, there are some considerations to keep in mind when using Docker containers. One potential drawback is the complexity of managing and orchestrating multiple containers. Docker requires a good understanding of container networking, volumes, and other configuration options. This can be challenging for beginners or those not familiar with container technologies.

Another downside is the security implications of using containers. While Docker does provide some level of isolation between containers, there is still a risk of container escape vulnerabilities. It’s crucial to regularly update and patch your containers to mitigate these risks.

When choosing the right option for your home server, consider your specific needs, budget, and technical capabilities. If you prioritize control and reliability, a real server may be the best choice. If flexibility and isolation are important, virtual machines might be the way to go. LXD containers offer excellent performance, scalability and isolation for Linux-based systems, while Docker containers provide portability and efficiency but require some expertise to manage effectively.