When dealing with a large number of parallel operations in elasticsearch, such as search requests or bulk indexing operations, you may encounter thread pool related errors. Here we explain thread pools and discuss a typical search request thread pool error that might be faced, as well as how to handle such issues.

Thread pools

Thread pools are a collection of threads which are made available to perform specific tasks in elasticsearch. The main goal of thread pools is to make the memory management easier by managing the life-cycles of the threads when it comes to executing large number of requests.

A single node in elasticsearch holds several thread pools for different operations such as search, indexing, bulk operations, and more. Most thread pools are associated with a queue whose purpose is to deal with pending requests. For ease of understanding, let's consider the search thread pool and discuss more about the concept and structure.

Search Thread Pools

Search operations in elasticsearch have a dedicated search pool and an associated queue for each node. The thread pools will have "N" workers, which accept the requests. The number of workers is equal to the number of cores in that node. These N workers can accept a total of N search requests at a time. The number of workers is determined by the number of cores the node is equipped with.

Thread pool queues are deployed when request numbers are exceeded. The default size of the search queue is 1000, and the requests which exceed the thread pool worker numbers are queued in here.

We're Looking For Contributors For Our Open Source Container Orchestration Software Supergiant. Care To Check It Out?

The below picture shows the search thread pool and its queue existing in a single node.  The first set of requests are handled by the "search thread pool" with its "N" workers. The next set of search requests go to the search queue whose default size is 1000.

Requests Exceeding Limits

What happens when requests exceed the number of workers and search queue size? As in the figure shown below, if the number of parallel requests are more than the thread pool and the queue can handle, Elasticsearch throws an exception error.

Solutions

There are a few solutions that can be applied, according to the use case to solve the request, which include:

  1. Increasing the size of the thread pool. We can increase the size of the thread pool by setting the "threadpool.search.size" parameter. But, it will affect the query speed performance.
  2. Increasing the size of the search queue. The ideal and most common practice is increasing the search queue size. It should be noted that the search queue resides in the memory. Increasing it extensively can lead to out-of-memory exception errors.
  3. Increasing the nodes and replicas. This issue is caused by the overload of parallel requests, depending on use case. This method is rarely employed.
  4. Changing input data to serial data. This less popular method is used to serialize the data. This method depends on the use case and is employed only if the query performance is not considered.

Conclusion

In this post we discussed search thread pools and the exception errors that might incur in the case of multiple requests. We also explained solutions for the exception errors thrown in cases of multiple requests. Questions/Comments? Drop us a line below.

随机推荐

  1. node.js执行shell命令

    nodejs功能强大且多样,不只是可以实现 服务器端 与 客户端 的实时通讯,另一个功能是用来执行shell命令 首先,引入子进程模块 var process = require('child_pro ...

  2. C++字符串类型和数字之间的转换

    转载:http://www.cnblogs.com/luxiaoxun/archive/2012/08/03/2621803.html 1.字符串数字之间的转换 字符串---字符数组(1)string ...

  3. 获取pc硬件信息杂记

    //Download by http://www.NewXing.com #include "StdAfx.h" #include "RegUtil.h" #i ...

  4. Invalidate()函数

    Invalidate( ) :使整个窗口客户区无效, 并进行更新显示的函数 介绍 void Invalidate( BOOL bErase = TRUE ); 参数: bErase 决定了是否要在WM ...

  5. python--数据类型--1

    原创博文,转载请标明出处--周学伟http://www.cnblogs.com/zxouxuewei/ 视频教程::http://www.imooc.com/learn/177 http://www. ...

  6. 微信jssdk批量添加卡券接口(踩坑经验)

    1)首先是官方接口文档: 1.批量添加卡券接口:https://mp.weixin.qq.com/wiki?action=doc&id=mp1421141115&t=0.0861973 ...

  7. 批量执行命令:fabric

    Fabric 可以通过 SSH 在多台客户端主机上批量执行任务,是基于 paramiko 封装开发的,paramiko 更底层一些,安装方法如下: [root@localhost ~]$ yum in ...

  8. Android储存

    Android储存一共5种方法 一: 手机内置,外部储存 1.获取本地存储 (Android的读写文件及权限设置) getFilesDir()   data/data/包名/File getCache ...

  9. thinkjs——redis

    前言: 后台某些操作的时候会用到缓存:比如用户登录或者校验次数的情景.而本次遇见的状况就是在点击“推送”按钮的时候,需要判断缓存中是否有其值,并将其次数限制为固定值. 过程: 刚听到此需求的时候,首先 ...

  10. MyBatis官方文档——入门

    入门 安装 要使用 MyBatis, 只需将 mybatis-x.x.x.jar 文件置于 classpath 中即可. 如果使用 Maven 来构建项目,则需将下面的 dependency 代码置于 ...