I'm running a big site with PHP/MySQL on a Linux server with 4gb RAM and (4) 250mb HDs and (4) 3 ghz Intel CPUs. PHP is 4.4.4 and MySQL is 4.1.22 (a cPanel setup). Linux is 2.4.21-47.0.1.ELsmp.
I have a database with just under 1 million records, 1.5gb. The indexes add another 1.5gb.
The existing database is doing fairly well, but runs out of memory and swap about once per day so the server has to be rebooted. Otherwise the searches are relatively fast.
There are NO writes into the database, other than to add records by the admins about once a month. It is basically a read-only site, something like a search engine. Users search the database by keyword phrases, or click ready-made searches or find us online via search engines who have already given them their search paths as URLs to click on.
The full database needs to be searched and results ranked by relevancy, then paged out into pages for ease of use. This has been working well so far, for about a year. Here is the code we use to access the records:
SELECT *,
MATCH(Title, Contents)
AGAINST ('$trimmedkeywords')
AS score
FROM reports
WHERE MATCH(Title, Contents)
AGAINST ('$trimmedkeywords' in boolean mode)
GROUP BY Link
ORDER BY score DESC";
PROBLEM:
We have another 7 million or so records we want to add to the database, which should bring the total to around 8 million. The final database will likely be about 12 gb, with indexes adding another 12 gb, for a total size of around 25 gb or so, roughly.
POSSIBLE SOLUTIONS:
We suspect that we need more RAM, no matter what we do. We are also considering other things, including:
1) Increasing RAM to 8, 16 or even 32 gb to help accommodate the large 25gb db.
2) changing the structure of our database to have more than one table,
3) changing the nature of the indexes
4) moving to another database instead of MySQL (has to be free and should run under cPanel/PHP/Linux)
5) Fine tuning our MySQL setup config so that it can more efficiently handle this larger db.
6) possibly running several machines in parallel to serve more traffic and more pages
Any ideas on how to do this, anyone?
Thanks!