how to reduce server load in linux

How to Reduce Server Load in Linux

Last updated on October 10th, 2022 at 10:01 am

It is important to regularly monitor server load, check which process is taking high load and take steps to troubleshoot high server load. This will improve website performance, improve user experience and reduce server costs. Here are the key tips to reduce server load for your website.


How to Calculate Server Load

Server load is a combination of CPU and disk usage. You can check server load in Linux using ‘w’ or ‘uptime’ commands. Linux will output average load value.

$ uptime 
10:40:40 up 18 days, 1:07, 1 user, load average: 0.15, 0.10, 0.10

You can also use third-party tools like Solarwinds and Nagios to check server load in Linux. They automatically calculate server load on a regular basis and plot results on intuitive graphs and dashboards that you can share with your team.

How to Reduce Server Load in Linux

Here are some important tips to reduce server load.

1. Optimize Website Images

Images are responsible for up to 50% of a website’s bandwidth. There are many image compression tools that can compress JPG, PNG, GIF images by up to 80%. Compressed images reduce server load by decreasing its CPU usage.

Use CSS effects instead of images, wherever possible. Similarly, use CSS sprites instead of separate icon images. CSS sprite is a collection of images put in a single image. So you can have a single CSS sprite that contains all your image icons. This will reduce your server load considerably, since it has to serve only one file, instead of separate icons.

Also, consider using new-age image formats such as webp which are up to 26% smaller than PNG files.

Avoid using high-resolution images on your website. A maximum image resolution of 1200×800 px is enough to look great on all devices.

Also disable image hotlinking on your website, so that other websites do not render images by linking to yours.


2. Compress HTML Resources

There are many third-party tools like Minify and HTML Minifier that allow you to compress and minify CSS, JS and HTML files for your websites. These tools automatically remove any comments & whitespaces, and replace long variable names with shorter ones to reduce the file size.


3. Compress your data

Most popular servers such as Apache and NGINX allow you to compress data before sending it to the client browser, which is automatically uncompressed and rendered by the browser for its user.

In fact, they even allow you to specify compression algorithm (gzip, bzip2, etc) to be used for data compression. Here’s how to enable GZIP compression in Apache.


4. Host Images on Third-party websites

Typically Ecommerce websites, photo sharing apps and social media platforms tend to have a lot images on their servers. In such cases, you may want to host these images on a third-party service such as Flikr or ImageShack, or even try a CDN.


5. Review Most Frequent Code

Every website and application has a set of features that are most frequently called upon by most users. For example, the product catalog, product details page and checkout pages are the most frequently accessed pages on an Ecommerce site.

Review the back end code that goes behind the processing of requests to these pages. Look for loops, variables and files that can be optimized or removed, as these tend to consume a lot of memory as well as increase CPU usage.

The key to reducing server load is to systematically compress every aspect of your website, and streamline most frequently used code on it. Hopefully, the above article will help you reduce server load in Linux.