Здравствуйте, господа. Решил вот приспособить следующее железо в качестве домашнего веб-сервачка на основе связки NGINX, PHP-FPM, MariaDB, MEMCACHE и Zend OPcache. В качестве ОС выбран Debian Wheezy 64-bit.
CPU: Intel Atom N2800, 1.86GHz (2 ядра + Hyper-Threading)
RAM: 4Gb, DDR3-1066
HDD: 1x640Gb, SATAII, 5400RPM (без каких-либо RAID'ов!)
Понимаю, железо совсем хилое для тяжёлых нагрузок, но что есть - то есть.
После долгих мытарств, противоречивых изысканий и гуглежа, сформировал следующие конфиги:
/etc/php5/fpm/php.ini (лишние строки исключил, дабы сократить список)
[PHP]
engine = On
short_open_tag = Off
asp_tags = Off
precision = 14
output_buffering = Off
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = 17
disable_functions = apache_child_terminate,apache_note,apache_setenv,debugger_off,debugger_on,define_syslog_variables,dl,escapeshellarg,escapeshellcmd,exec,ini_restore,leak,max_execution_time,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pclose,php_uname,popen,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,posix_getpwuid,posix_kill,posix_mkfifo,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_uname,shell_exec,symlink,syslog,system
disable_classes =
ignore_user_abort = Off
zend.enable_gc = On
expose_php = Off
max_execution_time = 30
max_input_time = 60
memory_limit = 128M
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
html_errors = On
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 8M
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
default_charset = "UTF-8"
doc_root =
user_dir =
enable_dl = On
fastcgi.logging = 0
file_uploads = On
upload_max_filesize = 2M
max_file_uploads = 20
allow_url_fopen = Off
allow_url_include = Off
default_socket_timeout = 60
[Pdo_mysql]
pdo_mysql.cache_size = 2000
pdo_mysql.default_socket =
[mail function]
SMTP = localhost
smtp_port = 25
mail.add_x_header = On
[SQL]
sql.safe_mode = On
[MySQL]
mysql.allow_local_infile = On
mysql.allow_persistent = On
mysql.cache_size = 4000
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off
[MySQLi]
mysqli.max_persistent = -1
mysqli.allow_local_infile = On
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.cache_size = 4000
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = On
[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
[Session]
session.save_handler = files
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 1
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.bug_compat_42 = On
session.bug_compat_warn = On
session.referer_check =
session.entropy_file = /dev/urandom
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 1
session.hash_bits_per_character = 6
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
/etc/php5/fpm/php-fpm.conf
[global]
pid = /var/run/php5-fpm.pid
error_log = /var/log/php5-fpm/error.log
log_level = notice
events.mechanism = epoll
include=/etc/php5/fpm/pool.d/*.conf
/etc/php5/fpm/pool.d/example.com
[example.com]
user = example.com
group = example.com
listen = /var/run/php5-fpm_example.com.sock
listen.backlog = 4096
listen.owner = www-data
listen.group = www-data
listen.mode = 0666
listen.allowed_clients = 127.0.0.1
pm = static
pm.max_children = 4
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 4
pm.status_path = /php_status
ping.path = /php_ping
ping.response = pong
access.log = /var/log/php5-fpm/$pool.access.log
access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
slowlog = /var/log/php5-fpm/$pool.slow.log
request_slowlog_timeout = 7s
request_terminate_timeout = 90s
chdir = /home/example.com/www
catch_workers_output = yes
security.limit_extensions = .php
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
php_flag[display_errors] = Off
php_admin_flag[log_errors] = On
php_admin_value[error_reporting] = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
php_admin_value[error_log] = /var/log/php5-fpm/error.log
php_admin_value[date.timezone] = Europe/Moscow
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f dyvniy@yandex.ru
;php_admin_value[open_basedir] = "/home/example.com/"
php_admin_value[cgi.fix_pathinfo] = 1
php_admin_value[expose_php] = Off
php_admin_value[allow_url_fopen] = On
php_admin_value[disable_functions] = exec,passthru,shell_exec,system,proc_open,popen,curl_multi_exec,parse_ini_file,show_source
php_admin_value[sql.safe_mode] = Off
php_admin_value[max_execution_time] = 60
php_admin_value[max_input_time] = 60
php_admin_value[memory_limit] = 128M
php_admin_value[realpath_cache_size] = 4096K
php_admin_value[realpath_cache_ttl] = 300
php_admin_value[upload_max_filesize] = 10M
php_admin_value[post_max_size] = 10M
php_admin_value[default_charset] = utf-8
php_admin_value[mbstring.internal_encoding] = utf-8
php_admin_value[session.save_handler] = memcache
php_admin_value[session.save_path] = "tcp://localhost:11211"
php_admin_value[upload_tmp_dir] = /home/example.com/tmp
php_admin_value[soap.wsdl_cache_dir] = /home/example.com/tmp
/etc/mysql/my.cnf
[client]
port = 3306
host = localhost
socket = /var/run/mysqld/mysqld.sock
character-sets-dir = /usr/share/mysql/charsets
[mysql]
no-auto-rehash
no-beep
safe-updates
character-sets-dir = /usr/share/mysql/charsets
[mysqld]
server-id = 1
user = mysql
pid_file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
bind-address = 127.0.0.1
basedir = /usr
datadir = /var/lib/mysql
#tmpdir = /run/shm
tmpdir = /dev/shm
max_connections = 100
max_user_connections = 50
max_connect_errors = 10
back_log = 50
max_allowed_packet = 16M
max_sort_length = 512
#skip-character-set-client-handshake
character-set-server = utf8
character-sets-dir = /usr/share/mysql/charsets
collation-server = utf8_general_ci
init-connect = "SET NAMES utf8"
init-connect = "SET CHARACTER SET utf8"
init-connect = "SET CHARSET utf8"
default-storage-engine = InnoDB
sql-mode = ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_IN_DATE
transaction-isolation = READ-COMMITTED
flush_time = 0
ft_min_word_len = 4
local-infile = 1
loose-local-infile = 1
open_files_limit = 4110
sysdate_is_now = 1
low-priority-updates
#memlock
skip-name-resolve
skip-external-locking
skip-networking
skip-archive
skip-blackhole
skip-federated
skip-partition
feedback = Off
concurrent_insert = ALWAYS
myisam-recover-options = backup,force
myisam_max_sort_file_size = 256M
myisam_data_pointer_size = 6
myisam_sort_buffer_size = 64M
myisam_repair_threads = 1
myisam_use_mmap = ON
#myisam_mmap_size = <VALUE>
#myisam_stats_method = <enumeration>
innodb_fast_shutdown
innodb = FORCE
innodb_buffer_pool_size = 1G
innodb_log_buffer_size = 8M
innodb_file_per_table = 1
#innodb_force_recovery = 1
innodb_lock_wait_timeout = 30
innodb_buffer_pool_instances = 8
innodb_checksum_algorithm = 0
innodb_concurrency_tickets = 5000
innodb_data_file_path = ibdata1:10M:autoextend
innodb_data_home_dir = /var/lib/mysql
innodb_max_dirty_pages_pct = 90
innodb_old_blocks_time = 1000
innodb_stats_on_metadata = 0
innodb_flush_log_at_trx_commit = 0
innodb_log_file_size = 128M
innodb_log_files_in_group = 2
innodb_log_group_home_dir = /var/lib/mysql
innodb_flush_method = O_DIRECT
innodb_strict_mode = 1
innodb_open_files = 400
innodb_io_capacity = 400
innodb_file_format = Barracuda
innodb_autoinc_lock_mode = 2
innodb_doublewrite = 1
innodb_rollback_on_timeout = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_buffer_pool_dump_now = 1
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_load_now = 1
innodb_thread_concurrency = 4
innodb_read_io_threads = 4
innodb_write_io_threads = 4
innodb_file_io_threads = 4
skip-innodb_adaptive_hash_index
#skip-innodb_doublewrite
bulk_insert_buffer_size = 2M
join_buffer_size = 3M
key_buffer_size = 32M
read_buffer_size = 2M
read_rnd_buffer_size = 4M
sort_buffer_size = 2M
table_open_cache = 4096
table_definition_cache = 4096
max_heap_table_size = 32M
tmp_table_size = 32M
max_tmp_tables = 25
query_cache_type = 1
query_cache_size = 32M
query_cache_limit = 2M
query_cache_min_res_unit = 4096
query_cache_wlock_invalidate = ON
thread_cache_size = 100
thread_concurrency = 4
thread_stack = 512K
thread_handling = one-thread-per-connection
connect_timeout = 5
interactive_timeout = 30
wait_timeout = 60
general_log = 1
general_log_file = /var/log/mysql/general.log
log-error = /var/log/mysql/error.log
log_warnings = 2
#log-bin = /var/log/mysql/mysql-bin.log
#binlog-format = mixed
expire_logs_days = 2
max_binlog_size = 100M
max-binlog-cache-size = 1M
#binlog_row_event_max_size = 8K
#sync_binlog = 1
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
slow-query-log = 1
slow-query-log-file = /var/log/mysql/slow.log
long_query_time = 1
#log_slow_rate_limit = 1000
log_slow_verbosity = query_plan
#log-queries-not-using-indexes
#log-slow-admin-statements
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
syslog
open-files-limit = 2048
[myisamchk]
key_buffer_size = 50M
sort_buffer_size = 50M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
Если не сложно, покритикуйте представленные конфиги (конфиг NGINX не предоставлял, так как он особо систему не грузит). Возможно где-то напортачил, из-за чего идёт сильная нагрузка на CPU и на HDD. Быть может возможно с помощью конфигов ещё немного быстродействия выжать?
P.S. И да, использую InnoDB. В оптимизации SQL-запросов пока что чайник. Полагаю, что должен быть ещё потенциал в конфигах.
С уважением, Геннадий.