How to Maximize Performance on a Linux Server?

Despite advances in computing technology, properly tuning your servers is vital to ensuring the success of your company because wasted resources can increase utility costs while also putting your data center under unnecessary strain. Fortunately performance tuning is something you can grasp fairly easily by following a few simple steps. While there are many server packages on the marketplace, this guide is focused on users running Apache on Linux systems as it is the most prevalent systems in-use.

linux

Build a Lean System

One of the first steps in ensuring that you are running an optimal system is to ensure that you are only running the services you need for mission critical tasks. While you can use the built-in process viewer Top to diagnose unnecessary services, Htop is a more powerful package for server administrators. While it isn’t installed by default in most Linux distros, it can be added simply by using the following commands:

On CentOS & RedHat based systems with the following command:~ yum install htop

On Ubuntu systems, Htop can be installed with the following command: sudo~apt-get install htop~

After installing Htop, it can be run simply by using the command htop.

Remove Unnecessary Language Support

While the exact services needed for your system may vary from project to project, in most cases, you likely will not need Perl or Python support enabled on your servers. To remove these packages, you can use the following commands:

mv /etc/httpd/conf.d/perl.conf /etc/httpd/conf.d/perl.conf-disabled

mv /etc/httpd/conf.d/python.conf /etc/httpd/conf.d/python.conf-disabled

Then, use the following command to restart Apache:~ /etc/init.d/httpd restart

Common Services which can be disabled

The following command can be used to further lighten Apache in one shot. If you see a service in the list below which is necessary for your projects, you should remove the appropriate line before executing the command.

perl -0 -p -i \

-e 's/#?(LoadModule\ authn_alias_module\ modules\/mod_authn_alias\.so)/#\1/;' \

-e 's/#?(LoadModule\ authn_anon_module\ modules\/mod_authn_anon\.so)/#\1/;' \

-e 's/#?(LoadModule\ authn_dbm_module\ modules\/mod_authn_dbm\.so)/#\1/;' \

-e 's/#?(LoadModule\ authnz_ldap_module\ modules\/mod_authnz_ldap\.so)/#\1/;' \

-e 's/#?(LoadModule\ authz_dbm_module\ modules\/mod_authz_dbm\.so)/#\1/;' \

-e 's/#?(LoadModule\ authz_owner_module\ modules\/mod_authz_owner\.so)/#\1/;' \

-e 's/#?(LoadModule\ cache_module\ modules\/mod_cache\.so)/#\1/;' \

-e 's/#?(LoadModule\ disk_cache_module\ modules\/mod_disk_cache\.so)/#\1/;' \

-e 's/#?(LoadModule\ ext_filter_module\ modules\/mod_ext_filter\.so)/#\1/;' \

-e 's/#?(LoadModule\ file_cache_module\ modules\/mod_file_cache\.so)/#\1/;' \

-e 's/#?(LoadModule\ info_module\ modules\/mod_info\.so)/#\1/;' \

-e 's/#?(LoadModule\ ldap_module\ modules\/mod_ldap\.so)/#\1/;' \

-e 's/#?(LoadModule\ mem_cache_module\ modules\/mod_mem_cache\.so)/#\1/;' \

-e 's/#?(LoadModule\ status_module\ modules\/mod_status\.so)/#\1/;' \

-e 's/#?(LoadModule\ speling_module\ modules\/mod_speling\.so)/#\1/;' \

-e 's/#?(LoadModule\ usertrack_module\ modules\/mod_usertrack\.so)/#\1/;' -e 's/#?(LoadModule\ version_module\ modules\/mod_version\.so)/#\1/;' /etc/httpd/conf/httpd.conf

Then, use the following command to restart Apache:~ /etc/init.d/httpd restart

Performance Enhancement Tools

Simple Tools for WordPress

If you are running a WordPress-based website, one of the simplest ways to enable caching on your server is to install the W3 Total Cache plugin on your system. This tool allows you to have a central hub to enable multiple optimization features on your install. Key features include integration for multiple types of caching, content delivery network (CDN) integration, minification, reverse proxies, and much more to improve your performance in a few simple steps.

Utilities for Drupal

Since Drupal is often used for complex websites, optimizing those systems can be a challenge at times. While Drupal performance tuning is a complex subject which cannot be fully covered in this article, using the Boost module is a simple way to enable caching on your site for non-logged in users.

If you want to further improve your performance, you can use the following .htaccess rule to improve server performance:

# Use mod_deflate to gzip components

<IfModule mod_deflate.c>

AddOutputFilterByType DEFLATE text/css application/x-javascript application/javascript text/plain text/html text/xml application/xml

</IfModule>

 

# Disable ETags (can help if you're using multiple servers, or use cloud hosting)

# see: http_://www.askapache.com/htaccess/apache-speed-etags.html~for more info

FileETag None

Content Delivery Networks

Using a content delivery network (CDN) is one of the most effective ways to improve your website performance because it allows you to have access to a global network of servers at an affordable price. By using a CDN, you can reduce the load on your server while ensuring your customers have their site requests served from the datacenters which are closest to their location. While there are many CDN offerings on the market, Amazon CloudFront is worth looking into as it is one of the largest and most affordable services on the web.

Aside from being developer friendly, the service also has flexible billing ensuring that you can use the service with large and small projects without worrying about breaking the bank.

 

Enable a Reverse Proxy

One of the most efficient ways to improve your server performance is to enable Varnish for your websites. Although the configuration process can be complex and it requires an additional server to house the software, Varnish has been shown to cause 300 - 1000x improvement when properly configured. It is important to note that the performance of this cache is only as good as the network it is connected to. This means that a low-quality bandwidth pipe can degrade the performance of your website significantly.

Switch to a High Performance Engine

Although Apache is a versatile platform well suited for many applications, handling highly trafficked websites often is its weak point. For some projects, switching to Nginx can yield significant performance enhancements if configured properly. As discussed in W3 Techs, as of 2013, Nginx (pronounced engine-ex) has overtaken Apache for powering the top 1,000 websites on the internet.

The biggest difference between Apache and Nginx is that the former is process-driven whereas the latter is event-driven. This means that Nginx has a performance advantage because it can easily deliver content to thousands of users (often more) simultaneously whereas Apache and Microsoft IIS struggle with such volume.

Although Nginx tuning is something which cannot be covered in this article, ArsTechnica did a thorough piece outlining the process of switching from Apache to Nginx. Although the article is from 2011, it still remains a solid resource outlining the key concepts of the server.

Conclusion

Although hardware today is much cheaper than in the past, properly tuning your Linux servers is crucial to ensuring your company is getting the most money from its IT budget. By following the previously mentioned steps in this article, you can ensure that your IT budget is kept in check even when your websites are facing large amounts of traffic.

Read more on ways to diagnose if your Linux Server crashes.

 

 

 

Comments (0)