简体   繁体   中英

Elasticsearch-py what happens to connection attempt if ES server is down?

Suppose I have a webserver that fetches some data from ES.

When ES goes down, there will be many clients requests that will fetch data from ES and there will be many connection timeout.. (Suppose every client requests need some data from ES so web server should fetch data from ES)

Does it affect the server's responsiveness in any way?

Could it make server unresponsive ?

Your code will be stuck and be waiting for a response from ELasticsearch, it won't make server unresponsive. You can add a timeout field which will timeout the request. This timeout can be used while initializing the client object and it can also be sent while executing a query from elasticsearch client object. Below is the code:

from elasticsearch import Elasticsearch
conn = Elasticsearch(URL, timeout = TIMEOUT_IN_SECS )

and

conn.search(index=INDEX, body= QUERY_BODY, request_timeout=TIMEOUT_IN_SECS)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM