I would recommend using the official client instead of Axios. You can configure a custom keep-alive agent easily:
const { Client } = require('elastic/elasticsearch')
const Agent = require('agentkeepalive').HttpsAgent
const client = new Client({
cloud: { id: 'id' },
auth: { username: 'username', password: 'password' },
agent () {
return new Agent({
timeout: 500,
maxFreeSockets: 10,
maxSockets: 100,
freeSocketTimeout: 500,
socketActiveTTL: 1000 * 60 * 10
})
}
})
Regarding the queue system, I would recommend using p-queue instead.