Edge Compute in practice – Ubuntu Server as APT cache node

Post Written by
Orange Cloud Team

Managing server infrastructure introduces a vast array of operational challenges. Among other things, reducing bandwidth consumption and speeding up server upgrades can be a fundamental improvement and make the administrator’s life much easier.
Ubuntu Server instances use APT package management system for software management. It allows system administrators to easily install and upgrade software across all server instances. Having a dedicated edge compute node for caching the DEB packages used by the server instances can dramatically speed up software upgrades across hundreds of server instances. That is what we are showcasing here, Edge Compute in practice - APT cache node

In addition to server instances, the development team can use the same caching node for local development and testing within Vagrant or similar environments. The caching node can speed up the provisioning of local development instances as well.

Setting all up

First, provision a new Ubuntu Server instance on an Edge Compute node on your choice. Preferably, the node should be as close as possible to your infrastructure and development teams for the biggest latency reduction possible.

Once the instance is provisioned and booted up, log into it through SSH and run a quick system upgrade:

sudo apt update && sudo apt full-upgrade -y

If prompted for a system reboot, be sure to reboot the VM now.

Next, install the apt-cacher-ng package:

sudo apt install apt-cacher-ng -y

That’s it! The Edge Compute in practice - APT cache node is now set up and works on port 3142 by default. Make sure to note the VM’s public IP address, you’ll need it later:

curl ifconfig.me 139.162.176.20

All that’s left is to configure the server instances (and Vagrant boxes, if desired) to use the new APT cache. That’s done by placing a new APT configuration file with the proper URL:

sudo echo "Acquire::http::Proxy \"http://139.162.176.20:3142\";" | sudo tee /etc/apt/apt.conf.d/90-apt-proxy > /dev/null

Make sure you’re putting a proper IP address. Now the client machine is configured to use the new APT cache. With the modern automation tools, such as Ansible, it should be trivial to configure a fleet of servers to use the new cache.

It’s important to note that cache can’t be populated with the packages in advance. Also, there’s nothing else that needs to change in day to day package management. The client machines can continue using APT as usual and the cache will start caching and delivering the packages in the background. The cached DEB packages are stored in /var/cache/ apt-cacher-ng/ directory by default.

We can check if the caching works by installing some new packages. For example, nginx can be installed on a new server instance:

sudo apt install nginx -y

Once the nginx is installed, we can check the APT cache node and see the packages now residing in the cache:

$ ls -la /var/cache/apt-cacher-ng/debrep/pool/main/n/nginx
total 1800
drwxr-sr-x 2 apt-cacher-ng apt-cacher-ng   4096 Jul 20 21:10 .
drwxr-sr-x 3 apt-cacher-ng apt-cacher-ng   4096 Jul 20 21:10 ..
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng  92604 Jul 20 21:10 libnginx-mod-http-auth-pam_1.14.2-2+deb10u1_amd64.deb
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng    309 Jul 20 21:10 libnginx-mod-http-auth-pam_1.14.2-2+deb10u1_amd64.deb.head
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng 100092 Jul 20 21:10 libnginx-mod-http-dav-ext_1.14.2-2+deb10u1_amd64.deb
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng    309 Jul 20 21:10 libnginx-mod-http-dav-ext_1.14.2-2+deb10u1_amd64.deb.head
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng 104160 Jul 20 21:10 libnginx-mod-http-echo_1.14.2-2+deb10u1_amd64.deb
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng    306 Jul 20 21:10 libnginx-mod-http-echo_1.14.2-2+deb10u1_amd64.deb.head
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng  93844 Jul 20 21:10 libnginx-mod-http-geoip_1.14.2-2+deb10u1_amd64.deb
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng    306 Jul 20 21:10 libnginx-mod-http-geoip_1.14.2-2+deb10u1_amd64.deb.head
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng  97368 Jul 20 21:10 libnginx-mod-http-image-filter_1.14.2-2+deb10u1_amd64.deb
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng    313 Jul 20 21:10 libnginx-mod-http-image-filter_1.14.2-2+deb10u1_amd64.deb.head
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng  95656 Jul 20 21:10 libnginx-mod-http-subs-filter_1.14.2-2+deb10u1_amd64.deb
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng    312 Jul 20 21:10 libnginx-mod-http-subs-filter_1.14.2-2+deb10u1_amd64.deb.head
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng  95732 Jul 20 21:10 libnginx-mod-http-upstream-fair_1.14.2-2+deb10u1_amd64.deb
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng    314 Jul 20 21:10 libnginx-mod-http-upstream-fair_1.14.2-2+deb10u1_amd64.deb.head
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng  95724 Jul 20 21:10 libnginx-mod-http-xslt-filter_1.14.2-2+deb10u1_amd64.deb
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng    312 Jul 20 21:10 libnginx-mod-http-xslt-filter_1.14.2-2+deb10u1_amd64.deb.head
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng 125508 Jul 20 21:10 libnginx-mod-mail_1.14.2-2+deb10u1_amd64.deb
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng    301 Jul 20 21:10 libnginx-mod-mail_1.14.2-2+deb10u1_amd64.deb.head
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng 147028 Jul 20 21:10 libnginx-mod-stream_1.14.2-2+deb10u1_amd64.deb
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng    303 Jul 20 21:10 libnginx-mod-stream_1.14.2-2+deb10u1_amd64.deb.head
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng  88256 Jul 20 21:10 nginx_1.14.2-2+deb10u1_all.deb
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng    286 Jul 20 21:10 nginx_1.14.2-2+deb10u1_all.deb.head
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng 120412 Jul 20 21:10 nginx-common_1.14.2-2+deb10u1_all.deb
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng    294 Jul 20 21:10 nginx-common_1.14.2-2+deb10u1_all.deb.head
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng 501048 Jul 20 21:10 nginx-full_1.14.2-2+deb10u1_amd64.deb
-rw-r--r-- 1 apt-cacher-ng apt-cacher-ng    294 Jul 20 21:10 nginx-full_1.14.2-2+deb10u1_amd64.deb.head

Make sure to check out our other tech blog posts!

Contact Us

Fill out the enquiry form and we'll get back to you as soon as possible.