I'm creating a TransportClient instance in elasticsearch. Below is the code for the same. The issue is I'm trying to lower the number of threads spawned with the threadpool that TransportClient initiates. But what ever settings I use my elasticsearch always initialing the threadpool with 12 threads. Please let me know how to configure the same to get the desirable threads.
public static TransportClient getTransportClient(String ip, int port) {
ImmutableSettings.Builder settings = ImmutableSettings
.settingsBuilder();
settings.put("cluster.name", "elasticsearch");
settings.put("threadpool.bulk.type", "fixed");
settings.put("threadpool.bulk.size" ,5);
settings.put("threadpool.bulk.queue_size", 5);
settings.put("threadpool.index.type" , "fixed");
settings.put("threadpool.index.size" , 5);
settings.put("threadpool.index.queue_size" , 10);
settings.put("threadpool.search.type", "fixed");
settings.put("threadpool.search.size" ,5);
settings.put("threadpool.search.queue_size", 5);
settings.build();
TransportClient instance = new TransportClient(settings)
.addTransportAddress(new InetSocketTransportAddress(ip, port));
return instance;
}
Elasticsearch ThreadPool Test. Thread pools are a collection of threads which are made available to perform specific tasks in the Elasticsearch cluster. A single Elasticsearch node holds multiple thread pools for different operations such as search, indexing, bulk operations, and more.
You can use multi thread, this is exactly why elasticsearch is good for: parallelism. An elasticsearch index, is composed of shards, this is the physical storage of your data. Shards can be on the same node or not (better).
The size of a thread pool is the number of threads kept in reserve for executing tasks. It is usually a tunable parameter of the application, adjusted to optimize program performance. Deciding the optimal thread pool size is crucial to optimize performance.
Try
Settings settings = ImmutableSettings.settingsBuilder()
.put("transport.netty.workerCount",NUM_THREADS)
.build();
Credit to JanuZ, taken from http://www.lucidelectricdreams.com/2013/11/reducing-number-of-threads-created-by.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With