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

Question: getLocalHost each event? #44

Open
lassic opened this issue Dec 21, 2014 · 3 comments
Open

Question: getLocalHost each event? #44

lassic opened this issue Dec 21, 2014 · 3 comments

Comments

@lassic
Copy link

lassic commented Dec 21, 2014

Hi,

I noticed that every time a EventDSL is constructed there is a call to getLocalHost, which on my AWS instance has an avg. of 10-20ms per call. It's not much per call perhaps, but accumulates when firing a lot of events.

Do you expect the machine's IP to change during the lifetime of the client? Shouldn't this at least be configurable? It seems like a waste calling this for each event if the IP doesn't change.

I can either submit a PR where I'm statically caching this once and reusing it in the constructor, or if you think this is how it should continue to work I can create a fork.

Thanks!

@aphyr
Copy link
Collaborator

aphyr commented Dec 21, 2014

Ah, the joys of the JVM, where getLocalHost makes a call to the DNS resolver, which, on EC2, means a bloody network call.

So we work around this in Riemann proper by a.) reading env-vars depending on platform, b.) shelling out to hostname(1), and c.) caching the result for a minute. https://github.com/aphyr/riemann/blob/master/src/riemann/common.clj#L35-L61. That's probably the right approach to port to the JVM client as well.

@lassic
Copy link
Author

lassic commented Dec 31, 2014

Cool, sorry for the long delay in response. When I get a chance I'll try the same approach and submit a PR.

@lassic
Copy link
Author

lassic commented Jan 1, 2015

Working on it now.

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