Arkshine
Active member
Hi,
Recently I've noticed my forum starting to slow-down and it would be seem server eats too much memory that it uses almost all the available swap most of time.
I guess it's time to configure properly all the softwares since I got more hits than at the start.
Just as note, I don't know much and the current configuration is from different tutorials here and there, but I am willing to do any manipulations. I want to have a fast forum !
Here the relevant informations :
General
You will agree with a VPS/512MB and one forum, it should be fine fairly up to medium community. So, it's a real problem it uses alread all the swap with only few connections.
As note, I'm willing to hire someone to configure/optimize this configuration. So, for people who know well this stuff, it would be some easy money, if interested send me a PC.
Anyway, many thanks in advance for people who will advive/suggest/help me.
Recently I've noticed my forum starting to slow-down and it would be seem server eats too much memory that it uses almost all the available swap most of time.
I guess it's time to configure properly all the softwares since I got more hits than at the start.
Just as note, I don't know much and the current configuration is from different tutorials here and there, but I am willing to do any manipulations. I want to have a fast forum !
Here the relevant informations :
General
- VPS with 512MB RAM + 362 MB for swap
- Contains only one XenForo forum and don't plan to add more
- Small community, don't have much visits for now since forum is fairly new
- OS : Debian 6 32 bits (2.6.32-xenU-7428-i386)
- PHP-FPM 5.3.23-1~dotdeb.0
- MariaDB 5.5.30
- varnish 3.0.3 as frontend
- nginx 1.2.7 as backend
- memcached 1.4.15 (with Libmemcached 1.0.10)
- APC 3.1.13
- About PHP-FPM
php-fpm.conf
Code:pid = /var/run/php5-fpm.pid error_log = /var/log/php5-fpm.log log_level = notice emergency_restart_threshold = 10 emergency_restart_interval = 1m process_control_timeout = 5s
pool.d/www.conf
Code:user = www-data group = www-data listen = /var/run/php5-fpm.sock listen.owner = www-data listen.group = www-data listen.mode = 0666 pm = dynamic pm.max_children = 10 pm.start_servers = 1 pm.min_spare_servers = 1 pm.max_spare_servers = 3 pm.process_idle_timeout = 10s; pm.max_requests = 1000 slowlog = /var/log/php5-fpm/$pool.log.slow request_slowlog_timeout = 5s request_terminate_timeout = 120s
- About MariaDB
Probably this one eating too much memory.
my.cnf
Code:[client] port= 3306 socket= /var/run/mysqld/mysqld.sock [mysqld_safe] socket= /var/run/mysqld/mysqld.sock nice= 0 # # * Basic Settings # user= mysql pid-file= /var/run/mysqld/mysqld.pid socket= /var/run/mysqld/mysqld.sock port= 3306 basedir= /usr datadir= /srv/d_cs-amx/mysql tmpdir= /tmp lc_messages_dir= /usr/share/mysql lc_messages= en_US skip-external-locking # # * Fine Tuning # max_connections= 20 connect_timeout= 5 wait_timeout= 28800 max_allowed_packet= 32M thread_cache_size = 50 sort_buffer_size= 4M bulk_insert_buffer_size= 16M tmp_table_size= 32M max_heap_table_size= 32M join_buffer_size= 256K # # * MyISAM # # This replaces the startup script and checks MyISAM tables if needed # the first time they are touched. On error, make copy and try a repair. myisam_recover = BACKUP key_buffer_size= 128M open-files-limit= 5000 table_open_cache= 2000 myisam_sort_buffer_size= 128M concurrent_insert= 2 read_buffer_size= 2M read_rnd_buffer_size= 1M # # * Query Cache Configuration # query_cache_type= OFF # # * Logging and Replication # log_warnings= 2 slow_query_log= 1 slow_query_log_file= /srv/d_cs-amx/mysql/log/mariadb-slow.log long_query_time= 5 log_slow_verbosity= query_plan log_bin= /srv/d_cs-amx/mysql/log/mariadb-bin log_bin_index= /srv/d_cs-amx/mysql/log/mariadb-bin.index sync_binlog= 1 expire_logs_days= 3 max_binlog_size = 100M # # * InnoDB # default_storage_engine= InnoDB innodb_buffer_pool_size= 128M innodb_log_buffer_size= 8M innodb_file_per_table= 1 innodb_open_files= 1024 innodb_io_capacity= 1024 innodb_flush_method= O_DIRECT innodb_thread_concurrency= 0 innodb_stats_on_metadata= off innodb_old_blocks_time= 1000 [mysqldump] quick quote-names max_allowed_packet= 16M [mysql] #no-auto-rehash# faster start of mysql but no tab completition [isamchk] key_buffer= 16M
- About Varnish
default.vcl
http://pastebin.com/uZNceAnj (takes too much caracters )
etc/default/varnish
Code:# Should we start varnishd at boot? Set to "no" to disable. START=yes # Maximum number of open files (for ulimit -n) NFILES=131072 # Maximum locked memory size (for ulimit -l) # Used for locking the shared memory log in memory. If you increase log size, # you need to increase this number as well MEMLOCK=82000 ## Alternative 2, Configuration with VCL # # Listen on port 6081, administration on localhost:6082, and forward to # one content server selected by the vcl file, based on the request. Use a 1GB # fixed-size cache file. # DAEMON_OPTS="-a :80 \ -T localhost:6082 \ -f /etc/varnish/default.vcl \ -S /etc/varnish/secret \ -s malloc,256m"
- About nginx
nginx.conf
Code:userwww-data www-data; # As a thumb rule: One per CPU. If you are serving a large amount # of static files, which requires blocking disk reads, you may want # to increase this from the number of cpu_cores available on your # system. # # The maximum number of connections for Nginx is calculated by: # max_clients = worker_processes * worker_connections worker_processes2; # Change these paths to somewhere that suits you! error_log /var/log/nginx/error.log; pid/var/run/nginx.pid; # Maximum file descriptors that can be opened per process # This should be > worker_connections worker_rlimit_nofile9000; events { # When you need > 8000 * cpu_cores connections, you start optimizing # your OS, and this is probably the point at where you hire people # who are smarter than you, this is *a lot* of requests. worker_connections8000; } http { includemime.types; default_typeapplication/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] $request ' '"$status" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" "$gzip_ratio"'; set_real_ip_from127.0.0.1; real_ip_headerX-Forwarded-For; sendfileon; tcp_nopushoff; tcp_nodelayon; keepalive_timeout5; types_hash_max_size2048; server_tokensoff; #keepalive_requests0; # Click tracking! #access_log/var/log/nginx/access.log main; gzipoff; gzip_staticon; gzip_varyon; gzip_disable"MSIE [1-6]\.(?!.*SV1)"; gzip_min_length1100; gzip_buffers32 8k; gzip_http_version1.1; gzip_comp_level9; gzip_proxiedany; gzip_typestext/plain text/css text/javascript text/xml text/x-component application/x-javascript application/xml application/xml+rss application/octet-stream application/vnd.ms-fontobject application/x-font-opentype application/x-font-woff image/png image/gif image/jpeg image/svg+xml image/x-icon; client_body_buffer_size 10m; client_max_body_size16m; client_body_temp_path /var/spool/nginx/client_temp 1 2; port_in_redirect off; include /etc/nginx/sites-enabled/*; }
site-available/default
http://pastebin.com/u0cd58LS (takes too much caracters )
- About memcached
With session/igbinary/json support enabled.
Used with XF :
/library/config.php
Code:$config['cache']['enabled'] = true; $config['cache']['cacheSessions'] = true; $config['cache']['frontend'] = 'Core'; $config['cache']['frontendOptions'] = array( 'caching'=> true, 'cache_id_prefix'=> 'xf_', 'automatic_serialization'=> true, 'lifetime'=> 0 ); $config['cache']['backend'] = 'Libmemcached'; $config['cache']['backendOptions'] = array( 'servers' => array( array( 'host'=> '127.0.0.1', 'port'=> 11211, 'weight'=> 1 ) ) );
etc/default/memcached
Code:DAEMON_OPTS="-u nobody \ -m 16"
etc/php5/conf.d/memcached.ini
Code:extension = memcached.so session.save_handler = "memcached" session.save_path = "127.0.0.1:11211" [memcached] memcached.sess_locking = On memcached.sess_lock_wait = 150000 memcached.sess_prefix = "memc.sess.key." memcached.sess_binary = Off memcached.compression_type = "fastlz" memcached.compression_factor = "1.3" memcached.compression_threshold = 2000 memcached.serializer = "igbinary" memcache.hash_strategy = "consistent"
- About APC
etc/php5/conf.d/apc.ini
Code:extension=apc.so apc.cache_by_default= 1 apc.canonicalize= 1 apc.coredump_unmap= 0 apc.enable_cli= 0 apc.enabled= 1 apc.file_md5= 0 apc.file_update_protection= 0 apc.gc_ttl= 1200 apc.include_once_override= 0 apc.lazy_classes= 0 apc.lazy_functions= 0 apc.max_file_size= 10M apc.mmap_file_mask= /tmp/apc-mmap.XXXXXX apc.num_files_hint= 1000 apc.report_autofilter= 0 apc.rfc1867= 1 apc.rfc1867_freq= 512k apc.rfc1867_name= APC_UPLOAD_PROGRESS apc.rfc1867_prefix= upload_ apc.rfc1867_ttl= 1200 apc.serializer= igbinary apc.shm_segments= 1 apc.shm_size= 64M apc.shm_strings_buffer= 4M apc.slam_defense= 0 apc.stat= 1 apc.stat_ctime= 1 apc.ttl= 0 apc.use_request_time= 1 apc.user_entries_hint= 4096 apc.user_ttl= 0 apc.write_lock= 1
You will agree with a VPS/512MB and one forum, it should be fine fairly up to medium community. So, it's a real problem it uses alread all the swap with only few connections.
As note, I'm willing to hire someone to configure/optimize this configuration. So, for people who know well this stuff, it would be some easy money, if interested send me a PC.
Anyway, many thanks in advance for people who will advive/suggest/help me.