How to Best Optimize your VPS Server

If you have a VPS system with 512MB of RAM or less (or even with 1GB of RAM) and feel slow, you can improve server performance with some simple tricks.

You can get Virtualmin on your hosting provider to use less than 100MB of RAM, but we also have to pay attention to Apache processes (150-200MB if we have all modules active), MySQL, BIND or Postfix

Here are best 10 tricks to optimize RAM consumption on a VPS server with Virtualmin

#1 32 or 64-bit system

If you have less than 3GB of RAM, it would be advisable to use a 32bit Linux system. The 64bit architecture consumes more RAM. Keep in mind, this will impose limitations on your system in the future (or right now), so consider “passing” this option and focusing on the others.

#2 De-activate the preload of Virtualmin

Let’s go to System Settings >Virtualmin Config. And change «Preload Virtualmin libraries at startup? » to No.

We will reduce the consumption of about 90MB (120MB in a 64bit system) to only about 10MB of RAM.

#3 Reduce memory usage of SpamAssassin and ClamAV

If you don’t need them, disable them. However, if you want to reduce your RAM usage, you can do the following in Virtualmin:

We go to System Settings> Spam and Virus Scanning and enable SpamAssassin and ClamAV

#4 Reduce Apache memory usage

In this case, it depends a lot on how much RAM you have. Therefore, it is best to test it. However, this configuration can be valid for a system with 512MB or 1GB of RAM. If you have more RAM, you just have to multiply the x2 values ​​to optimize the result.

We can edit the Apache configuration file to be:

and we change the following:

We can also deactivate the Apache modules that we do not need.

#5 Deactivate services that are not necessary

If you do not use PostgreSQL, proftpd, Mailman, etc. You can disable them and save a few MB of RAM

#6 configure a SWAP partition

If your system allows it, configure a SWAP partition on your Linux system.

#7 Optimize MYSQL for low RAM system

Edit the configuration file to be:

vi /etc/my.cnf

This change will also be trial and error depending on the RAM you have, but you can test this:

You can visit this entry:  Optimize and tune my.cnf (Mysql) on your VPS server

#8 Use some cache system

You have to use a cache system on your server like the one that Memcache, OPcache, Varnish, Redis can provide you with. There are many options out there so that it values ​​which one best suits your system. I use Memcache and OPcache on my pages with WordPress.

#9 Host your websites in a good hosting

A good VPS server hosting can make a difference. And last but not least.

#10 Use and take benefits of CDN

According to Wikipedia, a CDN (Content Delivery Network in English) is an overlapping network of computers that contain copies of data. The CDNs are placed at various points in a network in order to maximize bandwidth for accessing customer data over the network. While the advice in this section can be applied to any WordPress Hosting installation, including shared servers, I would like to suggest that for your VPS as well since its implementation greatly frees your server from task.

Nowadays, it is effortless to load static resources in a distributed way. Remember that when we connect to a web server, we have a limited number of simultaneous connections. Therefore, there is a bottleneck situation. We have more requests for resources than we can manage simultaneously, so we must take turns.

This is significantly reduced by using CDNs for loading JavaScript libraries such as jQuery, loading webfonts from a provider such as Google Fonts, CSS files, etc.

Of course, the images have a prominent place in this section and I have not mentioned previously. Any website today has many graphic contents, and that is generally the most problematic for server to deliver. Therefore, it is a priority to configure a space in a CDN where you can host these files.