Use multiple threads to send data to Elasticsearch to speed up reindex for larger clusters.
Product.reindex(concurrency: 4)
I added this in the threads branch. However, in the benchmarks on my machine, it's not faster. Still trying to identify the bottleneck, but happy if others want to help.
git clone https://github.com/ankane/searchkick.git
cd searchkick
git checkout threads
BUNDLE_GEMFILE=benchmark/Gemfile bundle
BUNDLE_GEMFILE=benchmark/Gemfile bundle exec rake benchmark
Think it has to do with thread scheduling. New direction: will try to do parallel requests with Faraday + Typhoeus.
In performance benchmarks, Ruby code to query the DB and generate search data is the biggest bottleneck. Using ActiveJob to parallelize this across multiple processes / machines (not just threads) is best, but requires some orchestration.
^ Done. Check out https://github.com/ankane/searchkick#large-data-sets
That link is now https://github.com/ankane/searchkick#parallel-reindexing
Most helpful comment
^ Done. Check out https://github.com/ankane/searchkick#large-data-sets