Thinking Sphinx rebuilding index - high CPU load
I have a CRON job rebuilding Sphinx index every 5 minutes:
*/5 * * * * cd /var/www/my_app && /usr/local/bin/ruby /usr/local/bin/rake RAILS_ENV=production 开发者_开发知识库ts:rebuild >> /var/www/my_app/log/cron_log.log
It's indexing only one table with around 400 records, but every time it starts the rake task the CPU load jumps to 100% (VPS with 4 CPUs and 1 GB RAM). I can't seem to find any reasonable explanation for this. How can I investigate what's causing it? Is there any way to optimize this process?
Does this task use the processes a great deal, and then stop as expected? Does it hang around far longer than it should?
Also, it's worth noting that you only need to rebuild if indices structures change (new fields or attributes), or you add or remove indices - to just update data, use the ts:index
task instead (which doesn't restart Sphinx unnecessarily).
精彩评论