In this toolkit, you can test the approximate latency of Lucene index update.
In contrast to regular indexes (Wired Tiger Indexes) in MongoDB, Lucene search indexes are asynchronously updated. Therefore, you might see stale data, if you immediately query just after you've written.
- It's been tested succesfully on Amazon Linux 2, with the node version
v17.1.0
and npm version8.1.2
.
- After you've successfully installed
node
andnpm
on the machine, clone this repository and run the following command to install dependent librariesnpm install
- Provision an M30 Atlas Cluster in the region closest to the location where the script is going to be executed.
- Load Sample Data into the cluster.
- Create a dynamic index on the collection
movies
in thesample_mflix
database. Result should be similar to below.
- Change the
connectionString
variable in thelatency_test.js
accordingly.
- In every step script generates a random string and updates a field in the collection and that field is also in the search index.
- Depends on the variable
numberOfUpdatesPerIteration
, 1 or more documents can be updated. _id
fields of the updated documents were stored temporarily.
- Depends on the variable
- After
updateMany
successfully executed,$search
query executed with thephrase
search to match generated random string.$search
query is executed until it returns all the updated documents in theupdateMany
stage.
- Locate the folder where the script in place
- Run the following:
node latency_test.js
- Change the db/collection name accordingly in the config part of the script
- Change the index name and field to be updated properly.
- You can update multiple fields rather than one field as in this script and re-evaluate the latency values
- This is only one single thread therefore you can run multiple node process concurrently and re-evaluate the latency values
- If you increase number of updates per iteration, you may see higher latencies.
- e.g.
var numberOfUpdatesPerIteration=1000
- e.g.