Hi, For both elasticsearch and redis python clients you should just have one instance and keep reusing it.
If you create new ones there will be some connections left hanging (though gc should pick them up) but also both your app and elasticsearch itself will be paying tthe overhead of creating and maintaining additional connections, which is not good. Hope this helps, Honza On Fri, Mar 27, 2015 at 8:09 PM, Yogesh <bindasyog...@gmail.com> wrote: > Hi, > > I am using the Python Elasticsearch API > <http://www.elasticsearch.org/guide/en/elasticsearch/client/python-api/current/> > to interact with ES in my Python Flask application (server is Python > Tornado). Currently, as soon as the app gets a new user request, it does > esclient = Elasticsearch("127.0.0.1") and then uses this esclient to search > for the required data. But I recently read that ES has persistent > connections. So, > > 1. Should I save the esclient somewhere and reuse it instead of doing > esclient = Elasticsearch("127.0.0.1") for every request? > 2. Would there be some resource leak if I forget about esclient after > the request and open a new one every time? Is there a way to close this > open connection? > > I am also doing the same for another db, Redis in my app. Sorry, might > seem like a basic question but I am a bit confused. > > Thanks-in-advance! > > -- > You received this message because you are subscribed to the Google Groups > "elasticsearch" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to elasticsearch+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elasticsearch/19d47985-087f-41c1-b524-1f6ac26fd63c%40googlegroups.com > <https://groups.google.com/d/msgid/elasticsearch/19d47985-087f-41c1-b524-1f6ac26fd63c%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Honza Král Python Engineer honza.k...@elastic.co -- You received this message because you are subscribed to the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAC4VrtwsJoVmw1C-2wixjOcvu2722JRcsqtAdC6ZpgwXs3Vjqg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.