How much memory does a webserver need?

How much memory does a webserver need?

RAM

More memory generally means your server is better in handling demanding applications. Yet, even with multiple gigabytes of RAM available, a webserver can still go out-of-memory (OOM) ... and make your website go offline. How can you prevent this? 

What needs what?

So, what takes up all the RAM of your server? A small part of the available memory is used by the operating system and its applications. The biggest chunk of memory however is reserved for all the applications and its users. It is not uncommon for PHP applications to require tens of megabytes of memory... for each user connection. Finally, a part of the memory is needed for database storage.

Caching

Because you get better and faster access to the data stored in RAM, the operating system will always try to optimize the usage of the available memory. The available memory is used for the caching of all recently opened files, so that the files can be read from your RAM instead of the slow hard drive. Caching increases your performance, so, don't limit the amount of RAM in your server. Make sure there is always some RAM available.

Types of website

The type of website also has a great influence on the amount of RAM that is needed. Is your website purely written in html or are you using a CMS which dynamically builds web pages? As can be expected, the latter category will need more memory. Some content management systems, like Drupal and Magento, are known for needing quite a lot of memory for themselves. 

The following 6 insights about memory usage are mostly relevant for dynamic websites.

  1. Traffic spike When a website is unexpectedly hit with thousands of visitors at once, every server will have a difficult time, no matter how much RAM it has. A single webserver is generally not capable to cope with such high traffic. Caching can help to ease the burden, but very dynamic websites that are popular will need an optimized environment with multiple servers to spread the load.

  2. PHP config For each visitor of your website, PHP applications will allocate a small piece of the available memory. The size is determined by the PHP settings, that can be changed through the Control panel. The setting 'memory_limit' should be changed to provide each visitor with more or less memory. 

The purpose of the memory_limit setting is to protect PHP scripts from using an unlimited amount of memory due to, for example, bad code. We advise you to set this value high enough for the application to run smoothly. Don't set it too high though, or the server will easily go out-of-memory. 

Another important PHP setting to take into account, is the number of concurrent users. This setting determines the maximum number of visitors that can load a webpage from your site at exactly the same moment. Depending on your server and the type of website you run, Combell will choose the optimal setting for your website. Contact us if you want to change this setting.  
 

    TIP: you can calculate the maximum amount of available RAM needed, by multiplying the number of concurrent users with the memory_limit setting.

  3. More than one Running multiple websites on a single server is very common practice. Although this approach is quite economical, you must be aware that all those websites are sharing the same server resources, including the RAM. When one of the websites temporarily needs more RAM, this will have consequences for the other websites and even may decrease their performance.

  4. Bad code Don't be surprised, but many times it's the programming that causes inefficient use of the memory. To gain insight in how the underlying code works and how it affects server resources, you can rely on application monitoring tools like New Relic. With this specialized tool, you can pinpoint performance bottlenecks right in the code of the website itself. Let us know if you want us to activate a free trial of New Relic on your server!

  5. Search robots From time to time, a search robot will visit your website and index it. This is very normal. However, some of these bots can be quite aggressive, because they try to index the whole website instead of just a selection of pages. They can consume a lot of server memory that way. If you want more control over which bots can access your website, you can add a file called robots.txt in the root folder of your website. Find out more about the usage of robots.txt on this site

  6. Attackers Not all robots have good intentions. So-called 'bad bots' also visit your website. Many websites are powered by a content management system that can be accessed by a special administration login page. By just randomly trying combinations, these bots will try to get into the CMS. In many cases, a botnet of hundreds or even thousands of hacked computers is used to perform these kind of unwanted actions. The load of this unwanted traffic can take down your website or server. To prevent this you must choose a strong password, and always keep the cms and its plugins up-to-date.

SSD Hosting: your website or web store up to 20 times faster!

  • 24/7 free support and domain name
  • Money back guarantee
  • User-friendly control panel
More information?

Couldn't find a solution?

Our team is available 24/7 to provide you with free assistance. Feel free to contact our collaborators, free of charge, via e-mail or telephone.

0800-8-5678

+32 (0)9 218 79 79