MRatWork Forum by Mustafa Ramadhan
Sawo Project - Kloxo-MR Discussions => Kloxo-MR Technical Helps => Topic started by: Anik on 2013-02-20, 13:06:25
-
Hello guys,
i tried all the trial and error methods with the configuration files in my vps, for sometime it worked but it now again started to giving headaches. everyday i am getting 1-2 hours of downtime. The problem is in php-fpm, it's expiring as usual and the only way to fix it is to restart it manually or automatically. So i decided to post here most of the config files, test them, tweak them, drop them do anything you want. only we need a highly optimized configuration which will utilize every possible resource and will be top in performance and speed.
Before i began, the hardware and software of the sever is 8 core xeon, 2GB RAM, 4GB swap. nginxproxy, php-fpm event, php53u.
So lets drool. :)
# /etc/security/limits.conf
# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#<domain> <type> <item> <value>
#
#Where:
#<domain> can be:
# - an user name
# - a group name, with @group syntax
# - the wildcard *, for default entry
# - the wildcard %, can be also used with %group syntax,
# for maxlogin limit
#
#<type> can have the two values:
# - "soft" for enforcing the soft limits
# - "hard" for enforcing hard limits
#
#<item> can be one of the following:
# - core - limits the core file size (KB)
# - data - max data size (KB)
# - fsize - maximum filesize (KB)
# - memlock - max locked-in-memory address space (KB)
# - nofile - max number of open files
# - rss - max resident set size (KB)
# - stack - max stack size (KB)
# - cpu - max CPU time (MIN)
# - nproc - max number of processes
# - as - address space limit
# - maxlogins - max number of logins for this user
# - maxsyslogins - max number of logins on the system
# - priority - the priority to run user process with
# - locks - max number of file locks the user can hold
# - sigpending - max number of pending signals
# - msgqueue - max memory used by POSIX message queues (bytes)
# - nice - max nice priority allowed to raise to
# - rtprio - max realtime priority
#
#<domain> <type> <item> <value>
#
#* soft core 0
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#@student - maxlogins 4
# End of file
admin soft nofile 15000
admin hard nofile 32000
nginx soft nofile 10000
nginx hard nofile 22528
mysql soft nofile 10000
mysql hard nofile 16384
root soft nofile 10000
root hard nofile 16384
/etc/sysctl.conf
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
# Controls IP packet forwarding
net.ipv4.ip_forward = 0
# Controls source route verification
net.ipv4.conf.default.rp_filter = 1
# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0
# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0
# Controls whether core dumps will append the PID to the core filename
# Useful for debugging multi-threaded applications
kernel.core_uses_pid = 1
# Controls the use of TCP syncookies
net.ipv4.tcp_syncookies = 1
# Controls the maximum size of a message, in bytes
kernel.msgmnb = 65536
# Controls the default maxmimum size of a mesage queue
kernel.msgmax = 65536
# Controls the maximum shared segment size, in bytes
kernel.shmmax = 4294967295
# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 268435456
fs.file-max = 80000
/etc/my.cnf
[mysqld]
skip-bdb
skip-locking
skip-external-locking
key_buffer_size = 45M
query_cache_size = 50M
sort_buffer_size = 32M
read_rnd_buffer_size = 32M
tmp_table_size = 80M
max_heap_table_size = 80M
table_cache = 300
thread_cache_size = 5
#default-storage-engine=myisam
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
thread_concurrency = 4
wait_timeout = 1200
## InnoDB
#innodb-buffer-pool-size = 58M
#innodb-log-file-size = 50M
#innodb-log-buffer-size = 8M
#innodb-file-per-table = 1
#innodb-open-files = 500
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0
[mysqld_safe]
log-error=/dev/null
expire_logs_days = 5
pid-file=/var/run/mysqld/mysqld.pid
/etc/php-fpm.conf
[global]
pid=/var/run/php-fpm/php-fpm.pid
error_log=/dev/null
log_level=alert
emergency_restart_threshold=10
emergency_restart_interval=1m
process_control_timeout=10s
daemonize=yes
include=/etc/php-fpm.d/*.conf
/etc/php-fpm.d/admin.conf
[admin]
listen = 127.0.0.1:51006
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
user = admin
group = admin
pm = dynamic
pm.max_children = 15
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 2
pm.max_requests = 1000
;pm.status_path = /status
;ping.path = /ping
;ping.response = pong
request_terminate_timeout = 60s
request_slowlog_timeout = 20s
slowlog = /dev/null
rlimit_files = 2048
rlimit_core = 0
;chroot =
;chdir = /var/www
catch_workers_output = yes
security.limit_extensions = .php .php3 .php4 .php5
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f webmaster@domain.com
;php_flag[display_errors] = off
php_admin_value[error_log] = /dev/null
php_admin_value[session.save_path] = /var/lib/php/session
php_admin_flag[log_errors] = off
php_admin_value[memory_limit] = 64M
/etc/nginx/nginx.conf
user nginx;
worker_processes 5;
worker_rlimit_nofile 4096;
pid /var/run/nginx.pid;
events {
worker_connections 2048;
use epoll;
}
http {
add_header Cache-Control public;
server_names_hash_max_size 1024;
server_names_hash_bucket_size 128;
client_body_buffer_size 128k;
client_max_body_size 32M;
include '/etc/nginx/conf.d/*.conf';
reset_timedout_connection off;
}
So here are they. if you need more configs to see, tellme.
Right now traffic are not too high, something about 800000 per month. so please tellme which config tweak will give me maximum.
by average it takes no more than 1.2 gb of ram and 20% processor state. page creation time is little slower too. So what should i change?
Anik.
-
i need apache config, i use worker
it not pass 5% cpu and the site is veri slow 1-2 visits per second
-
i have a light site, statis is delivered by nginx
i have 2x@3ghz 1gb (2gb burst) ram
i added on httpd.conf when i worked very bad
<IfModule worker.c>
StartServers 20
MaxClients 1500
MinSpareThreads 10
MaxSpareThreads 20
ThreadsPerChild 250
MaxRequestsPerChild 4000
ThreadStackSize 81960
MaxMemFree 200
SendBufferSize 655360
ReceiveBufferSize 655360
</IfModule>
my.cnf
[mysqld]
skip-innodb
skip-bdb
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
#log-bin
log-slow-queries=/var/lib/mysql/slow.log
log=/var/log/mysqlupdate.log
log-error=/var/log/mysqlupdate.log
max_connections = 2000
key_buffer = 512M
myisam_sort_buffer_size = 128M
join_buffer_size = 2M
read_buffer_size = 2M
sort_buffer_size = 4M
table_cache = 5000
thread_cache_size = 268
interactive_timeout = 25
wait_timeout = 7000
connect_timeout = 10
max_allowed_packet = 32M
max_connect_errors = 10
query_cache_limit = 4M
query_cache_size = 32M
query_cache_type = 1
tmp_table_size = 32M
-
<IfModule worker.c>
StartServers 20
MaxClients 1500
MinSpareThreads 10
MaxSpareThreads 20
ThreadsPerChild 250
MaxRequestsPerChild 4000
ThreadStackSize 81960
MaxMemFree 200
SendBufferSize 655360
ReceiveBufferSize 655360
</IfModule>
Above is waste if using nginx+apache+php-fpm/fcgid/suphp.
We don't need StartServers/MinSpareThreads/MaxSpareThreads with high value. Select 'default' on 'Apache optimize' instead optimize.
-
what about my config?
-
i change as you config, and same thing
only mysql is not as yours
i used default apache setting
same thing very bad lod time
-
i change as you config, and same thing
only mysql is not as yours
i used default apache setting
same thing very bad lod time
ex http://www.programe-tv.eu/static/sprites26.png (http://www.programe-tv.eu/static/sprites26.png) , is from apache the problem 10+ sec load time
read carefully what he said.
-
now works well
-
same problem, now is not loading worst, with default configuration, what can i do?
-
@Anik,
Better update for newest upload because modified some timeout setting for web and php.
@costa1988sv,
If you think your php process so slow, better optimize phpfpm config. Read viewtopic.php?f=15&t=245 (http://forum.mratwork.com/viewtopic.php?f=15&t=245) for customize rule.
Try,
1. minimize client amount. If possible only use 1 client (only use 'admin')
2. modified php53-fpm-pool.conf.tpl (when using php 5.3/5.4 dan php-fpm) where:
...
$maxchildren = '5';
...
to:
...
if ($user = 'admin') {
$maxchildren = '10';
} else {
$maxchildren = '5';
}
...
If you have less than 1024MB use don't change maxchildren value more than 25.
-
ok,i will update tomorrow but should i increase any of this value above?? if yes then which ones?
thanks mustafa.
-
where is the file located?
i think is apache related not php, because even images are loading bad
-
Read viewtopic.php?f=15&t=245 (http://forum.mratwork.com/viewtopic.php?f=15&t=245) for config location.
-
the number of apache processes are starting, i even had 30 visits per second it started 60-80
-
As I said before, use:
...
StartServers 20
MaxClients 1500
MinSpareThreads 10
MaxSpareThreads 20
...
is too much and useless (for using php-fpm). Better reduced with select 'default' for 'apache optimize' on 'webserver config'.
-
same thing, one and the other, the site is dead when has 20 visit per minute
-
switched to worker and all is good
-
switched to worker and all is good
I don't know what you mean 'worker'. Suphp/php-fpm/fcgid have 'worker' beside 'event'. If you using 'event' need '<IfModule event.c></IfModule>'
-
i made a mistake, i switched to php-fpm_event
-
just updated thewith the latest MR but everything messed up.. most of the times i can see 500 error. also page creation time is very slow,.. did the sh /script/cleanup but not worked. help.
-
now after reboot everything is offline. tried with switching the services but all failed.
the 'update horror' is coming back again.
-
now by default "Enable Php 5.2 (use Lxphp) As Secondary Php" this thing checked. i did not activated this..
-
just updated thewith the latest MR but everything messed up.. most of the times i can see 500 error. also page creation time is very slow,.. did the sh /script/cleanup but not worked. help.
me to, after update make me unstable, sometimes 500 error
and I try changing webserver to nginx, also lighttpd and back again to my choice (nginx-proxy)
it's work, ... stable again
don't ask me Why ;)
-
just updated thewith the latest MR but everything messed up.. most of the times i can see 500 error. also page creation time is very slow,.. did the sh /script/cleanup but not worked. help.
me to, after update make me unstable, sometimes 500 error
and I try changing webserver to nginx, also lighttpd and back again to my choice (nginx-proxy)
it's work, ... stable again
don't ask me Why ;)
yeah i know that trick, as i said before tried with switching the services but all failed. already did that about 10 times but now no response. before it was showing some of the pages, but now not a single one.... :(
-
now i can see nginx isnt starting..
-
now i can see nginx isnt starting..
Try simple 'sh /script/restart-services'. Maybe something with nginx or else.
-
permission denied..
/script/restart-services: line 7: /etc/init.d/named: No such file or directory
Stopping Djbdns:
Starting Djbdns:
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
/script/restart-services: line 7: /etc/init.d/nginx: Permission denied
/script/restart-services: line 7: /etc/init.d/lighttpd: No such file or directory
Stopping php-fpm: [ OK ]
Starting php-fpm: [ OK ]
Stopping Qmail:
Starting Qmail:
/script/restart-services: line 7: /etc/init.d/dovecot: No such file or directory
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
-
Delete '/etc/init.d/nginx' and then copy '/home/nginx/etc/init.d/nginx.init' to '/etc/init.d/nginx'.
-
ohh,, that file's permission was changed. so after chmoding that nginx started. but now getting 500 error all over again.
-
okay, 500 now solved after changing php type and fixing ownership. but the page creation time is very very slow..
about 20-25 sec. how to fix it?
-
what do you think : https://github.com/perusio (https://github.com/perusio)
I apply some config from this guy (private file - fastcgi for drupal)
/home/nginx/conf/globals/custom.proxy.conf
-
my problem is with php-fpm for site speed and stability. not nginx. it works mostly fine for me.
-
my problem is with php-fpm for site speed and stability. not nginx. it works mostly fine for me.
that is specific at php-fpm : https://github.com/perusio/php-fpm-exam ... e/unix/fpm (https://github.com/perusio/php-fpm-example-config/tree/unix/fpm)
only for the insight, all about number from this guy is useless
because : example pm is set to 'dynamic'
Cheers
i am just following to learn with you
-
ooww.. they are hugely commented. i am wondering what hardware config that guy has, because without knowing that it's useless to come up with something.
i actually do trial and error methods with configs. i will let you know more about them in this thread. stay tuned. :)
-
i changed the pm to 'static' and the 'pm.max_children = 40'. but the page creation time is slower. 1-3 sec. how to make it fast?
should i alter the '/etc/security/limits.conf' and'/etc/sysctl.conf' ?
-
I am at default config, and little up for "max children" and "pm.max_requests"
just upload some file config from "peruso" at related folder for more 'compitble'
I think some tweak not only about number
please: Mr. MR, give me the reason that php-fpm can handle high traffic for the case above. :?:
-
didn't you altered your system kernel limits?
-
i tested only the mysql config, the differences are 5x better that default
-
i tested only the mysql config, the differences are 5x better that default
which one you tested?