Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My server have 512 MB memory. nginx.conf setting is

user www-data;
worker_processes 2;
pid /var/run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

##
# Basic Settings
##

sendfile on;
#tcp_nopush on;
#tcp_nodelay on;
keepalive_timeout 3;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

##
# Virtual Host Configs
##
upstream php {
    server 127.0.0.1:9000;
}


open_file_cache max=5000 inactive=20s;
open_file_cache_valid    30s;
open_file_cache_min_uses 2;
open_file_cache_errors   on;

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

my php fpm config is

user = www-data
group = www-data
pm = dynamic

pm.max_children = 50

pm.start_servers = 25

pm.min_spare_servers = 8

pm.max_spare_servers = 40

I am using one wordpress site. But it's too slow. I have another 512 MB server for the office. It's using apache and it's more faster than nginx + phpfpm. Is there anything wrong in my configuration ?

Memory usages

memory free

Top results

top results

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

dont start so many php servers initially, perhaps consider testing without this block of code too:

open_file_cache max=5000 inactive=20s;
open_file_cache_valid    30s;
open_file_cache_min_uses 2;
open_file_cache_errors   on;

it looks to me like your trying to load too much into ram initially with php though, it also sounds like your website is a little resource intensive based on the memory usage in top, have you considered an opcode cacher like APC? http://pecl.php.net/APC

share|improve this answer
add comment

I'm a bit unsure why you're doing inline gz compression, this takes CPU cycles.. why do you need it?

As anthonysomerset said, lower the number of php children.

share|improve this answer
    
Compression takes almost no time on PCs newer than 15 years. –  demonkoryu Jul 8 '13 at 10:06
    
Also with 2000-3000 conns/sec? –  Marki555 Feb 10 at 20:47
add comment

I use a similar setup with nginx and php-fpm with APC. The Min and Max Servers are a bit high, I also have a virtual machine with about 500mb of memory per machine. After reading http://stephentanner.com/index.php/2011/07/tuning-php-fpm/ I've tuned my machines to the following.

pm.max_children = 6
pm.start_servers = 2
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.max_requests = 50

My machines sit with 4 php-fpm processes at about 60mb each eating about 252mb which leaves more resources for nginx/mysql/whatnot.

Give that a try if it doesn't fit your need exactly tune it a bit more.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.