Transcript
Page 1: Scaling Solr with Solr Cloud

Scaling Solr with SolrCloud

Rafał Kuć – Sematext Group, Inc.@kucrafal @sematext sematext.com

Page 2: Scaling Solr with Solr Cloud

Ta me…

Sematext consultant & engineerSolr.pl co-founderFather and husband

Page 3: Scaling Solr with Solr Cloud

Solr History

2004

2006

2007

2008

2009

2010

2012

2013

Y. Seeley creates Solr

Incubator graduation

Solr 1.4 released

Solr 4.0 released

Solr 4.1 and counting

Lucene / Solr merge

Solr 1.3 released

Solr donated to ASF

Page 4: Scaling Solr with Solr Cloud

The Past

Page 5: Scaling Solr with Solr Cloud

Master – Slave Deployment

Application

Solr Master

Solr Slave Solr Slave Solr Slave Solr Slave

Page 6: Scaling Solr with Solr Cloud

Master as SPOF

Application

Solr Slave Solr Slave Solr Slave Solr Slave

Solr Master

Page 7: Scaling Solr with Solr Cloud

R

Replication Time

Indexing App

Solr Slave

Solr Slave

Solr Master

Solr Slave

Querying App

Page 8: Scaling Solr with Solr Cloud

Solr Slave Solr Slave

Solr Master

Too Much for a Single Shard

Application

Solr MasterSolr Master

Solr Slave Solr SlaveSolr Slave Solr Slave

Page 9: Scaling Solr with Solr Cloud

Solr Slave Solr Slave

Solr Master

Too Much for a Single Shard

Application

Solr Master

Solr Slave Solr SlaveSolr Slave Solr Slave

Solr Master

Page 10: Scaling Solr with Solr Cloud

DocResponseResponse

Shar

d1, s

hard

2,

shar

d3Sh

ard1

, sha

rd2,

sh

ard3

Querying in Multi Master Deployment

Solr SlaveShard 2

Solr SlaveShard 3

Solr SlaveShard 1

Application

Page 11: Scaling Solr with Solr Cloud

SolrCloud Comes Into Play

Page 12: Scaling Solr with Solr Cloud

Basic Glossary

https://cwiki.apache.org/confluence/display/solr/SolrCloud+Glossary

Cluster

Node

Collection

Shard

Leader & Replica

Overseer

Page 13: Scaling Solr with Solr Cloud

Apache ZooKeeperQuorum is required

Sample configuration

clientPort=2181dataDir=/usr/share/zookeeper/datatickTime=2000initLimit=10syncLimit=5server.1=192.168.1.1:2888:3888server.2=192.168.1.2:2888:3888server.3=192.168.1.3:2888:3888

ZooKeeper ZooKeeper ZooKeeper

Page 14: Scaling Solr with Solr Cloud

Solr Instances

ZooKeeper ZooKeeper ZooKeeper

Solr Server Solr Server

-DzkHost=192.168.1.2:2181,192.168.1.1:2181,192.168.1.3:2181

Solr Server Solr Server

-DzkHost=192.168.1.1:2181,192.168.1.2:2181,192.168.1.3:2181

-DzkHost=192.168.1.3:2181,192.168.1.1:2181,192.168.1.2:2181

-DzkHost=192.168.1.3:2181,192.168.1.1:2181,192.168.1.2:2181

Page 15: Scaling Solr with Solr Cloud

Collection Creation

ZooKeeper ZooKeeper ZooKeeper

Solr Server Solr Server

Solr Server Solr Server$ cloud-scripts/zkcli.sh –cmd upconfig -zkhost 192.168.1.2:2181 -confdir /usr/share/config/revolution/conf -conf revolution

$ curl 'http://solr1:8983/solr/admin/collections?action=CREATE&name=revolution&numShards=2&replicationFactor=1'

Page 16: Scaling Solr with Solr Cloud

Solr Server

Single Collection Deployment

Solr Server

Solr Server Solr Server

Shard1

Application

Shard2

Page 17: Scaling Solr with Solr Cloud

Collection with Replica

ZooKeeper ZooKeeper ZooKeeper

Solr Server Solr Server

Solr Server Solr Server$ curl 'http://solr1:8983/solr/admin/collections?action=CREATE&name=revolution&numShards=2&replicationFactor=2'

Page 18: Scaling Solr with Solr Cloud

Solr Server

Collection with Replicas

Solr Server

Solr Server Solr Server

Shard1 Replica

Shard2 Replica

Shard2Shard1

Application

Page 19: Scaling Solr with Solr Cloud

Solr Server

Querying

Solr Server

QU

ERY

fl=id,sco

re

fl=id,score

Application

Id,score Id,scoreShard1 Shard2

Solr Server

Page 20: Scaling Solr with Solr Cloud

Solr Server

Querying

Solr Server

Application

docdoc

get docs

get docsResults

Shard2Shard1

Solr Server

Page 21: Scaling Solr with Solr Cloud

Shard and Replica Number

How your data looks

Expected data growth

Target performance

Target node number

Max number of nodes = number of shards * (number of replicas + 1)

Shard

Replica

ReplicaReplica

Replica

Shard

Shard

Replica

Page 22: Scaling Solr with Solr Cloud

What should I go for?

More data? Shard

Replica Replica

ShardShard

ReplicaMore queries ? Replica Replica Replica

Page 23: Scaling Solr with Solr Cloud

Custom Routing

Default (numShards present, pre 4.5)

Implicit (numShards not present, pre 4.5)

Page 24: Scaling Solr with Solr Cloud

Solr ServerSolr Server

id=userB!3id=userA!2

Custom Routing Example

id=userA!1

Shard2Shard1

Page 25: Scaling Solr with Solr Cloud

Querying Solr – Default Routing

Shard 1 Shard 2 Shard 3 Shard 4

Shard 5 Shard 6 Shard 7 Shard 8

Solr Collection

Application

Page 26: Scaling Solr with Solr Cloud

Shard 1 Shard 2 Shard 3 Shard 4

Shard 5 Shard 6 Shard 7 Shard 8

Solr Collection

Application

Quering Solr – Custom Routing

q=revolution&_route_=userA!

Page 27: Scaling Solr with Solr Cloud

Collection Manipulation CommandsCreate

Delete

Reload

Split

Create Alias

Delete Alias

Shard Creation/Deletionhttp://wiki.apache.org/solr/SolrCloud

Page 28: Scaling Solr with Solr Cloud

Collection Creation

name

numShards

replicationFactor

maxShardsPerNode

createNodeSet

collection.configName

Page 29: Scaling Solr with Solr Cloud

Collection Split Example

$ curl 'http://solr1:8983/solr/admin/collections?action=CREATE&name=collection1&numShards=2&replicationFactor=1'

Page 30: Scaling Solr with Solr Cloud

Collection Split Example

$ curl 'http://localhost:8983/solr/admin/collections?action=SPLITSHARD&collection=collection1&shard=shard1'

Page 31: Scaling Solr with Solr Cloud

Collection Aliasing

$ curl 'http://solr1:8983/solr/admin/collections? action=CREATEALIAS&name=weekly&collections=20131107,20131108,20131109,20131110,20131111,20131112,20131113'

$ curl 'http://solr1:8983/solr/admin/collections? action=DELETEALIAS&name=weekly'

$ curl 'http://solr1:8983/solr/weekly/select?q=revolution'

Page 32: Scaling Solr with Solr Cloud

Caches

q=lucene+revolution

fq=city:Dublin

Solr Cache

Refreshed with IndexSearcher

Configurable

Different purposes

Different implementations

Page 33: Scaling Solr with Solr Cloud

Filter Cache

q=*:*&fq={!cache=false}city:Dublin

q=*:*&fq={!frange l=0 u=10 cache=false cost=200}sum(price,pro)

q=lucene+revolution&fq=city:Dublin

<filterCache class="solr.FastLRUCache" size="512" initialSize="512" autowarmCount="128" />

q=lucene+revolution+city:Dublin

Page 34: Scaling Solr with Solr Cloud

Document Cache

<documentCache class="solr.LRUCache" size="512" initialSize="512" />

Page 35: Scaling Solr with Solr Cloud

Query Result Cache

q=lucene+revolution&fq=city:Dublin&sort=date+desc&start=0&rows=10

<queryResultCache class="solr.LRUCache" size="512" initialSize="512" autowarmCount="128"/>

q=lucene+revolution+city:Dublin&sort=date+desc&start=0&rows=10

<queryResultWindowSize>20</queryResultWindowSize>

<queryResultMaxDocsCached>200</queryResultMaxDocsCached>

Page 36: Scaling Solr with Solr Cloud

Warming<listener event="newSearcher" class="solr.QuerySenderListener"> <arr name="queries"> <lst><str name="q">*:*</str><str name="sort">date desc</str></lst> <lst><str name="q">keywords:* OR tags:*</str></lst> <lst><str name="q">*:*</str><str name="fq">active:*</str></lst> </arr></listener><listener event="firstSearcher" class="solr.QuerySenderListener"> <arr name="queries"> <lst><str name="q">*:*</str><str name="sort">date desc</str></lst> <lst><str name="q">keywords:* OR tags:*</str></lst> <lst><str name="q">*:*</str><str name="fq">active:*</str></lst> </arr></listener><useColdSearcher>false</useColdSearcher>

Page 37: Scaling Solr with Solr Cloud

The Right Directory

_0.fdt _0.fdx _0.fnm _0.nvd

_1.fdt _1.fdx _1.fnm _1.nvd

StandardDirectory

SimpleFSDirectory

NIOFSDirectory

MMapDirectory

NRTCachingDirectory

RAMDirectory <directoryFactory name="DirectoryFactory" class="solr.NRTCachingDirectoryFactory" />

Page 38: Scaling Solr with Solr Cloud

Column oriented fields - DocValues

<field name="categories" type="string" indexed="false" stored="false" multiValued="true" docValues="true"/>

<field name="categories" type="string" indexed="false" stored="false" multiValued="true" docValues="true" docValuesFormat="Disk"/>

NRT compatible

Better compression than field cache

Can store data outside of JVM heap

Can improve things for dynamic indices

Page 39: Scaling Solr with Solr Cloud

Segment Merge

a b c d e

Level 0 Level 1

cf g

Page 40: Scaling Solr with Solr Cloud

Segment Merge Under Control

Merge policy

Merge scheduler

Merge factor

Merge policy configuration

Page 41: Scaling Solr with Solr Cloud

Configuring Segment Merge

<mergePolicy class="org.apache.lucene.index.TieredMergePolicy"> <int name="maxMergeAtOnce">10</int> <int name="segmentsPerTier">10</int></mergePolicy>

<mergeScheduler class="org.apache.lucene.index.ConcurrentMergeScheduler"/>

<mergeFactor>10</mergeFactor>

<mergedSegmentWarmer class="org.apache.lucene.index.SimpleMergedSegmentWarmer"/>

Page 42: Scaling Solr with Solr Cloud

Indexing Throughput Tuning

Maximum indexing threads

RAM buffer size

Maximum buffered documents

Bulk, bulks and bulks

CloudSolrServer

Autocommit

Cutting off unnecessary stuff

Page 43: Scaling Solr with Solr Cloud

TransactionLog

<updateLog> <str name="dir">${solr.ulog.dir:}</str></updateLog>

Updates durability

Recovering peer replay

Performant Realtime Get

<requestHandler name="/get" class="solr.RealTimeGetHandler"></requestHandler>

Page 44: Scaling Solr with Solr Cloud

Autocommit or Not?

<autoCommit> <maxTime>15000</maxTime> <maxDocs>1000</maxDocs> <openSearcher>false</openSearcher></autoCommit>

<autoSoftCommit> <maxTime>1000</maxTime> </autoSoftCommit>

Automatic data flush

Automatic index view refresh

Page 45: Scaling Solr with Solr Cloud

Autocommit & openSearcher=true<autoCommit> <maxDocs>10</maxDocs> <openSearcher>true</openSearcher></autoCommit>

Page 46: Scaling Solr with Solr Cloud

AutoSoftCommit & openSearcher=false<autoCommit> <maxDocs>1000</maxDocs> <openSearcher>false</openSearcher></autoCommit>

<autoSoftCommit> <maxDocs>10</maxDocs> </autoSoftCommit>

Page 47: Scaling Solr with Solr Cloud

Postings Formats to the Rescue

Lucene 4.0 >= Flexible Indexing

Postings == docs, positions, payloads

Different postings formats available

<codecFactory class="solr.SchemaCodecFactory" />

<field name="id" type="string_pulsing" indexed="true" stored="true" />

<fieldType name="string_pulsing" class="solr.StrField" postingsFormat="Pulsing41" />

BloomPulsingSimple textDirectMemory

Page 48: Scaling Solr with Solr Cloud

MonitoringCluster state

Nodes utilization

Memory usage

Cache utilization

Query response time

Warmup times

Garbage collector work

Page 49: Scaling Solr with Solr Cloud

JMX and Solr

Page 50: Scaling Solr with Solr Cloud

JMX and Solr

Page 51: Scaling Solr with Solr Cloud

Administration Panel

Page 52: Scaling Solr with Solr Cloud

Administration Panel

Page 53: Scaling Solr with Solr Cloud

Monitoring with SPM

Page 54: Scaling Solr with Solr Cloud

Monitoring with SPM

Page 55: Scaling Solr with Solr Cloud

Other Monitoring Tools

Ganglia http://ganglia.sourceforge.net/

New Relic http://www.newrelic.com/

Opsview http://www.opsview.com

Page 56: Scaling Solr with Solr Cloud

We Are Hiring !

Dig Search ?Dig Analytics ?Dig Big Data ?Dig Performance ?Dig working with and in open – source ?We’re hiring world – wide !

http://sematext.com/about/jobs.html


Recommended