Version 8 (modified by AlexT, 14 years ago) (diff) |
---|
Hosting Server Setup Recommendations
It was noticed that many server's default setup is very inefficient. It lead to poor script performance and in some hosting can terminate your account due to heavy load. This document covers very basic recommendations on how to improve your site performance by slightly changing your server configuration.
This recommendations are for dedicated or VPS server owners, however if you are on shared hosting and notice that your server configuration is inefficient you can ask your hosting support do change this settings on the server, so whole server will run faster.
You need root access to the server and have some skills on how to connect to the server using SSH terminal and know some basic command line tools, like navigating through directories and editing files.
Remember, making wrong changes can bring your server down '''
Before Start
Always backup old data, so you can always return to original configuration.
Before starting optimization It is better to monitor your server performance before starting optimization and after to see how things are changing, if it becomes better or worth. I suggest to install "Munin" server monitor, it is available as WHM plugin, you can install it from WHM panel -> cPanel -> Manage Plugins -> click "Install and Keep Updated" near Munin logo and press "Save" button at the bottom of the page. After installing link to Munin appears in "Plugins" section of WHM panel, please allow up to 10 minutes until it generates pages with graphs for you.
MySQL
First you need to check if query_cache is enabled on your server. It was noticed that 80% of all SELECT queries are taken from query_cache when it is enabled, so if it is disabled on your server - mysql performance is 5 times slower !
To check this go to phpMysqlAdmin tool (in most cases it is in your whm panel -> SQL Services -> phpMyAdmin). Then click "Variables" tab. "query cache size" must be at lesat 16M, "query cache type" must be ON and "query cache limit" value should be around 1M. Example of good configuration:
After you realized that you need to change these settings you need to edit "my.cnf" file on your server (in most cases it in in "/etc" folder) and add the foollowing lines in "[mysqld]" section of the file, if the same configuration options already exists it is better to comment out old ones (with hash # symbol ) and add new ones near them:
[mysqld] query_cache_limit = 1M query_cache_size = 32M
You need to restart mysql server to apply the changes, you can do it from whm panel or from command line, most common command line for linux servers is:
/etc/init.s/mysql restart
This most critical configuration options. Other useful options must be enabled too - "key buffer size", "max heap table size", "tmp table size", "thread_cache" are some of them. But exact values varies from server from server, for example for dedicated or VPS server with 1Gb RAM and one dolphin site, these values maybe like this:
[mysqld] query_cache_limit = 1M query_cache_size = 32M key_buffer_size = 64M max_heap_table_size = 256M tmp_table_size = 256M thread_cache = 128
There is already a tool in phpMyAdmin which can help you with deciding what configuration values need to be changed. Go to phpMyAdmin and open "Status" tab, look through this page and pay attention to red values. There is a comment near each value you can use as a guide in changing particular MySQL option. During changing remember that memory is always limited, so you need to increase the values adequately your available RAM. Keep in mind that this is values are collected during some time, so if you change some value it is better to wait at least 1 day until new data is collected for analysis. After MySQL restarted this data is collected from the scratch.
This is an example on many queries becomes cached after introducing "query cache":
1 day is showed on the graph, in the beginning cache was disabled then cache was enabled - pink zpne shows SELECT queries which are taken from cache. So, benefits are obvious !
PHP
Attachments (12)
- hssr-mysql-1-query-cache.jpg (18.0 KB) - added by AlexT 14 years ago.
- hssr-mysql-2-queries-day.png (38.1 KB) - added by AlexT 14 years ago.
- hssr-php-1-dso.jpg (6.1 KB) - added by AlexT 14 years ago.
- hssr-php-2-cgi.jpg (5.4 KB) - added by AlexT 14 years ago.
- hssr-benchmark.jpg (62.0 KB) - added by AlexT 14 years ago.
- wso-0-preparation.jpg (84.7 KB) - added by AlexT 14 years ago.
- wso-1-compression-phpinfo.jpg (82.9 KB) - added by AlexT 14 years ago.
- wso-1-compression-result-score.jpg (118.4 KB) - added by AlexT 14 years ago.
- wso-1-compression.jpg (85.5 KB) - added by AlexT 14 years ago.
- wso-2-user-side-cache-graph.jpg (47.9 KB) - added by AlexT 14 years ago.
- wso-2-user-side-cache-page-speed-after.jpg (89.9 KB) - added by AlexT 14 years ago.
- wso-2-user-side-cache-page-speed-before.jpg (401.9 KB) - added by AlexT 14 years ago.
Download all attachments as: .zip