Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solr performance with commitWithin does not make sense

I am running a very simple performance experiment where I post 2000 documents to my application. Who in tern persists them to a relational DB and sends them to Solr for indexing (Synchronously, in the same request).

I am testing 3 use cases:

  1. No indexing at all - ~45 sec to post 2000 documents
  2. Indexing included - commit after each add. ~8 minutes (!) to post and index 2000 documents
  3. Indexing included - commitWithin 1ms ~55 seconds (!) to post and index 2000 documents

The 3rd result does not make any sense, I would expect the behavior to be similar to the one in point 2. At first I thought that the documents were not really committed but I could actually see them being added by executing some queries during the experiment (via the solr web UI).

I am worried that I am missing something very big. Is it possible that committing after each add will degrade performance by a factor of 400?!

The code I use for point 2:

SolrInputDocument = // get doc
SolrServer solrConnection = // get connection 
solrConnection.add(doc);
solrConnection.commit(); 

Where as the code for point 3:

SolrInputDocument = // get doc
SolrServer solrConnection = // get connection
solrConnection.add(doc, 1); // According to API documentation I understand there is no need to call an explicit commit after this
like image 275
Vitaliy Avatar asked Mar 20 '23 14:03

Vitaliy


1 Answers

According to this wiki:

https://wiki.apache.org/solr/NearRealtimeSearch

the commitWithin is a soft-commit by default. Soft-commits are very efficient in terms of making the added documents immediately searchable. But! They are not on the disk yet. That means the documents are being committed into RAM. In this setup you would use updateLog to be solr instance crash tolerant.

What you do in point 2 is hard-commit, i.e. flush the added documents to disk. Doing this after each document add is very expensive. So instead, post a bunch of documents and issue a hard commit or even have you autoCommit set to some reasonable value, like 10 min or 1 hour (depends on your user expectations).

like image 151
D_K Avatar answered Mar 31 '23 13:03

D_K