Puppet node inheritance is not the same as inheritance in most other programming languages . Included classes are evaluated immediatelly when the child is evaluated. And the parent node is evaluated after that. Therefore my example will never work. If you want to know recommended solution for this, read puppet - common misconceptions. I did it this way and it works.
Although I have to admit that I'm pretty disappointed right now, because complex puppet syntax might be confusing for starters.
The idea behind the calculation is that you need to keep some memory for other things - the operating system and other services running on the instance. After that, whatever you have left, you divide by the average memory used (resident set size - RSS column) to get the maximum number of threads your server can handle without running out of memory.
That said, I like to do my calculation slightly differently, but I'll address that later.
From httpd.conf:
prefork MPM
- StartServers: number of server processes to start
- MinSpareServers: minimum number of server processes which are kept spare
- MaxSpareServers: maximum number of server processes which are kept spare
- ServerLimit: maximum value for MaxClients for the lifetime of the server
- MaxClients: maximum number of server processes allowed to start
- MaxRequestsPerChild: maximum number of requests a server process serves
The config you have shown will keep a constant 10 processes running: you start 10 processes (StartServers) and you have a maximum of 10 server processes you allow (MaxClients). In this case, the MinSpareServers and MaxSpareServers shouldn't come into play. After a server process has served 4000 requests, it will be terminated and a new one created in its place (to try and limit memory leaks, etc)
So, the assumption being made is that everything else on your server will use about 80MB of memory - leaving you with 530MB. Divide that by your average process size (53MB) to get 10 processes.
I'd suggest that the assumption is off a bit. If you are running anything else (e.g. MySQL) on the server, you definitely need to keep more memory in reserve. Additionally, there is no room for variation factored in. For estimation, I would leave at least 120MB for the operating system and other services and then reduce the remainder by 10% for variation. So, about 8 apache processes max.
<IfModule prefork.c>
StartServers 2
MinSpareServers 1
MaxSpareServers 3
MaxClients 8
MaxRequestsPerChild 1000
</IfModule>
So, with the above - there are a maximum of 8 processes. We are only starting 2. We would like at least one idle at any given time - but no more than 3 idle. Also, since memory is an issue, the MaxRequestsPerChild has been reduced.
Now, I prefer to calculate the number by actually running the server for a bit, then stopping apache and seeing how much memory the rest of the system is using. Subtract that number from your total, take 90%, and divide by your average apache process size. Especially for more complex setups, this gives a more realistic value.
As a point of mention, on a memory constrained box, Nginx is likely preferable to Apache as a webserver. Also, you definitely want some swap space on a t1.micro (although, you should not find yourself using it much).
Best Answer
You can set
mpm_module
tofalse
, to explicitly declare the prefork-class with custom parameters afterwards.