eruna — 2011-09-29T11:52:02-04:00 — #1
A site I've been working on has started to get very slow with increased traffic.
Search result combine listing combined from several tables. What is the best strategy for speeding this up?
I was thinking caching an XML file might work. Though I'm concerned writing the entire table as xml may run into memory limits. Another idea is to compile the complete listings in a table so they wouldn't need to get assembled on the fly.
Any thoughts on this?
scallioxtx — 2011-09-29T18:23:53-04:00 — #2
What kind of searches are performed on the data?
Writing to XML probably won't make it faster, because XML is not a very fast nor efficient format to use. You're probably better off using some caching mechanism like memcache, XCache or APC.
Alternatively, depending on the data, you may want to look at alternative servers to MySQL, like Solr, which is a lot better and faster at searching large quantities of data than MySQL will ever be.
eruna — 2011-09-29T23:41:41-04:00 — #3
An example search would be to filter blog entries by theme and location
Each entry would have information drawn from the blog table, member table, location table, etc.. for the display.
eruna — 2011-10-04T10:12:11-04:00 — #4
I researched you recommendations but couldn't figure out where to start and how to install them.
So I went with my original plan and set up a cron job to update a cached "profile" field to the members' table for searches.
This cut the delivery of the html from 10 seconds to 600ms.
This may not be optimal, but it worked.
cups — 2011-10-05T04:15:19-04:00 — #5
This is not the fast option, but might lead to insights.
Log what the actual search terms are (and if possible the number results found) and look for patterns (frequent terms, terms by time of day, terms by type of user and so on).
After some time you will spot patterns emerging which may lead you to:
a) pre-cache some results
b) alter your gui and navigation to make these top tasks more accessible early on to your users and make your site easier to use.
c) compelling evidence of "missing content" - stuff your users search for - but never find
d) mismatch of terms, you call it a "swimming pool ingester" but your users search for "pool cleaner"
The solution you found sounds good, but doing the above might lead you to other solutions, and to ask fundamental questions such as "why are our users searching?"
eruna — 2011-10-05T23:05:23-04:00 — #6
Thank you Cups. These searches are mostly drop down menus sorts. They can also be searched by name and country. The strategy I used created acceptable results. The downside to it is that a separate caching script needs to be created for each type of content (of which they are many). On the host the site is on now, APC isn't an option and I don't think the other ones ScallioXTX mentioned are either. Though they are probably more elegant solutions.
cups — 2011-10-06T04:15:28-04:00 — #7
So in effect, are you saying its not "string searches" a la Google, it is filtered results? From your database?
jv1 — 2011-10-06T14:46:26-04:00 — #8
Make sure you have indexed all your searchable/sortable columns properly.
cups — 2011-10-07T06:56:17-04:00 — #9
Turn on the slow queries log temporarily and try and knock off the slowest ones, do what JV- suggests. See if you can increase the cache size on your database (sorry, I don't know if this is really possible).