Sponsor:

Server and Web Integrator
Link:
Kloxo-MR logo
6.5.0 or 7.0.0
Click for "How to install"
Donation/Sponsorship:
Kloxo-MR is open-source.
Donate and or Sponsorship always welcome.
Click to:
Click Here
Please login or register. 2024-04-19, 22:35:34

Author Topic: Tweaks with config.  (Read 23242 times)

0 Members and 1 Guest are viewing this topic.

Offline Anik

  • Senior Member
  • *
  • Posts: 189
  • Karma: +0/-0
    • View Profile
    • http://www.feirox.com
Tweaks with config.
« 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

Code: [Select]
# /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

Code: [Select]
# 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

Code: [Select]
[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

Code: [Select]
[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

Code: [Select]
[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

Code: [Select]
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.
« Last Edit: 1970-01-01, 01:00:00 by Guest »
Having Kloxo-MR useful? Then support the development. Consider buying a server from the author. http://hostspectra.com

Offline costa1988sv

  • Junior Member
  • *
  • Posts: 40
  • Karma: +0/-0
    • View Profile
Re: Tweaks with config.
« Reply #1 on: 2013-02-21, 01:51:05 »
i need apache config, i use worker
it not pass 5% cpu and the site is veri slow 1-2 visits per second
« Last Edit: 1970-01-01, 01:00:00 by Guest »

Offline costa1988sv

  • Junior Member
  • *
  • Posts: 40
  • Karma: +0/-0
    • View Profile
Re: Tweaks with config.
« Reply #2 on: 2013-02-21, 02:00:20 »
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

Code: [Select]
<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

« Last Edit: 1970-01-01, 01:00:00 by Guest »

Offline MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,807
  • Karma: +119/-11
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: Tweaks with config.
« Reply #3 on: 2013-02-21, 02:09:03 »
Code: [Select]
<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.
« Last Edit: 1970-01-01, 01:00:00 by Guest »
..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

Offline Anik

  • Senior Member
  • *
  • Posts: 189
  • Karma: +0/-0
    • View Profile
    • http://www.feirox.com
Re: Tweaks with config.
« Reply #4 on: 2013-02-21, 02:19:23 »
what about my config?
« Last Edit: 1970-01-01, 01:00:00 by Guest »
Having Kloxo-MR useful? Then support the development. Consider buying a server from the author. http://hostspectra.com

Offline costa1988sv

  • Junior Member
  • *
  • Posts: 40
  • Karma: +0/-0
    • View Profile
Re: Tweaks with config.
« Reply #5 on: 2013-02-21, 02:23:42 »
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

« Last Edit: 2014-11-03, 03:17:01 by costa1988sv »

Offline Anik

  • Senior Member
  • *
  • Posts: 189
  • Karma: +0/-0
    • View Profile
    • http://www.feirox.com
Re: Tweaks with config.
« Reply #6 on: 2013-02-21, 02:28:54 »
Quote from: "costa1988sv"
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 , is from apache the problem 10+ sec load time

read carefully what he said.
« Last Edit: 1970-01-01, 01:00:00 by Guest »
Having Kloxo-MR useful? Then support the development. Consider buying a server from the author. http://hostspectra.com

Offline costa1988sv

  • Junior Member
  • *
  • Posts: 40
  • Karma: +0/-0
    • View Profile
Re: Tweaks with config.
« Reply #7 on: 2013-02-21, 02:33:18 »
now works well
« Last Edit: 1970-01-01, 01:00:00 by Guest »

Offline costa1988sv

  • Junior Member
  • *
  • Posts: 40
  • Karma: +0/-0
    • View Profile
Re: Tweaks with config.
« Reply #8 on: 2013-02-21, 23:29:24 »
same problem, now is not loading worst, with default configuration, what can i do?
« Last Edit: 1970-01-01, 01:00:00 by Guest »

Offline MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,807
  • Karma: +119/-11
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: Tweaks with config.
« Reply #9 on: 2013-02-22, 00:31:18 »
@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 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:
Code: [Select]
...
    $maxchildren = '5';
...

to:
Code: [Select]
...
    if ($user = 'admin') {
        $maxchildren = '10';
    } else {
        $maxchildren = '5';
    }
...

If you have less than 1024MB use don't change maxchildren value more than 25.
« Last Edit: 1970-01-01, 01:00:00 by Guest »
..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

Offline Anik

  • Senior Member
  • *
  • Posts: 189
  • Karma: +0/-0
    • View Profile
    • http://www.feirox.com
Re: Tweaks with config.
« Reply #10 on: 2013-02-22, 00:40:59 »
ok,i will update tomorrow but should i increase any of this value above?? if yes then which ones?

thanks mustafa.
« Last Edit: 1970-01-01, 01:00:00 by Guest »
Having Kloxo-MR useful? Then support the development. Consider buying a server from the author. http://hostspectra.com

Offline costa1988sv

  • Junior Member
  • *
  • Posts: 40
  • Karma: +0/-0
    • View Profile
Re: Tweaks with config.
« Reply #11 on: 2013-02-22, 00:58:52 »
where is the file located?

i think is apache related not php, because even images are loading bad
« Last Edit: 1970-01-01, 01:00:00 by Guest »

Offline MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,807
  • Karma: +119/-11
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: Tweaks with config.
« Reply #12 on: 2013-02-22, 01:12:57 »
Read viewtopic.php?f=15&t=245 for config location.
« Last Edit: 1970-01-01, 01:00:00 by Guest »
..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

Offline costa1988sv

  • Junior Member
  • *
  • Posts: 40
  • Karma: +0/-0
    • View Profile
Re: Tweaks with config.
« Reply #13 on: 2013-02-22, 01:34:37 »
the number of apache processes are starting, i even had 30 visits per second it started 60-80
« Last Edit: 1970-01-01, 01:00:00 by Guest »

Offline MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,807
  • Karma: +119/-11
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: Tweaks with config.
« Reply #14 on: 2013-02-22, 02:24:28 »
As I said before, use:
Code: [Select]
...
    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'.
« Last Edit: 1970-01-01, 01:00:00 by Guest »
..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

 


Top 4 Global Search Engines:    Google    Bing    Baidu    Yahoo
Click Here

Page created in 0.049 seconds with 18 queries.

web stats analysis