Analyze System Startup Performance on Ubuntu

Analyze System Startup Performance on Ubuntu

Understanding and optimizing system startup performance is a key responsibility for any system administrator, especially in environments where uptime and responsiveness are critical. Slow boot times can signal underlying problems such as misconfigured settings, failing services, or redundant processes that unnecessarily delay the startup sequence. This tutorial shows how to analyze system startup performance on Ubuntu.

Ubuntu uses systemd, a modern init system that not only manages services but also provides useful tools for analyzing system boot performance.

1. Overall startup performance

To get a quick summary of your system's boot time, run the following command:

systemd-analyze

You'll see an output like:

Startup finished in 4.121s (kernel) + 21.928s (userspace) = 26.049s 
graphical.target reached after 21.905s in userspace

This tells you how long the kernel and userspace (services, scripts, etc.) took to initialize.

2. Identifying slow services

To see which services are taking the most time to start:

systemd-analyze blame

This will list services sorted by startup time, like:

20.670s plymouth-quit-wait.service
12.345s mysql.service
 1.411s containerd.service
 1.354s docker.service
 1.238s e2scrub_reap.service
...

This command helps you identify slow or problematic services. You can then decide whether to disable, mask, or delay the startup of non-essential services.

3. Dependency timing

For a more detailed view of what services are causing bottlenecks due to dependencies, use:

systemd-analyze critical-chain

This command shows the timeline of service startups, highlighting which services are blocking others:

The time when unit became active or started is printed after the "@" character.
The time the unit took to start is printed after the "+" character.

graphical.target @21.905s
└─multi-user.target @21.905s
  └─plymouth-quit-wait.service @1.235s +20.670s
    └─systemd-user-sessions.service @1.165s +35ms
      └─network.target @1.051s
        └─NetworkManager.service @770ms +278ms
          └─dbus.service @765ms
            └─basic.target @745ms
              └─sockets.target @745ms
                └─docker.socket @744ms +710us
...

By default, it analyzes the first service that was delayed in the boot process.

4. Focus on specific services

To analyze the startup impact and dependencies of a particular service (e.g. MySQL), you can pass the service name to critical-chain:

systemd-analyze critical-chain mysql.service

Output example:

The time when unit became active or started is printed after the "@" character.
The time the unit took to start is printed after the "+" character.

mysql.service +12.345s
└─network.target @1.051s
  └─NetworkManager.service @770ms +278ms
    └─dbus.service @765ms
      └─basic.target @745ms
        └─sockets.target @745ms
          └─docker.socket @744ms +710us
            └─sysinit.target @736ms
...

This helps isolate and analyze a specific service in detail, which is useful when you're tuning or troubleshooting one component in particular.

Leave a Comment

Cancel reply

Your email address will not be published.