Previous Thread
Next Thread
Print Thread
Rate Thread
#213176 01/31/2002 9:27 PM
Joined: May 1999
Posts: 149
Enthusiast
Enthusiast
Offline
Joined: May 1999
Posts: 149
Some words to the wise.

For quite a period of time, I suffered from regular mySQL crashes. I therefore did the unthinkable, and poured over http://www.mysql.com/doc/S/H/SHOW_VARIABLES.html

A few basic lessons learned, for beginners like me.

Inside mySQL, you can run
> show variables;
to display the current variables in action. And you can run
> show status;
to see the impact of these variables & gauge the current state of your mySQL installation.

Your my.cnf file, usually sitting in /etc/ , controls the default settings for many of the variables. In the source of mysql, there are several default my.cnf files... one for small systems, another for medium and large.

Persistent database connections put a lot of demands on memory... generally not worth the small speed improvement.

A few key parameters to adjust:

key_buffer_size
This one is really important. It's explained well in the manual. What's not stressed enough is that if you set this value to be too large, mySQL will demand memory from your operating system. If this demand is too high, Your OS will attempt to accommodate the request, leading to swapping/paging and your system will slow down to a crawl. This is what was happening to me. Also, don't be fooled by the seemingly available memory reported by the OS. I suspect that Linux doesn't like giving too much memory to a single app... so although Linux might report free available memory, you might still be swapping.

To adjust key_buffer_size, take a look at the status results... if Key_reads compared to Key_read_requests is about 1%, you're doing OK... no need to increase key-buffer_size further. A value of 32 MB is quite sufficient in most cases, and 64 MB is very generous.

table_cache
This is probably the next most important value. I have it set to 128. If it's too small, you'll see your "Opened tables" value steadily grow bigger when running status. If "Opened tables" is steady, you don't need to increase this value (but try decreasing it to see if you can get away with less).

thread_cache_size
Try setting this to 8 if you have enough memory. The impact of a larger number is that your ration of "threads created" to "Connections" will decrease. I believe that CPU demands will also decrease. This variable is important if you have a lot of short-lived connections, but is less important otherwise.

thread_concurrency
The manual recommends setting this to # of CPUs x 2. It mentions that it only matters on Solaris, but I'm not certain... to play it safe, don't exceed the CPU x 2 number.

max_connections
100 is common. I have it set to 50, on a forum which frequently has 50+ simulataneous users. You really don't want too many simultaneous queries hitting mySQl at the same time... bad things can happen. I'd rather have a user get an error message every once in a long while, and have to hit reload, than to have mySQL crunch, creak and buckle. This is especially important if you're suffering from frequent crashes / slowdowns. A common mistake is to increase the number of connections... you should decrease them instead.

OK, that's pretty much my current braindump with respect to mySQL optimisation... not much for experienced users, but I hope that it's useful for someone out there. Please feel free to ask questions, or correct any errors I may have made.

Regards,
Max



Sponsored Links
Entire Thread
Subject Posted By Posted
MySQL optimization Max Fisch 02/01/2002 5:27 AM
Re: MySQL optimization Renaud 02/03/2002 5:41 AM
Re: MySQL optimization AllenAyres 02/03/2002 8:35 AM
Re: MySQL optimization Max Fisch 02/08/2002 1:42 PM
Re: MySQL optimization The Team 04/08/2002 1:46 AM

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
• Shock Hosting
• Stable Host
• bluehost
• InterServer
Visit us on Facebook
Member Spotlight
Zarzal
Zarzal
Berlin, Germany
Posts: 808
Joined: July 2001
Forum Statistics
Forums63
Topics37,583
Posts293,957
Members13,826
Most Online151,614
Nov 14th, 2025
Today's Statistics
Currently Online 75951
Topics Created 0
Posts Made 0
Users Online 1
Birthdays 2
Top Posters
AllenAyres 21,080
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,834
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2026 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.1.0
(Snapshot build 20261026)