Skip to content

Website & Server Help

Unlimited Webspace Help

Menu
  • Home
  • Apps
  • Website
    • Sending email from a WordPress website hosted on an IONOS server
    • How to increase Upload Max Filesize
    • How to reset a WordPress password
    • 22 Ways To Speed-Up A Plesk Website
  • Server
    • Linux or Plesk Server Error 500
    • Windows Server: File cannot be loaded. The file is not digitally signed.
    • Adding or modifying IP addresses on a Linux server
    • Installing Remote Desktop on Debian 12
    • Installing Remote Desktop on Ubuntu 22.04
    • How To Install a Let’s Encrypt SSL in Apache on Debian/Ubuntu
  • Favs
    • How to Connect to a Server
    • The Ultimate Guide to Setting Up a Proper Plesk Email Server With IONOS
    • The Ultimate IONOS Migration Guide
    • Help! My Plesk Websites Are Down!
    • Running tests for a slow server or dropped packets
    • Checking File System and Hard Drive Health
Menu

Troubleshooting a slow website on a Linux server, Part 1: The processes on the server

Posted on January 31, 2023June 30, 2023 by admin

Websites hosted on an Apache server can slow down for various reasons, such as high resource usage by other processes, outdated software, or misconfigurations. In this tutorial, we will cover how to use various commands in Ubuntu to identify the processes that are causing the slowdowns and how to resolve the issue.

Identify High Resource Usage

One common cause of slow websites is high resource usage by other processes on the server. To see which processes are using the most resources, run the following command in the terminal:

ps aux

The ps aux command will display a list of all running processes and their resource usage, including CPU, memory, and disk I/O. Look for any processes that are using a high percentage of CPU or memory.

Another useful command for identifying high resource usage is top, which provides a real-time view of the server’s resource usage:

top

The top command will display a list of the processes that are using the most resources at the current moment. You can sort the list by CPU or memory usage by pressing the Shift + p or Shift + m keys, respectively.

Determine the Number of Cores

To accurately interpret the results of the top command, it is important to know the number of cores on the server. To find the number of cores, run the following command:

nproc --all

Find the Location and Command of the Process

Once you have identified the process that is causing the slowdowns, you need to determine where it is located on the system and what command or file called it to run.

To find the location of the process, use the lsof command and the process ID (PID) from top:

lsof -p [PID]

This will display a list of all the open files associated with the process, including the executable file and any configuration files.

To find the command or file that started the process, use the ps command with the process ID:

ps -p [PID] -o cmd

Change Process Priorities with renice

In some cases, you may be able to resolve the slowdowns by adjusting the priority of the processes that are using high resources. To adjust the priority of a process, use the renice command and the process ID:

renice [priority] [PID]

The priority value should be between -20 and 19, with a lower number indicating a higher priority. 0 is base priority. 19 is highest. For example, to give a process a higher priority, you could use the following command:

renice -10 [PID]

Force Stop the Process with kill

If adjusting the priority of the process does not resolve the slowdowns, you may need to force stop the process. To force stop a process, use the kill command and the process ID:

kill -9 [PID]

Note: Before force stopping a process, make sure to backup any important data associated with the process and verify that the process is not a critical component of the system or another website.

Special Offer

The internet's fastest, cheapest, unlimited bandwidth VPS

VPS
1core | 1GB RAM | 10GB NVMe
Unlimited Bandwidth | 1Gbps
$2/month - risk free