1

I was wondering if anyone had actually used the official python elastic search ES client in the context of flask-socketio (with either eventlet / gevent + the monkey patches)?

The official python ES client is multi-thread safe, but that is not too much help in a single threaded async environment like flask-scoketio (+eventlet/gevent).

Would setting up an pool like eventlet has for db connections (eventlet/db_pool) be the way to go here?

Thanks -

Elrondy
  • 43
  • 1
  • 3
  • I haven't used these two together so I can't really give you an answer. But it would be fairly easy to test. Just take the official [examples](https://github.com/elastic/elasticsearch-py/tree/master/example) and try to run them with the std library monkey patched for eventlet to see what happens. Note that the threading isn't the main problem, you want to make sure the queues and sockets are all cooperative so that your app does not block while going off to talk to ES. – Miguel Grinberg Aug 19 '17 at 17:52
  • Thank you @Miguel, What i did was to run up a single instance of elastic search and with the monkey patched flask-socketio and py-elasticsearch opened up 2 connections to the elasticsearch instance and hammered it with requests. I then added some random eventlet.sleep() - to simulate blocking on one of the 2 connections just to make sure that there was no main thread blocking and worked. I dropped down to 1 connection and compared the performance against 2 connections and essentially i can see a 2x throughput. So on the face of it (non production!) it appears to be working famously. Thanks! – Elrondy Aug 23 '17 at 03:27

0 Answers0