I’m setting up a PHP/MySQL web application on a new VPS. The VPS is running PHP 5 and MySQL 5, and has 512MB RAM (burstable to 1GB). The server and the application are freshly installed, so I don’t have much benchmarks on the database performance, but I would like it to be robust and scalable under a high-usage multi-user scenario.
The database schema consists of 4 tables only, all InnoDB except for one which is a MyISAM table. The MyISAM table has a full-text index on one of the VarChar fields. There are indexes on all relevant primary key and foreign key fields (all MediumInt).
I would appreciate if someone can review my database configuration (my.cnf listed below) and please suggest suitable improvements:
Some questions that I need answered if I’m going to give you proper suggestions.
How big is your database in MB?
So that I can get a feel for what the settings would be.
Do you really need InnoDB and why?
Because as I understand you need MyISAM due to fulltext index and it is better to just focus on one table type in that case.
How many queries per second are you expecting?
You should always try to do some estimation so that you know what to begin with. Otherwise you are just shooting in the dark with the settings.
I have made some assumptions based on what you told me and some experienced guesses of my own.
You said the server had 512MB RAM.
Which means that I have deduced about 128MB (OS) + 128 (Apache+PHP) = 256Mb.
If you look at this later and it turns out they are using much less then you can increase the Innodb_buffer_pool_size parameter.
But at the same time you said that your DB was current only 20Mb so it will take you a while before your are going to need so much cache space.
I also made an estimation about future storage requirement for your DB.
One user = 1500 rows according to you and if we assume an average of 5 columns and a guess of column width to 100 bytes (which is probably very high but since I don’t know about your structure).
It still turns out to: 1500 * 5 * 100 = 750kb so the growth rate doesn’t seem to be that high.
Which means that if your InnoDB table space is set to 256Mb as I have in the conf file.
It will take you 3000 users to reach 256MB. Is this a reasonable figure?
Above I’m trying to get you to start to think about things like this. Because without actually trying to calculate something you will never make an educated guess.
Unless you had some special reason for some of the settings in the my.cnf that you posted.
I suggest something like this instead.
It is much simpler since I removed a lot of usually unnecessary or default values:
This should be sufficient for you to start with and run for quite some time. And by then your DB will be large enough to actually be able to spot any real performance problems.