Search code examples
elasticsearchopensearch

Is there anyway to check current bulk queue size Opensearch?


My Opensearch sometimes reaches the error "429 Too Many Requests" when writing data. I know there is a queue, when the queue is full it will show that error. So is there any Api to check that bulk queue status, current size...? Example: queue 150/200 (nearly full)


Solution

  • Yes, you can use the following API call

    GET _cat/thread_pool?v
    

    You will get something like this, where you can see the node name, the thread pool name (look for write), the number of active requests currently being carried out, the number of requests waiting in the queue and finally the number of rejected requests.

    node_name       name   active queue rejected
    node01          search      0     0        0
    node01          write       8     2        0
    

    The write queue can handle as many requests as 1 + number of CPUs, i.e. as many can be active at the same time. If active is full and new requests come in, they go directly in the queue (default size 10000). If active and queue are full, requests start to be rejected.

    Your mileage may vary, but when optimizing this, you're looking at:

    • keeping rejected at 0
    • minimizing the number of requests in the queue
    • making sure that active requests get carried out as fast as possible.

    Instead of increasing the queue, it's usually preferable to increase the number of CPU. If you have heavy ingest pipelines kicking in, it's often a good idea to add ingest nodes whose goal will be to execute that pipeline instead of on the data node.