Setup for a linode 512 with a Forum

Hello everyone,

New to all this so please excuse the basic questions. First I recent got a 512 node and have set it up as follows:

Ubuntu 10.04 LTS

PHP 5.3.6 (FPM)

APC 3.1.7

Nginx 0.8.54

MySQL 5.1.41

I have a basic firewall in place that basically only opens port 80 and my SSH port. SSH root login is off. Everything is working thus far and I have installed an SMF forum and a backup database to test things out.

Now my primary question is about memory usage, I'm not sure where to start on some of the items so I'm looking for some recommendations.

APC shared memory is set to 128M, is this to high, should this be a % of system memory or based off the number of potential FPM processes?

PHP-FPM process. Right now it is set up in dynamic mode with max 50, start 8, min spare 5, max spare 10. I'm not sure how to relate the number of process to users or traffic to determine a starting point.

MySQL is set up as follows, these are basically 45% of memory from looking at one of the stackscripts. Over time I figure that I can tune these with one of the mysql scripts after I've collected some data.

key_buffer = 176M

sortbuffersize = 4M

readbuffersize = 4M

readrndbuffer_size = 4M

myisamsortbuffer_size = 16M

querycachesize = 32M

4 Replies

@spuds:

APC shared memory is set to 128M, is this to high, should this be a % of system memory or based off the number of potential FPM processes?
APC has script apc.php, this script can show, which amount of memory is used by APC. If APC has filled 50-70% of memory - it's fine. If less - you can decrease apc.shm_size.

Check, that apc.slam_defense = Off

@spuds:

key_buffer = 176M

sortbuffersize = 4M

readbuffersize = 4M

readrndbuffer_size = 4M

myisamsortbuffer_size = 16M

querycachesize = 32M
max_connections? Default 100?

Set max_connections to 50 as maximum and you will able to increase buffer's sizes.

To control memory usage, use this script: http://www.day32.com/MySQL/tuning-primer.sh

If you will need help with tuning - paste output of script execution here.

Reduce your maximum fpm processes or it will chew your ram up, assuming you could allocate all your ram to your 50 processes you'd have 10MB of ram per process, which most php forums will chew through, since you obviously can't allocate all your ram it's will OOM (out of memory).

I'd say put apc around 32MB, apc caches the files and since the files tend to be small you don't need much memory for them.

fpm set around 20-25

Mysql, your key_buffer is a bit high, do you have very large myisam indexes? You probably don't need it that high, something around 16M is more normal for a small machine.

Download and run http://mysqltuner.pl/mysqltuner.pl after your server has been up a few days to see if it advises changing anything.

A couple of other tips, enable gzip compression in nginx, if you have static files that don't change very often set the expires option in nginx.

I'm going to assume that the number of fpm processes is roughly equivalent to if you're running lighttpd with PHP in fastcgi, which I am. In which case, 50 is insane. Unless you have blocking long-running scripts, 8 as an absolute cap is fine; it ensures you can get two processes per core, and 4 slow scripts will still leave one process per core to serve stuff. Maybe I could see a bit higher than that being useful, but not by much. I think the default lighttpd setting is 10 or 12? And that' sufficient for massive load.

Thank you for all the help, I've made a bunch of changes and things look much better (using top and free) for a starting point now. Before I started to change things the memory was almost all committed with just me on line!

> maxconnections? Default 100? It was 150, now its 50. Also tweaked some of the per connection buffer limits (sortbuffersize, readbuffersize, readrndbuffersize) so I did not consume massive amounts of memory on each connection.

> APC has script apc.php, this script can show, which amount of memory is used by APC. If APC has filled 50-70% of memory - it's fine. If less - you can decrease apc.shm_size.

Check, that apc.slam_defense = Off
> I'd say put apc around 32MB, apc caches the files and since the files tend to be small you don't need much memory for them. Done… it was only about 20% used so I lowered the shared memory down quite a bit, I think its at 48M now which holds all the scripts with room to spare for extra. I set the slam.defense to 25% chance.

> Mysql, your key_buffer is a bit high, do you have very large myisam indexes? You probably don't need it that high, something around 16M is more normal for a small machine. ts an SMF 2.0 board and its still set up as an isam so it needs that value to be pretty high.

> A couple of other tips, enable gzip compression in nginx, if you have static files that don't change very often set the expires option in nginx. Done and done, made sure it was working with pagespeed.

> I'm going to assume that the number of fpm processes is roughly equivalent to if you're running lighttpd I think that is correct so I've adjusted the startup, min spare, max spare and max ever settings to be in line with what you have indicated. I'll have php-fpm status setup so I can see what the pools do.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct