NicolasLM / sauna

Lightweight daemon that runs and reports health checks
https://sauna.readthedocs.io
BSD 2-Clause "Simplified" License
18 stars 10 forks source link

Reuse HTTP session (make it configurable) #69

Closed xavierhardy closed 6 years ago

xavierhardy commented 7 years ago

To improve HTTP request performance, you should avoid re-opening a new HTTP session each time (or at least add an option to make this configurable). With requests, instead of calling requests.request, you could create a Session object and keep it open for each call.

NicolasLM commented 7 years ago

Hey thanks for the tip.

However one core point in Sauna is that checks are independent from each others. It would be weird for a check being run now to be impacted by a check that ran 1 minute ago. This is what sessions do, they keep state between requests.

Moreover there are some thread safety issues to take into account as checks can be run by different threads and Session objects are not thread safe.