MyBB Community Forums

Full Version: my.cnf
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi folks,
Hope all are doing fine.
My forum crashes and not stable!
Running Top Command results = mysql is taking over % of the CPU !!
As an average its taking 175% of the CPU's.
My current plan is VPS Server with these options:
8 CPU's @ 1.8 each.
756 RAM.

I tried to modify my,cnf in etc. My modifications didnt give good results Sad

I attached my original cnf file.
Please I want who has excellent experiences to help me in modifying this file to met my Server Plan and to REDUCE mysql load.

Thanks in advance.
Please see this thread. It's very detailed, and explains how to optimize my.cnf to work with your current system.
(2012-04-14, 07:40 PM)Nathan Malcolm Wrote: [ -> ]Please see this thread. It's very detailed, and explains how to optimize my.cnf to work with your current system.

Thanks for reply Rolleyes

Please check back the link u guided me to.
I got this message:
Forbidden

You don't have permission to access /showthread.php on this server.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

Best regards.
^ you must login. However that is my guide so I'll just login and paste it here.
You have 756mb of ram so this is perfect for you.
--------------------

Welcome! In this thread I'll be teaching you how to optimize MySQL for maximum website performance.
This tutorial is for servers with 512mb - 1GB of RAM.
Before we start, lets check the following,
I have a VPS, dedicated server, or access to the my.cnf file. Y/N?
If yes, lets continue.

Right, lets start by explaining the variables.

thread_cache_size
This variable determines how many threads MySQL will keep open in memory to handle new connections. A value of zero is not recommended, this means MySQL will always create new threads.

table_cache
When MySQL accesses a table, it places it in the cache so data can be retrieved faster.
You may need to increase the value if opened_tables number is high. You can find this number by typing this from SSH,

SHOW STATUS LIKE "open%tables%";

max_connections
Self explanatory. This defines the maximum number of connections allowed to MySQL. You may need to increase this, but not so high that MySQL can max out RAM usage.

join_buffer_size
A join buffer is allocated for each full join between tables. You should increase this value for a fast full join when adding indexes isn't an option.

sort_buffer_size
Each thread that needs to do a sort allocates a buffer of this size. Increase this value for faster ORDER BY or GROUP BY operations.

interactive_timeout
This value will determine the amount of seconds during inactivity that MySQL will wait before closing an interactive connection such as mysql shell.

wait_timeout
Same definition as above, but for non-interactive sessions. This value shouldn't be too low otherwise it will drop connections unexpectedly. Nor should it be too high otherwise bad connections will remain open, preventing new connections to the database.

connect_timeout
The amount of seconds MySQL will wait before dropping a connection. A good value it between 10 and 60.

max_allowed_packet
This value will determine the maximum packet size allowed to be received. If this is too low, you might see errors. A good value is 20M.

max_connect_errors
The value determines how many interrupted connections can occur. Surpassing this value will result in the host being blocked from further connections. You can unblock hosts by using the FLUSH_TABLES statement.

key_buffer_size
This is the most useful variable to tweak. Getting a perfect value is important. The larger this value is, the more of your MyISAM table indexes will be stored in memory. This value should be at least a quarter, but no more than a half of your maximum available memory. For example, a server with 1GB of ram should have a key buffer size of around 300MB.

query_cache_size
If your database runs the same queries repeatedly, this variable is very useful. MySQL will cache the result set, avoiding the overhead of through data over and over again.

query_cache_limit
This is the maximum query size that will be cached.

tmp_table_size
This is the number of implicit temporary tables on disk created while executing statements. This is memory based.
tmp_table_size is useless without the max_heap_table_size, which is explained next.


max_heap_table_size
Your application may use HEAP tables, HEAP tables are stored in memory and if stale sessions aren't cleaned, you may begin to see errors. It is recommended that this value is the same as tmp_table_size.

----------------------------
That's the variables briefly explained to the best of my knowledge, some may not be 100% accurate though.

Now, here is the my.cnf I configured myself for my server.

thread_cache_size= 20
table_cache= 3000
max_connections= 200
myisam_sort_buffer_size= 16M
join_buffer_size = 1M
read_buffer_size = 1M
sort_buffer_size = 4M
interactive_timeout = 25
wait_timeout = 300
connect_timeout = 10
max_allowed_packet = 20M
max_connect_errors = 10
key_buffer_size = 450M
query_cache_type = 1
query_cache_size = 40M
query_cache_limit = 5M
tmp_table_size = 6M
max_heap_table_size = 8M

This should be a good base for you to begin optimizing from.
I recommend installing MySQL Tuner. Here's how,
1: From SSH, type,
wget mysqltuner.pl

2: Then type,
 chmod 775 mysqltuner.pl

3: You can now run the script by typing,
./mysqltuner.pl
OR
perl mysqltuner.pl

It will take a few seconds, and will give you alerts and suggestions about your MySQL configuration. If you need help with this, post your results here and I'll assist.

Any questions, just ask.
I'll continue to add to this with more optimizations, there is lots more to do, this is just the beginning.
This has been tested on MySQL 5.1 and MySQL 5.5, whilst running a MyBB Forum, a Wordpress blog and an image host.
Written exclusively for SupportForums.net
Thanks for reading.