When indexing document with the Bulk Service the NXQL query materialize the document set to index, the processing is the following:
1. Index request computation, receiving bucket of ids (default 1000):
Read documents by batch (25 by default) and build a bulk request (here it is elasticsearch bulk api not our bulk service)
Create multiple es bulk request if the size exceed the maximum record size (1MB)
Convert each es bulk request into a DataBucket record
Send records downstream and checkpoint
2. Elasticsearch bulk indexing computation, receiving DataBucket
This computation use an elasticsearch processor to aggregate indexing request from multiple DataBucket/bulk requests
The elasticsearch processor handles: the optimal bulk request size (default 5MB), the retry in case of failure (3 retries with backoff).
Using the computation timer we force the processor flush (default every 10s) and checkpoint position
3. An index completion computation is reading the done stream for index command,
if the indexing command contains an option to refresh the index or update the aliases, the computation executes these post indexing actions
Note that the bulk indexing computation is generic and can also process delete request (or create, update but it is not used in Nuxeo so far).
Because we want to use this bulk action to re index an entire repository an automation operation Elasticsearch.BulkIndex similar to Elasticsearch.Index is provided, this operation will first drop and create an index (or create a new index when alias is enabled) before running an indexing command on the entire repository (on completion the alias is updated if necessary).
Here the curl syntax:
The default re-indexing for the reference benchmark uses the following configuration:
with 2 Nuxeo nodes this means 12 Nuxeo threads submitting requests to the 3 elasticsearch nodes.
The results is:
- 2118 docs/s or 373116 docs in 178s
The monitoring during indexing shows that elasticsearch is the bottleneck.
The reindexing using the new BulkIndex operation uses only 4 Nuxeo threads (2 per nodes) and also saturates on elasticsearch it provides a similar throughput:
- 2048 docs/s or 373119 docs in 183s
The additionals seconds are probably due to the flush interval which may add up to 10s.
The monitoring is slightly different, the projection phase is fast ~1min where nuxeo and the db are a bit more solicited, but after on the pure indexing phase only elastic is loaded, nuxeo saturates easily elastic with less than 10% cpu (out of 400%)