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. H.264:FFMpeg 实现简单的播放器

    H.264:FFMpeg 实现简单的播放器   FFMPEG工程浩大,可以参考的书籍又不是很多,因此很多刚学习FFMPEG的人常常感觉到无从下手.我刚接触FFMPEG的时候也感觉不知从何学起. 因此我 ...

  2. CentOS系统中的passwd命令实用技巧小结

    这篇文章主要介绍了Linux系统中的passwd命令实用技巧小结,是Linux入门学习中的基础知识,需要的朋友可以参考下   先来回顾一下passwd命令的基本用法: Linux passwd命令用来 ...

  3. 详解ASP.NET Core Docker部署

    前言 在前面文章中,介绍了 ASP.NET Core在 macOS,Linux 上基于Nginx和Jexus的发布和部署,本篇文章主要是如何在Docker容器中运行ASP.NET Core应用程序. ...

  4. chrome调试技巧--持续更新

    1.开始调试:右键审查元素 2.按钮功能: 调出控制台: 切换开发环境全屏还是嵌入: 清空当前显示: 将压缩 js 文件格式化缩进规整的文件: 3.常用页面功能: 查看.编辑(双击)HTML: 查看选 ...

  5. 解析oracle的rownum

    本人最近在使用oracle的rownum实现分页显示的时候,对rownum做了进一步的分析和研究.现归纳如下,希望能给大家带来收获. 对于rownum来说它是oracle系统顺序分配为从查询返回的行的 ...

  6. 第五章 使用 SqlSession(MyBatis)

    在 MyBatis 中,你可以使用 SqlSessionFactory 来创建 SqlSession.一旦你获得一个 session 之后,你可以使用它来执行映射语句,提交或回滚连接,最后,当不再需要 ...

  7. 父div高度不能自适应子div高度的解决方案

    <div id="parent"><div id="content"> </div></div> 当conten ...

  8. 总结ASP.NET C#中经常用到的13个JS脚本代码

    1.按钮前后台事件 <asp:Button ID="Button1" runat="server" OnClick="Button1_Click ...

  9. linux环境下,清空history中记录的历史命令

    需求描述: 今天在数据库主机上操作,通过history看到有刚操作过的历史记录,想把这个清除了, 但是,还不影响后续的命令记录,所以查了下,在此记录. 操作过程: 1.通过history -c命令,完 ...

  10. hasattr() 、getattr() 、setattr()

    hasattr(object, name) :用于判断一个对象中是否有指定的属性或方法,如果存在返回 True,否则返回 False getattr(object, name, [default]) ...