Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My company has a few servers that we dedicate to running Sphinx Search. All are CentOS 5 with about 48GB of memory and our version of searchd is 1.11. Recently I've been trying to understand why Sphinx uses so little of the available memory for its regular indexes (we don't use RT indexes at the moment). According to the official Sphinx website, all files related to an index except for the .spd and .spp files are stored in RAM. At present this constitutes about 14GG for all our indexes, which can easily fit in RAM. However, when I consult htop for memory usage, it's showing a little less than 1.5GB being used! Interestingly enough, it reports that swap is being used as well, even with vm.swappiness set to 0. If I stop searchd, swap goes down to 0. (It should be noted that the amount of swap used is no greater that the amount of memory being used.) We have it configured so that all our indexes are preopened on startup (preopen_indexes = 1 in our sphinx conf).

I have two questions, given the above information:

  1. What is Sphinx doing with the data in those indexes, if it isn't keeping it in memory?
  2. Is it possible to force Sphinx to keep more data in memory?
share|improve this question
add comment

2 Answers

What is Sphinx doing with the data in those indexes, if it isn't keeping it in memory?

It probably does put them into memory. But the host OS, notices they are not being used much, and so swaps them out.

Would suggest looking at making sure your swappiness is really being applied.

Is it possible to force Sphinx to keep more data in memory?

If you have the memory to spare. Put the indexes on a RAM-Disk :)


And if you really have plenty of memory to spare, turn OFF swap altogether instead. You risk a crash if run out of memory, but it sounds unlikly to happen on that server.

share|improve this answer
    
Thanks for the advice. I've gone through the SphinxSearch forums and found much of what you said. Swappiness is indeed set to 0, but will certainly look into just turning swap off. One thing I have also tried is using the mlock option for each index to lock the .spa and .spi files in memory, but I don't see an appreciable increase in memory usage when enabled. It isn't giving me an error when I start searchd. Do you know if the option works properly? I have tried it with 2.0.6 and 2.1.1-dev as well as 1.10 and it seemed to operate the same no matter which version I used. –  altendo Feb 13 '13 at 0:40
add comment

try mlock = 1 and reindex all indexes.

index index1
{
    source      = main1
    path        = /ssd/sphinx/index.main
    charset_type    = utf-8
    docinfo     = extern
    mlock       = 1
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.