Caching 如何将整个Solr索引加载到内存中以提高性能?
我的网站每秒点击10-30次(包括机器人爬行)。我在Solr中索引了600万条记录(来自一个mysql表)。当我使用Caching 如何将整个Solr索引加载到内存中以提高性能?,caching,indexing,solr,lucene,solr4,Caching,Indexing,Solr,Lucene,Solr4,我的网站每秒点击10-30次(包括机器人爬行)。我在Solr中索引了600万条记录(来自一个mysql表)。当我使用q=something和sort=random\uu检索30条记录时,Solr需要200到300毫秒才能响应,有时需要100毫秒 我试图使用solr.RAMDirectoryFactory设置来改进检索,但出现内存不足错误。我知道solr.RAMDirectoryFactory设置不是持久的。所以,哪一个是增加缓存和将整个索引加载到内存中的最佳选择 我正在为Solr使用Digita
q=something
和sort=random\uu
检索30条记录时,Solr需要200到300毫秒才能响应,有时需要100毫秒
我试图使用solr.RAMDirectoryFactory
设置来改进检索,但出现内存不足错误。我知道solr.RAMDirectoryFactory
设置不是持久的。所以,哪一个是增加缓存和将整个索引加载到内存中的最佳选择
我正在为Solr使用Digital Ocean 8GB服务器
Solr设置
<filterCache class="solr.FastLRUCache"
size="512"
initialSize="512"
autowarmCount="0"/>
<queryResultCache class="solr.LRUCache"
size="512"
initialSize="512"
autowarmCount="0"/>
<documentCache class="solr.LRUCache"
size="512"
initialSize="512"
autowarmCount="0"/>
论据:
-DSTOP.KEY=solrrocks-DSTOP.PORT=7983-Djetty.home=/opt/solr/server-Djetty.port=8983-Dlog4j.configuration=file:/var/solr/log4j.properties-Dsolr.data.home=-Dsolr.default.confdir=/opt/solr/server/solr/configsets/_default/conf-Dsolr.install.dir=/opt/solr-Dsolr.jetty.https.port=8983-Dsolr.log.dir=/var/solr/logs-Dsolr.log.muteconsole-Dsolr.solr.home=/var/solr/data-Duser.timezone=UTC-XX:+CMSParallelRemarkEnabled-XX:+CMSScavengeBeforeRemark-XX:+ParallelRefProcEnabled-XX:+PrintGCApplicationStoppedTime-XX:+PrintGCDateStamps-XX:+PrintGCDetails-XX:+PrintGCTimeStamps-XX:+PrintHeapAtGC-XX:+PrintTenuringDistribution-XX:+UseCMSInitiatingOccupancyOnly-XX:+UseConcMarkSweepGC-XX:+UseGCLogFileRotation-XX:+UseParNewGC-XX:-OmitStackTraceInFastThrow-XX:CMSInitiatingOccupancyFraction=50-XX:CMSMaxAbortablePrecleanTime=6000-XX:ConcGCThreads=4-XX:GCLogFileSize=20M-XX:MaxTenuringThreshold=8-XX:NewRatio=3-XX:NumberOfGCLogFiles=9-XX:OnOutOfMemoryError=/opt/solr/bin/oom_solr.sh 8983 /var/solr/logs-XX:ParallelGCThreads=4-XX:PretenureSizeThreshold=64m-XX:SurvivorRatio=4-XX:TargetSurvivorRatio=90-Xloggc:/var/solr/logs/solr_gc.log-Xms512m-Xmx512m-Xss256k-verbose:gc
提前感谢重要的是要记住,当8GB服务器和Solr堆设置为512M时,Lucene(而不是Solr!)将使用机器上剩余的可用内存(减去O.s.需要的内存等) 比如说,操作系统需要512M的RAM,而你的Solr堆是512M,那么Lucene还有7GB。如果你是Solr和Lucene的新手,那么Lucene的记忆是如何工作的 你的指数有多大?您可以使用
du-h
检查您的/solr/data
文件夹
为了澄清增加Solr Heap会使情况变得更糟(Lucene的内存会更少)。为了避免将RAM交换到磁盘,您还需要关闭交换(参见示例)
Solr和Lucene以及您的实例中有许多旋钮和按钮需要调整,以确保整个索引都在内存中。即使这样,也要记住,JavaGC、CPU速度、内存速度以及将索引预热到内存中都会显著影响响应时间
要了解更多信息,请参阅
-DSTOP.KEY=solrrocks-DSTOP.PORT=7983-Djetty.home=/opt/solr/server-Djetty.port=8983-Dlog4j.configuration=file:/var/solr/log4j.properties-Dsolr.data.home=-Dsolr.default.confdir=/opt/solr/server/solr/configsets/_default/conf-Dsolr.install.dir=/opt/solr-Dsolr.jetty.https.port=8983-Dsolr.log.dir=/var/solr/logs-Dsolr.log.muteconsole-Dsolr.solr.home=/var/solr/data-Duser.timezone=UTC-XX:+CMSParallelRemarkEnabled-XX:+CMSScavengeBeforeRemark-XX:+ParallelRefProcEnabled-XX:+PrintGCApplicationStoppedTime-XX:+PrintGCDateStamps-XX:+PrintGCDetails-XX:+PrintGCTimeStamps-XX:+PrintHeapAtGC-XX:+PrintTenuringDistribution-XX:+UseCMSInitiatingOccupancyOnly-XX:+UseConcMarkSweepGC-XX:+UseGCLogFileRotation-XX:+UseParNewGC-XX:-OmitStackTraceInFastThrow-XX:CMSInitiatingOccupancyFraction=50-XX:CMSMaxAbortablePrecleanTime=6000-XX:ConcGCThreads=4-XX:GCLogFileSize=20M-XX:MaxTenuringThreshold=8-XX:NewRatio=3-XX:NumberOfGCLogFiles=9-XX:OnOutOfMemoryError=/opt/solr/bin/oom_solr.sh 8983 /var/solr/logs-XX:ParallelGCThreads=4-XX:PretenureSizeThreshold=64m-XX:SurvivorRatio=4-XX:TargetSurvivorRatio=90-Xloggc:/var/solr/logs/solr_gc.log-Xms512m-Xmx512m-Xss256k-verbose:gc