From 3ce69524dc95bb450204ba2b8e82ee69af3af833 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Thu, 20 Oct 2022 22:31:23 +0200 Subject: [PATCH] set requestTimeout to 500ms for ES queries (#31929) --- middleware/api/es-search.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/middleware/api/es-search.js b/middleware/api/es-search.js index b31e31a5f2..4b73c2625d 100644 --- a/middleware/api/es-search.js +++ b/middleware/api/es-search.js @@ -15,6 +15,14 @@ function getClient() { } return new Client({ node: ELASTICSEARCH_URL, + // The default is 30,000ms but we noticed that the median time is about + // 100ms with some occasional searches taking multiple seconds. + // The default `maxRetries` is 5 which is a sensible number. + // If a query gets stuck, it's better to (relatively) quickly give up + // and retry. So if it takes longer than this time here, we're banking on + // that it was just bad luck and that it'll work if we simply try again. + // See internal issue #2318. + requestTimeout: 500, }) }