Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with localhost and domain configured in hosts file #96

Closed
dradford opened this issue Sep 17, 2013 · 2 comments
Closed

Issues with localhost and domain configured in hosts file #96

dradford opened this issue Sep 17, 2013 · 2 comments

Comments

@dradford
Copy link

Hi there, I've been using Locust.io for a couple of weeks in my day job and it's really helped us nut out a couple of big performance issues, so thank you for the awesome application.

I've decided to start using it to load test some behaviour scenarios with my own personal project and just wanted to start getting things right on my local dev server, however I've hit a slight snag:

Both the app server and Locust are running on my laptop (app server is a Flask app running behind Gunicorn at 127.0.0.1:5000), I've defined a hostname in /etc/hosts which is local-cms-server.app.co resolving to 127.0.0.1. I have a local instance of nginx listening on port 80 for that hostname and proxying to the app server.

Locust is configured to connect to that hostname, however I get 100% of requests dying with a DNS Error.

I've tried a plain request to the above hostname with the Python requests library and it works. I've also tried setting Locust to connect to http://127.0.0.1:5000 and it works fine.

Everything seems to work correctly with that hostname except Locust. I was wondering if something weird is going on behind the scenes in the Locust HTTPClient trying to resolve the hostname to IP. I've seen a similar (not exactly the same) issue raised with requests+gevent over here https://github.com/kennethreitz/requests/issues/1202, however I'm not sure if I should start heading down that route until I'm sure it's not something to do with my config.

Wondering if anyone here has seen something similar?

Thanks,
Damo

@heyman
Copy link
Member

heyman commented Sep 17, 2013

Hi!

I think this is caused by an issue with gevent's DNS (see gevent/gevent#87). Maybe you can configure nginx to not care about the hostname, and make Locust go directly against your IP? Or you could make locust use your IP directly, and manually set the Host header when you make the requests.

Another options is to upgrade to gevent 1.0 (pip install https://github.com/surfly/gevent/releases/download/1.0rc3/gevent-1.0rc3.tar.gz), which should fix DNS issues. However, note that even though Locust should work with gevent 1.0 it hasn't been as tested as with gevent 0.13.

Overall, I've seen weird DNS errors when using gevent (0.13) so I try to avoid DNS lookups in my locust tests, and instead set the Host header where it's needed.

@dradford
Copy link
Author

Thanks Heyman,

Just to confirm, I did track this down to a call in gevent's DNS resolution method in version 0.13. Upgrading to 1.0rc3 worked. I'm going to downgrade back to 0.13, bypass the hostname and use the Host header.

Thanks for your suggestions,
Damo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants