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
Joined: Feb 2002
Posts: 1
Lurker
Lurker
Offline
Joined: Feb 2002
Posts: 1
In reply to:


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





I don't think so.
Persistents databases connections are very important for MySQL. Some benchamarks have been done and all have the same results: MySQL is very very slow when it have many concurrent acces. It's often the slowest database after 30 concurrent connections.
But, it's still on of the fastest linux database if you are using persistent connections. Of course, you need a lot of memory, but all big databases, with many concurrents acces, need memory.

"Use persistent connections to the database to avoid the connection overhead" is the first tip of "Optimisation Tips" from MySQL manual:
http://www.mysql.com/doc/T/i/Tips.html

If you want to see benchmark about MySQL persistent/non-persistant connections, read this benchmark (in french but you have graphics):
http://www.devparadise.com/technoweb/sys/bench/d55a446.asp

Renaud



kcbruce #213178 02/03/2002 12:35 AM
Joined: Mar 2000
Posts: 21,080
Likes: 3
I type like Navaho
I type like Navaho
Joined: Mar 2000
Posts: 21,080
Likes: 3
In reply to:


If you want to see benchmark about MySQL persistent/non-persistant connections, read this benchmark (in french but you have graphics):
http://www.devparadise.com/technoweb/sys/bench/d55a446.asp

Renaud




Wow, ASP kicks.. ummm... asp []https://www.ubbdev.com/threads/php/images/icons/laugh.gif[/]

Welcome Renaud []https://www.ubbdev.com/threads/php/images/icons/smile.gif[/]


- Allen wavey
- What Drives You?
Joined: May 1999
Posts: 149
Enthusiast
Enthusiast
Offline
Joined: May 1999
Posts: 149
Hi Renaud,

Thanks for the info... OK, let me rephrase:

Persistent databases put a lot of demands on memory. If you're suffering from regular crashes, and "too many connections" errors, do not hesitate to disable persistent connections. The resulting slowdown for UBBThreads in a Unix/mySQL environment is barely perceptible to the naked eye for a typical installation.

Regards,
Max

Joined: Aug 2000
Posts: 3,590
Likes: 1
Moderator
Moderator
Offline
Joined: Aug 2000
Posts: 3,590
Likes: 1
"
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. []/forum/images/icons/smile.gif[/]

Sponsored Links

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)