0

I'm trying to configure a LAMP server. Actually I opted for Nginx but I guess it's irrelevant to the topic. The server is to be used as a wordpress host. I'm planning to use APC to fully cache pages (APC Object Cache Backend and Batcache plugins).

My question is not about the amount of RAM installed into a machine but about the proportion of RAM allocated to each component of the LAMP (or LEMP) server. I'm asking this because every article that I've found on memory configuration says the same:

  • allocate all available memory to <put the name of the component here>

I have the following components that compete for RAM:

  • Nginx
  • php-fpm
  • Percona MySQL
  • APC

Something tells me letting these processes compete for the memory is a bad idea. They need to know their limits.

I understand that the actual memory allocation may depend on the website usage but is there a proportion for starters? For example, allocate 20% to MySQL, 40% to APC, 20% to php-fpm, leave the rest to the system?

Michael Hampton
  • 252,907
Dmitry
  • 9

1 Answers1

0

OK, well first off you don't generally "allocate" RAM to components. Processes REQUEST RAM (typically through malloc() or similar means), and the operating system's kernel either grants or denies the request depending on available resources.
The kernel also does things like figure out if you don't have enough RAM and need to use swap space to fake it, or if a program requested a whole bunch of RAM it's not actively using (which can be dumped into swap to free up more of the real physical RAM).

Now some programs - like database servers, caching servers, etc. - allow you to take a guess at how much RAM they should request. If that's what you're asking about the correct answer is "As much RAM as they need to achieve optimal performance on your workload".

How do you know how much RAM each component needs to achieve optimum performance?
Load Testing And Capacity Planning! -- You test your environment on your workload, and determine where it's bottlenecking, then you tweak things until the performance is where you want it.

The only rule of thumb is "start with the default configuration and modify as needed".

voretaq7
  • 80,749