10

We are using Locust to for load testing rest api services behind elastic load balancing. I came across this article regarding load balancing and auto scaling, which is something we are testing.

Locust is using python-requests which is using urllib3, so my question is if python-requests does a dns query for every connect, and if not, is it configurable?

djonsson
  • 563
  • 4
  • 14
  • Urllib3 is probably using `socket.getaddrinfo` which should be using the `getaddrinfo` of the OS you are using according to this [answer](http://stackoverflow.com/a/16621318/6061947) on another SO question. So it should cache the results depending on the OS for each subsequent request to the same hostname. – Cory Shay Mar 18 '16 at 16:41
  • And according to this question: http://stackoverflow.com/questions/11020027/dns-caching-in-linux caching is disabled on most Linux configurations. – djonsson Mar 19 '16 at 11:50

2 Answers2

4

Locust is using python requests that is using urllib3 that is using socket.getaddrinfo which has DNS caching disabled according to this SO thread (given that your test machine runs linux).

Community
  • 1
  • 1
djonsson
  • 563
  • 4
  • 14
0

python-requests does a dns query for every connect.

To disable this you can use a dns cache.

Now you can enable systemd-resolved with systemctl enable systemd-resolved

more info - https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html

Tal Folkman
  • 2,013
  • 1
  • 2
  • 17