Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Mon Mar 28, 2011 8:55 pm 
Offline
Newbie

Joined: Sat Mar 26, 2011 11:53 pm
Posts: 2
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
sort_buffer_size = 4M
read_buffer_size = 4M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 16M
query_cache_size = 32M


Top
   
PostPosted: Tue Mar 29, 2011 4:48 am 
Offline
Senior Member

Joined: Sat Mar 12, 2011 3:43 am
Posts: 76
Location: Russia
spuds wrote:
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 wrote:
key_buffer = 176M
sort_buffer_size = 4M
read_buffer_size = 4M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 16M
query_cache_size = 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.


Top
   
 Post subject:
PostPosted: Tue Mar 29, 2011 6:25 am 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
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.

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
 Post subject:
PostPosted: Tue Mar 29, 2011 10:09 am 
Offline
Senior Member
User avatar

Joined: Tue May 26, 2009 3:29 pm
Posts: 1691
Location: Montreal, QC
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.


Top
   
 Post subject:
PostPosted: Tue Mar 29, 2011 7:56 pm 
Offline
Newbie

Joined: Sat Mar 26, 2011 11:53 pm
Posts: 2
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!

Quote:
max_connections? Default 100?
It was 150, now its 50. Also tweaked some of the per connection buffer limits (sort_buffer_size, read_buffer_size, read_rnd_buffer_size) so I did not consume massive amounts of memory on each connection.

Quote:
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

Quote:
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.

Quote:
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.

Quote:
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.

Quote:
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.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group