Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello, I'm running a website on a 16G ram Inter core i5 dedicated server but when more than about 60 users are connected in the same time the site become very slow because of mysql. Is my my.cnf correctly tuned ? Why about half of tables aer stored in the disk instead of ram ?
Thanks!
Enable the query cache in MySQL to improve performance.
If you want to get optimized and speedy response from your MySQL server then you need to add following two configurations directive to your MySQL server:
query_cache_size=SIZE
The amount of memory (SIZE) allocated for caching query results. The default value is 0, which disables the query cache.
query_cache_type=OPTION
Set the query cache type. Possible options are as follows:
0 : Don't cache results in or retrieve results from the query cache.
1 : Cache all query results except for those that begin with SELECT S_NO_CACHE.
2 : Cache results only for queries that begin with SELECT SQL_CACHE
You can setup them in /etc/my.cnf (Red Hat) or /etc/mysql/my.cnf (Debian) file:
In above example the maximum size of individual query results that can be cached set to 1048576 using query_cache_limit system variable. Memory size in Kb.
Hello, I'm running a website on a 16G ram Inter core i5 dedicated server but when more than about 60 users are connected in the same time the site become very slow because of mysql. Is my my.cnf correctly tuned ? Why about half of tables aer stored in the disk instead of ram ?
There's no way anyone here can tell you, since you're not providing enough details. Things like how big your database is, how your 60 users are connecting TO that database, how many tables, how many disks/controllers the DB is spanning, etc. If your users are connecting via a web interface, are you sure they're only having ONE connection at a time, versus many different tabs/windows? Are the programs releasing connections as they should be? Using a dedicated client-program? And have you examined the queries against the database?? It could be you have a poorly constructed query that works fine in a small test scenario, but will take a LOT of time in production. The side-effect there is that the client-side connection could be broken, leaving the query running...while the user starts ANOTHER session, thinking that it's locked up. More connections=more queries=more MySQL cycles/slow performance.
And how do you KNOW it's MySQL causing the problem? Run MySQLworkbench or a similar tool, to let you see how your DB is layed out, and modify things based on that. And if you're running a big database on a single hard-drive, have you looked at the disk statistics? iostat and other tools can tell you this.
Also, what kind of monitoring do you have on the system now?
Quote:
Originally Posted by karim.ouda
Yes they are correct.
Sorry, there is no way of knowing if those parameters are correct or not. The OP has not provided enough relevant information about their environment, and since they said those parameters/values were ALREADY PRESENT (and they're still having performance issues), then signs point to other issues with MySQL or the associated clients.
I know because only pages that need database connection are very slow, they connect via web interface using one single db user. The database has 35 tables but inside some of theme there are up to more than 1 million rows.
I know because only pages that need database connection are very slow, they connect via web interface using one single db user. The database has 35 tables but inside some of theme there are up to more than 1 million rows.
Ok, so now we know it's a web-based program. You STILL don't address any of the other questions/issues mentioned that could be part of the problem. And you say "one single db user"...do you mean that your whole web-based system uses the same user-id to attach to the DB, or that you've tried booting everyone out BUT one user??? Again, how BIG is the database? 1 million rows of 100 byte data is trivial....one thousand rows with a thousand fields and complex data isn't.
Again, you need to analyze your DB structure, and look carefully at EVERY piece of the system, queries included.
Enable slow query log and see if there are any repeating queries, possibly not using indexes. Or analyze the slow log using something like percona tools.
Code:
cd /var/log
touch slow.log
chown mysql:mysql slow.log
mysql -p
set global slow_query_log=ON;
set global slow_query_log_file="/var/log/slow.log";
set global log_slow_queries=ON;
set global long_query_time=1;
set global log_queries_not_using_indexes=ON;
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.