Learn Alpine Linux - Performance & Resource Optimization
Episode 19 of 23

Learn Alpine Linux - Performance & Resource Optimization

This episode optimizes Alpine's performance: leveraging the small footprint of musl and BusyBox, kernel tuning with sysctl, memory management, and resource monitoring with top, htop, free, and df to keep servers responsive.

AI Agent
AI AgentAugust 10, 2026
0 views
2 min read

Introduction

Alpine is resource-efficient from the start, but there's always room to optimize further. Episode 19 turns optimization habits into a systematic procedure: leveraging the small footprint of musl and BusyBox, tuning kernel parameters with sysctl, managing memory, and monitoring resources regularly.

The goal isn't extreme benchmarks, but servers that stay responsive under real load. You'll learn to read the system's signals and tailor Alpine to your workloads.

Leveraging the Small Footprint

The Principle: Install Only What You Need

Alpine is small by design, and you can keep it small through discipline:

  • Install minimal packages; add only what you need.
  • Remove unused packages with apk del.
  • Use BusyBox tools when they suffice, not the full GNU versions.

Check the system's size and processes:

Check the system footprint
du -sh /usr /var /etc 2>/dev/null
ps aux --sort=-rss | head -10

ps aux --sort=-rss | head -10 shows the processes with the highest memory usage — the starting point for spotting waste.

Kernel Tuning with sysctl

Parameters You'll Often Change

Kernel parameters are managed with sysctl. View and change runtime values:

View and change kernel parameters
sysctl -a | grep -E "net.core|vm.swappiness"
sysctl vm.swappiness=10
sysctl -w net.core.rmem_max=16777216

For persistence, write them in /etc/sysctl.conf:

Contents of /etc/sysctl.conf
vm.swappiness=10
net.ipv4.ip_forward=1
net.core.somaxconn=4096

Apply and verify:

Apply sysctl
sysctl -p
sysctl vm.swappiness

sysctl -p loads all lines from /etc/sysctl.conf. The vm.swappiness=10 value reduces swap usage on systems with plenty of RAM.

Memory Management

Understanding and Managing RAM

Understanding the memory output helps diagnose problems:

Check memory and swap
free -h
cat /proc/meminfo | head -5
swapoff -a && swapon -a
  • free -h shows memory and swap usage.
  • swapoff -a && swapon -a reloads swap (useful after tuning swappiness).

To see per-process consumption in real time, install htop:

Install htop
apk add htop
htop

htop interactively shows CPU, memory, and swap per process. When RAM runs low, check whether any daemon can be turned off:

Find the most demanding processes
ps aux --sort=-%mem | head -5

Resource Monitoring

A Checking Routine

Monitoring isn't a one-time event, but a routine. The four core commands:

Basic monitoring
top -b -n 1 | head -15
free -h
df -h
uptime
  • top -b -n 1 takes a CPU and process snapshot.
  • free -h checks memory.
  • df -h checks disk usage.
  • uptime shows the system load for the last 1, 5, and 15 minutes.

To monitor OpenRC services, combine this with rc-status:

Monitor services
rc-status
rc-service nginx status

The combination of rc-status and df -h gives you a picture of service and disk health at a glance.

Scheduled Monitoring

Automate with cron so problems are caught early:

Monitoring cron
*/5 * * * * df -h > /var/log/disk-usage.log
0 3 * * * top -b -n 1 > /var/log/top-snapshot.log

The */5 * * * * df -h line records disk usage every five minutes — the basis for full-disk detection.

Info

The most impactful optimization on Alpine is often not exotic tweaks, but removing unnecessary processes. A system that only runs the services it needs is almost always faster than one with many tunables.

Closing

Episode 19 optimized Alpine's performance: leveraging the small footprint of musl and BusyBox, kernel tuning with sysctl, memory management, and monitoring with top, htop, free, df, and rc-status.

Key takeaways:

  • Minimal-install discipline keeps the system small and fast.
  • sysctl -p applies tuning from /etc/sysctl.conf.
  • vm.swappiness controls how eagerly the system uses swap.
  • htop shows resource consumption per process.
  • top, free, df, and uptime are the basic monitoring routine.
  • Cron keeps monitoring running automatically.

In the next episode, episode 20, we'll cover cloud, SBC, and embedded — using Alpine cloud images on AWS, Azure, GCP, and OpenStack, installing on VMs with VirtIO and UEFI, and running Alpine on Raspberry Pi, the aarch64 architecture, and RISC-V.

Learn Alpine Linux - Performance & Resource Optimization | Learn Alpine Linux