Web Hosting

Performance Tuning MySQL Server

Mysql provides a configuration file located in /etc/my.cnf. From here you can set all of the memory, table, and connection limits as well as a host of other options. Before we get started I suggest you get aquainted with the my.cnf file as well as the tuning parameters within it.

Here is the my.cnf I use:

[mysqld]
back_log = 75
skip-innodb
max_connections = 500
key_buffer = 384M
myisam_sort_buffer_size = 64M
join_buffer_size = 1M
read_buffer_size = 1M
sort_buffer_size = 2M
table_cache = 1800
thread_cache_size = 384
wait_timeout = 7200
connect_timeout = 10
tmp_table_size = 64M
max_heap_table_size = 64M
max_allowed_packet = 64M
max_connect_errors = 1000
read_rnd_buffer_size = 524288
bulk_insert_buffer_size = 8M
query_cache_limit = 4M
query_cache_size =128M
query_cache_type = 1
query_prealloc_size = 65536
query_alloc_block_size = 131072
default-storage-engine = MyISAM

[mysqld_safe]
nice = -5
open_files_limit = 8192

[mysqldump]
quick
max_allowed_packet = 16M

[myisamchk]
key_buffer = 64M
sort_buffer = 64M
read_buffer = 16M
write_buffer = 16M

Let’s just look at the important bits.

max_connections = 500 – I use a tool (see below) to check how many current connections I have, and under very heavy load (2000 simultaneous users) I rarely hit 400 concurrent connections to the database. This is because most connections only last for a few milliseconds.

key_buffer = 384M - When tuning a MySQL server, key_buffer_size is very important. This number works well for me and with the mysqlreport script I rarely use 50% of the available memory.

DirectAdmin Tip: Moving a domain from 1 user to another

There is no official domain transfer tool between users at this time, so here's how you have to do it:

1) Go to Reseller Panel -> Manage User Backups and make a backup of the user who owns the domain you want to transfer.

2) Login as that user, go to User Panel -> Domain Administration -> Change domain name, and change the name of that domain to something different (ie: from domain.com to domain2.com). This is done so that you can restore the domain on the other account without DA complaining that it already exists.

3) Go back into the Reseller Panel, and create the a new user. Set the domain to the actual name of the domain you want transferred. If the user already exists, then just create the domain through the User Panel -> Domain Administration menu.

4) Take the backup from step 1, and rename is from olduser.tar.gz to newuser.tar.gz, where newuser is the name you are transferring TO and olduser is the name you are transferring FROM.

5) From Reseller Panel -> Manage User Backups, select newuser.tar.gz and restore it into the newuser account. This should set all the data from the domain into the new user.

6) Once you've verified that everything is correct and as it should be, log back into the olduser account and delete domain2.com.
Syndicate content