Tag : cloud

post image

How to use Ubuntu and LXD on Alibaba Cloud

Alibaba Cloud is like Amazon Web Services as they offer quite similar cloud services. They are part of the Alibaba Group, a huge Chinese conglomerate. For example, the retailer component of the Alibaba Group is now bigger than Walmart. Here, we try out the cloud services.

The main reason to select Alibaba Cloud is to get a server running inside China. They also have several data centers outside China, but inside China it is mostly Alibaba Cloud. To get a server running inside mainland China though, you need to go through a registration process where you submit photos of your passport. We ain’t have time for that, therefore we select the closest data center to China, Hong Kong.

Creating an account on Alibaba Cloud

Click to create an account on Alibaba Cloud (update: no referral link). You get $300 credit to use within two months, and up to $50 of that credit can go towards launching virtual private servers. Actually, make that account with the referral now, before continuing with this section below..

When creating the account, there is either the option to verify your email or phone number. Let’s do the email verification.

Let’s check our mails. Where is that email from Alibaba Cloud? Nothing arrived!?!

The usability disaster is almost evident. When you get to this page about the Verification, the text says We need to verify your email. Please input the number you receive. Alibaba Cloud did not already send that email to us. We need to first click on Send to get it to send that email. The text should have said instead something like To use email verification, click Send below, then input the numbercode you have received.

You can pay Alibaba Cloud using either a bank card or Paypal. Let’s try Paypal! Actually, to make use of the $300 credit, it has to be a bank card instead.

We have added a bank card. This bank card has to go through a type verification. Alibaba Cloud will make a small debit (to be refunded later) and you can input either the transaction amount or the transaction code (see screenshot) below in order to verify that you do have access to your bank card.

After a couple of days, you get worried because there is no transaction with the description INTL*?????.ALIYUN.COM at your online banking. What went wrong? And what is this weird transaction with a different description in my bank statement?

Description: INTL*175 LUXEM LU ,44

Debit amount: 0.37€

What is LUXEM, a municipality in Germany, doing on my bank statement? Let’s hope that the processor for Alibaba in Europe is LUXEM, not ALIYUN.

Let’s try as transaction code the number 175. Did not work. Four more tries remaining.

Let’s try the transaction amount, 0.37€. Of course, it did not work. It says USD, nor EURO! Three tries remaining.

Let’s google a bit, Add a payment method documentation on Alibaba Cloud talks only about dollars. A forum post about non-dollar currencies says:

I did not get an authorization charge, therefore there is no X.

Let’s do something really crazy:

We type 0.44 as the transaction amount. IT WORKED!

In retrospect, there is a reference on ,44 in the description, who would have thought that this undocumented info might refer to the dollar amount.

After a week, the micro transaction of 0.37€ was not reimbursed. What’s more, I was also charged with a 2.5€ commission which I am not getting back either.

We are now ready to use the $300 Free Credit!

Creating a server on Alibaba Cloud

When trying to create a server, you may encounter this website, with a hostname YUNDUN.console.aliyun.com. If you get that, you are in the wrong place. You cannot add your SSH key here, nor do you create a server.

Instead, it should say ECS, Elastic Compute Service.

Here is the full menu for ECS,

Under Networks & Security, there is Key Pairs. Let’s add there the SSH public key, not the whole key pair.

First of all, we need to select the appropriate data center. Ok, we change to Hong Kong which is listed in the middle.

But how do we add our own SSH key? There is only an option to Create Key Pair!?! Well, let’s create a pair.

Ah, okay. Although the page is called Create Key Pair, we can actually Import an Existing Key Pair.

Now, click back to Elastic Computer S…/Overview, which shows each data center.

If we were to try to create a server in Mainland China, we get

In that case, we would need to send first a photo of our passport or our driver’s license.

Let’s go back, and select Hong Kong.

We are ready to configure our server.

There is an option of either a Starter Package or an Advanced Purchase. The Starter Package is really cool, you can get a server for only $4.5. But the find print for the $300 credit says that you cannot use the Starter Package here.

So, Advanced Purchase it will be.

There are two pricing models, Subscription and Pay As You Go. Subscription means that you pay monthly, Pay As You Go means that you pay hourly. We go for Subscription.

We select the 1-core, 1GB instance, and we can see the price at $12.29. We also pay separately for the Internet traffic. The cost is shown on an overlay, we still have more options to select before we create the server.

We change the default Security Group to the one shown above. We want our server to be accessible from outside on ports 80 and 443. Also port 22 is added by default, along with the port 3389 (Remote Desktop in Windows).

We select Ubuntu 16.04.  The order of the operating systems is a bit weird. Ideally, the order should reflect the popularity.

There is an option for Server Guard. Let’s try it since it is free. (it requires to install some closed-source package in our Linux. Eventually I did not try it).

The Ultra Cloud Disk is a network share and it is included in the earlier price. The other option would be to select an SSD. It is nice that we can add up to 16 disks to our server.

We are ready to place the order. It correctly shows $0 and mentions the $50 credit. We select not to auto renew.

Now we pay the $0.

And that’s how we start a server. We have received an email with the IP address but can also find the public IP address from the ECS settings.

Let’s have a look at the IP block for this IP address.


How to set up LXD on an Alibaba server

First, we SSH to the server. The command looks like ssh root@_public_ip_address_

It looks like real Ubuntu, with real Ubuntu Linux kernel. Let’s update.

root@iZj6c66d14k19wi7139z9eZ:~# apt update
Get:1 http://mirrors.cloud.aliyuncs.com/ubuntu xenial InRelease [247 kB]
Hit:2 http://mirrors.aliyun.com/ubuntu xenial InRelease

Get:45 http://mirrors.aliyun.com/ubuntu xenial-security/universe i386 Packages [147 kB] 
Get:46 http://mirrors.aliyun.com/ubuntu xenial-security/universe Translation-en [89.8 kB] 
Fetched 40.8 MB in 24s (1682 kB/s) 
Reading package lists... Done
Building dependency tree 
Reading state information... Done
105 packages can be upgraded. Run 'apt list --upgradable' to see them.

We upgraded (apt upgrade) and there was a kernel update. We restarted (shutdown -r now) and the newly updated Ubuntu has the updated kernel. Nice!

Let’s check /proc/cpuinfo,

root@iZj6c66d14k19wi7139z9eZ:~# cat /proc/cpuinfo 
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 63
model name : Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz
stepping : 2
microcode : 0x1
cpu MHz : 2494.224
cache size : 30720 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm fsgsbase bmi1 avx2 smep bmi2 erms invpcid xsaveopt
bugs :
bogomips : 4988.44
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:


How much free space from the 40GB disk?

root@iZj6c66d14k19wi7139z9eZ:~# df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/vda1   40G 2,2G 36G 6% /

Let’s add a non-root user.

root@iZj6c66d14k19wi7139z9eZ:~# adduser myusername
Adding user `myusername' ...
Adding new group `myusername' (1000) ...
Adding new user `myusername' (1000) with group `myusername' ...
Creating home directory `/home/myusername' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
Changing the user information for myusername
Enter the new value, or press ENTER for the default
 Full Name []: 
 Room Number []: 
 Work Phone []: 
 Home Phone []: 
 Other []: 
Is the information correct? [Y/n] 

Is LXD already installed?

root@iZj6c66d14k19wi7139z9eZ:~# apt policy lxd
 Installed: (none)
 Candidate: 2.0.10-0ubuntu1~16.04.2
 Version table:
     2.0.10-0ubuntu1~16.04.2 500
         500 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main amd64 Packages
         500 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 Packages
         100 /var/lib/dpkg/status
     2.0.2-0ubuntu1~16.04.1 500
         500 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-security/main amd64 Packages
         500 http://mirrors.aliyun.com/ubuntu xenial-security/main amd64 Packages
     2.0.0-0ubuntu4 500
         500 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 Packages
         500 http://mirrors.aliyun.com/ubuntu xenial/main amd64 Packages

Let’s install LXD.

root@iZj6c66d14k19wi7139z9eZ:~# apt install lxd

Now, we can add our user account myusername to the groups sudo, lxd.

root@iZj6c66d14k19wi7139z9eZ:~# usermod -a -G lxd,sudo myusername

Let’s copy the SSH public key from root to the new non-root account.

root@iZj6c66d14k19wi7139z9eZ:~# cp -R /root/.ssh ~myusername/
root@iZj6c66d14k19wi7139z9eZ:~# chown -R myusername:myusername ~myusername/.ssh/

Now, log out and log in as the new non-root account.

$ ssh myusername@IP.IP.IP.IP
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-96-generic x86_64)

* Documentation: https://help.ubuntu.com
 * Management: https://landscape.canonical.com
 * Support: https://ubuntu.com/advantage

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

Welcome to Alibaba Cloud Elastic Compute Service !


We are going to install the ZFS utilities so that LXD can use ZFS as a storage backend.

myusername@iZj6c66d14k19wi7139z9eZ:~$ sudo apt install zfsutils-linux

Now, we can configure LXD. From before, the server had about 35GB free. We are allocating 20GB of that for LXD.

myusername@iZj6c66d14k19wi7139z9eZ:~$ sudo lxd init
sudo: unable to resolve host iZj6c66d14k19wi7139z9eZ
[sudo] password for myusername:  ********
Name of the storage backend to use (dir or zfs) [default=zfs]: zfs
Create a new ZFS pool (yes/no) [default=yes]? yes
Name of the new ZFS pool [default=lxd]: lxd
Would you like to use an existing block device (yes/no) [default=no]? no
Size in GB of the new loop device (1GB minimum) [default=15]: 20
Would you like LXD to be available over the network (yes/no) [default=no]? no
Do you want to configure the LXD bridge (yes/no) [default=yes]? yes
Warning: Stopping lxd.service, but it can still be activated by:

LXD has been successfully configured.
myusername@iZj6c66d14k19wi7139z9eZ:~$ lxc list
Generating a client certificate. This may take a minute…
If this is your first time using LXD, you should also run: sudo lxd init
To start your first container, try: lxc launch ubuntu:16.04


Okay, we can create now our first LXD container. We are creating just a web server.

myusername@iZj6c66d14k19wi7139z9eZ:~$ lxc launch ubuntu:16.04 web
Creating web
Retrieving image: rootfs: 100% (6.70MB/s) 
Starting web 

Let’s see the container,

myusername@iZj6c66d14k19wi7139z9eZ:~$ lxc list
| web | RUNNING | (eth0) | | PERSISTENT | 0 |

Nice. We get into the container and install a web server.

myusername@iZj6c66d14k19wi7139z9eZ:~$ lxc exec web -- sudo --login --user ubuntu

To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.


We executed into the web container the command sudo –login –user ubuntu. The container has a default non-root account ubuntu.

ubuntu@web:~$ sudo apt update
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Hit:2 http://archive.ubuntu.com/ubuntu xenial InRelease 
Reading state information... Done
3 packages can be upgraded. Run 'apt list --upgradable' to see them.
ubuntu@web:~$ sudo apt install nginx
Reading package lists... Done
Processing triggers for ufw (0.35-0ubuntu2) ...
ubuntu@web:~$ sudo vi /var/www/html/index.nginx-debian.html 
ubuntu@web:~$ logout
myusername@iZj6c66d14k19wi7139z9eZ:~$ curl
<!DOCTYPE html>
<title>Welcome to nginx running in an LXD container on Alibaba Cloud!</title>
 body {
 width: 35em;
 margin: 0 auto;
 font-family: Tahoma, Verdana, Arial, sans-serif;
<h1>Welcome to nginx running in an LXD container on Alibaba Cloud!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>

Obviously, the web server in the container is not accessible from the Internet. We need to do something like add iptables rules to forward appropriately the connection.

Alibaba Cloud gives two IP address per server. One is the public IP address and the other is a private IP address (172.[16-31].*.*). The eth0 interface of the server has that private IP address. This information is important for iptables below.

myusername@iZj6c66d14k19wi7139z9eZ:~$ PORT=80 PUBLIC_IP=my172.IPAddress CONTAINER_IP= sudo -E bash -c 'iptables -t nat -I PREROUTING -i eth0 -p TCP -d $PUBLIC_IP --dport $PORT -j DNAT --to-destination $CONTAINER_IP:$PORT -m comment --comment "forward to the Nginx container"'

Let’s load up our site using the public IP address from our own computer:

And that’s it!


Alibaba Cloud is yet another provider for cloud services. They are big in China, actually the biggest in China. They are trying to expand to the rest of the world. There are several teething problems, probably arising from the fact that the main website is in Mandarin and there is no infrastructure for immediate translation to English.

On HN there has been a sort of relaunch a few of months ago. It appears there is interest from them to get international users. What they need is people to attend immediately to issues as they are discovered.

If you want to learn more about LXD, see https://stgraber.org/2016/03/11/lxd-2-0-blog-post-series-012/


Update #1

After a day of running a VPS on Alibaba Cloud, I received this email.

From: Alibaba Cloud
Subject: 【Immediate Attention Needed】Alibaba Cloud Fraud Prevention

We have detected a security risk with the card you are using to make purchases. In order to protect your account, please provide your account ID and the following information within one working day via your registered Alibaba Cloud email to compliance_support@aliyun.com for further investigation. 

If you are using a credit card as your payment method, please provide the following information directly. Please provide clear copies of: 

1. Any ONE of the following three forms of government-issued photo identification for the credit card holder or payment account holder of this Alibaba Cloud account: (i) National identification card; (ii) Passport; (iii) Driver's License. 
2. A clear copy of the front side of your credit card in connection with this Alibaba Account; (Note: For security reasons, we advise you to conceal the middle digits of your card number. Please make sure that the card holder's name, card issuing bank and the last four digits of the card number are clearly visible). 
3. A clear copy of your card's bank statement. We will process your case within 3 working days of receiving the information listed above. NOTE: Please do not provide information in this ticket. All the information needed should be sent to this email compliance_support@aliyun.com.

If you fail to provide all the above information within one working day , your instances will be shut down. 

Best regards, 

Alibaba Cloud Customer Service Center

What this means, is that update #2 has to happen now.


Update #2

Newer versions of LXD have a utility called lxd-benchmark. This utility spawns, starts and stops containers, and can be used to have an idea how efficient a server may be. I suppose primarily it is used to figure out if there is a regression in the LXD code. Let see it anyway in action here, the clock is ticking.

The new LXD is in a PPA at https://launchpad.net/~ubuntu-lxc/+archive/ubuntu/lxd-stable Let’s install it on Alibaba Cloud.

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ubuntu-lxc/lxd-stable
sudo apt updatesudo apt upgrade                   # Now LXD will be upgraded.sudo apt install lxd-tools         # Now lxd-benchmark will be installed.

Let’s see the options for lxd-benchmark.

Usage: lxd-benchmark spawn [--count=COUNT] [--image=IMAGE] [--privileged=BOOL] [--start=BOOL] [--freeze=BOOL] [--parallel=COUNT]
 lxd-benchmark start [--parallel=COUNT]
 lxd-benchmark stop [--parallel=COUNT]
 lxd-benchmark delete [--parallel=COUNT]

--count (= 100)
 Number of containers to create
 --freeze (= false)
 Freeze the container right after start
 --image (= "ubuntu:")
 Image to use for the test
 --parallel (= -1)
 Number of threads to use
 --privileged (= false)
 Use privileged containers
 --report-file (= "")
 A CSV file to write test file to. If the file is present, it will be appended to.
 --report-label (= "")
 A label for the report entry. By default, the action is used.
 --start (= true)
 Start the container after creation

First, we need to spawn new containers that we can later start, stop or delete. Ideally, I would expect the terminology to be launch instead of spawn, to keep in sync with the existing container management commands.

Second, there are defaults for each command as shown above. There is no indication yet as to how much RAM you need to spawn the default 100 containers. Obviously it would be more than the 1GB RAM we have on this server. Regarding the disk space, that would be fine because of copy-on-write with ZFS; any newly created LXD container does not use up additional space as they all are based on the space of the first container. Perhaps after a day when unattended-upgrades kicks in, each container would use up some space for any required security updates that get automatically applied.

Let’s try out with 3 containers. We have stopped and deleted the original web container that we have created in this tutorial (lxc stop web ; lxc delete web).

$ lxd-benchmark spawn --count 3
Test environment:
 Server backend: lxd
 Server version: 2.18
 Kernel: Linux
 Kernel architecture: x86_64
 Kernel version: 4.4.0-96-generic
 Storage backend: zfs
 Storage version:
 Container backend: lxc
 Container version: 2.1.0

Test variables:
 Container count: 3
 Container mode: unprivileged
 Startup mode: normal startup
 Image: ubuntu:
 Batches: 3
 Batch size: 1
 Remainder: 0

[Sep 27 17:31:41.074] Importing image into local store: 03c2fa6716b5f41684457ca5e1b7316df520715b7fea0378f9306d16fdc646ee
[Sep 27 17:32:12.825] Found image in local store: 03c2fa6716b5f41684457ca5e1b7316df520715b7fea0378f9306d16fdc646ee
[Sep 27 17:32:12.825] Batch processing start
[Sep 27 17:32:37.614] Processed 1 containers in 24.790s (0.040/s)
[Sep 27 17:32:42.611] Processed 2 containers in 29.786s (0.067/s)
[Sep 27 17:32:49.110] Batch processing completed in 36.285s
$ lxc list --columns ns4tS
| NAME        | STATE   | IPV4                | TYPE       | SNAPSHOTS |
| benchmark-1 | RUNNING | (eth0) | PERSISTENT | 0         |
| benchmark-2 | RUNNING | (eth0) | PERSISTENT | 0         |
| benchmark-3 | RUNNING | (eth0)  | PERSISTENT | 0         |
| web         | RUNNING | (eth0) | PERSISTENT | 0         |

We created three extra containers, named benchmark-?, and got them started. There were launched in three batches, which means that one was started after another, not in parallel.

The total time on this server, when the storage backend is zfs, was 36.2 seconds. It is not clear what the numbers in the parenthesis mean at Processed 1 containers in 18.770s (0.053/s).

The total time on this server, when the storage backend was dir, was 68.6 instead.

Let’s stop them!

$ lxd-benchmark stop
Test environment:
 Server backend: lxd
 Server version: 2.18
 Kernel: Linux
 Kernel architecture: x86_64
 Kernel version: 4.4.0-96-generic
 Storage backend: zfs
 Storage version:
 Container backend: lxc
 Container version: 2.1.0

[Sep 27 18:06:08.822] Stopping 3 containers
[Sep 27 18:06:08.822] Batch processing start
[Sep 27 18:06:09.680] Processed 1 containers in 0.858s (1.165/s)
[Sep 27 18:06:10.543] Processed 2 containers in 1.722s (1.162/s)
[Sep 27 18:06:11.406] Batch processing completed in 2.584s

With dir, it was around 2.4 seconds.

And then delete them!

$ lxd-benchmark delete
Test environment:
 Server backend: lxd
 Server version: 2.18
 Kernel: Linux
 Kernel architecture: x86_64
 Kernel version: 4.4.0-96-generic
 Storage backend: zfs
 Storage version:
 Container backend: lxc
 Container version: 2.1.0

[Sep 27 18:07:12.020] Deleting 3 containers
[Sep 27 18:07:12.020] Batch processing start
[Sep 27 18:07:12.130] Processed 1 containers in 0.110s (9.116/s)
[Sep 27 18:07:12.224] Processed 2 containers in 0.204s (9.814/s)
[Sep 27 18:07:12.317] Batch processing completed in 0.297s

With dir, it was 2.5 seconds.

Let’s create three containers in parallel.

$ lxd-benchmark spawn --count=3 --parallel=3
Test environment:
 Server backend: lxd
 Server version: 2.18
 Kernel: Linux
 Kernel architecture: x86_64
 Kernel version: 4.4.0-96-generic
 Storage backend: zfs
 Storage version:
 Container backend: lxc
 Container version: 2.1.0

Test variables:
 Container count: 3
 Container mode: unprivileged
 Startup mode: normal startup
 Image: ubuntu:
 Batches: 1
 Batch size: 3
 Remainder: 0

[Sep 27 18:11:01.570] Found image in local store: 03c2fa6716b5f41684457ca5e1b7316df520715b7fea0378f9306d16fdc646ee
[Sep 27 18:11:01.570] Batch processing start
[Sep 27 18:11:11.574] Processed 3 containers in 10.004s (0.300/s)
[Sep 27 18:11:11.574] Batch processing completed in 10.004s

With dir, it was 58.7 seconds.

Let’s push it further and try to hit some memory limits! First, we delete all, and launch 5 in parallel.

$ lxd-benchmark spawn --count=5 --parallel=5
Test environment:
 Server backend: lxd
 Server version: 2.18
 Kernel: Linux
 Kernel architecture: x86_64
 Kernel version: 4.4.0-96-generic
 Storage backend: zfs
 Storage version:
 Container backend: lxc
 Container version: 2.1.0

Test variables:
 Container count: 5
 Container mode: unprivileged
 Startup mode: normal startup
 Image: ubuntu:
 Batches: 1
 Batch size: 5
 Remainder: 0

[Sep 27 18:13:11.171] Found image in local store: 03c2fa6716b5f41684457ca5e1b7316df520715b7fea0378f9306d16fdc646ee
[Sep 27 18:13:11.172] Batch processing start
[Sep 27 18:13:33.461] Processed 5 containers in 22.290s (0.224/s)
[Sep 27 18:13:33.461] Batch processing completed in 22.290s

So, 5 containers can start in 1GB of RAM, in just 22 seconds.

We also tried the same with the dir storage backend, and got

[Sep 27 17:24:16.409] Batch processing start
[Sep 27 17:24:54.508] Failed to spawn container 'benchmark-5': Unpack failed, Failed to run: unsquashfs -f -d /var/lib/lxd/storage-pools/default/containers/benchmark-5/rootfs -n -da 99 -fr 99 -p 1 /var/lib/lxd/images/03c2fa6716b5f41684457ca5e1b7316df520715b7fea0378f9306d16fdc646ee.rootfs: . 
[Sep 27 17:25:11.129] Failed to spawn container 'benchmark-3': Unpack failed, Failed to run: unsquashfs -f -d /var/lib/lxd/storage-pools/default/containers/benchmark-3/rootfs -n -da 99 -fr 99 -p 1 /var/lib/lxd/images/03c2fa6716b5f41684457ca5e1b7316df520715b7fea0378f9306d16fdc646ee.rootfs: . 
[Sep 27 17:25:35.906] Processed 5 containers in 79.496s (0.063/s)
[Sep 27 17:25:35.906] Batch processing completed in 79.496s

Out of the five containers, it managed to create 3 (No 1, 3, 4). The reason is that unsquashfs needs to run to expand an image, and that process uses a lot of memory. When using zfs, the same process probably does not need that much memory.

Let’s delete the five containers (storage backend: zfs):

[Sep 27 18:18:37.432] Batch processing completed in 5.006s

Let’s close the post with

$ lxd-benchmark spawn --count=10 --parallel=5
Test environment:
 Server backend: lxd
 Server version: 2.18
 Kernel: Linux
 Kernel architecture: x86_64
 Kernel version: 4.4.0-96-generic
 Storage backend: zfs
 Storage version:
 Container backend: lxc
 Container version: 2.1.0

Test variables:
 Container count: 10
 Container mode: unprivileged
 Startup mode: normal startup
 Image: ubuntu:
 Batches: 2
 Batch size: 5
 Remainder: 0

[Sep 27 18:19:44.706] Found image in local store: 03c2fa6716b5f41684457ca5e1b7316df520715b7fea0378f9306d16fdc646ee
[Sep 27 18:19:44.706] Batch processing start
[Sep 27 18:20:07.705] Processed 5 containers in 22.998s (0.217/s)
[Sep 27 18:20:57.114] Processed 10 containers in 72.408s (0.138/s)
[Sep 27 18:20:57.114] Batch processing completed in 72.408s

We launched 10 containers in two batches of five containers each. The lxd-benchmark command completed successfully, in just 72 seconds. However, after the command completed, each container would start up, get an IP and get working. We hit the memory limit when the second batch of five containers where starting up. The network monitor on the Alibaba Cloud management console shows 100% CPU utilization, and it is not possible to access the server over SSH. Let’s delete the server from the management console and wind down this trial of Alibaba Cloud.

lxd-benchmark is quite useful and can be used to get practical understanding as to how many containers can make it on a server and much more.

Update #3

I just restarted the server from the management console and connected using SSH.

Here are the ten containers from Update #2,

$ lxc list --columns ns4
| NAME         | STATE   | IPV4 |
| benchmark-01 | STOPPED |      |
| benchmark-02 | STOPPED |      |
| benchmark-03 | STOPPED |      |
| benchmark-04 | STOPPED |      |
| benchmark-05 | STOPPED |      |
| benchmark-06 | STOPPED |      |
| benchmark-07 | STOPPED |      |
| benchmark-08 | STOPPED |      |
| benchmark-09 | STOPPED |      |
| benchmark-10 | STOPPED |      |

The containers are in the stopped state. That is, they do not consume memory. How much free memory is there?

$ free
       total  used   free shared buff/cache available
Mem: 1016020 56192 791752 2928 168076 805428
Swap:      0     0      0

About 792MB free memory.

There is not enough memory to get them all to run at the same time. It is good that they get into the stopped state when you reboot, so that you can fix.