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

Slow and repeated network calls during ec2 functions #59

Closed
1 of 2 tasks
hairyhenderson opened this issue Sep 2, 2016 · 0 comments · Fixed by #61
Closed
1 of 2 tasks

Slow and repeated network calls during ec2 functions #59

hairyhenderson opened this issue Sep 2, 2016 · 0 comments · Fixed by #61
Labels

Comments

@hairyhenderson
Copy link
Owner

hairyhenderson commented Sep 2, 2016

If I run a few ec2* functions on my laptop, usually it times out in ~5s and then subsequent calls are fast. But for some reason there are some environments where this doesn't happen, for example CircleCI, which does run in EC2, but they clearly restrict access to the EC2 APIs.

For example, running in a CircleCI debug session:

$  time (echo '{{ec2region}}{{ec2region}}{{ec2region}}' | ./gomplate)
unknownunknownunknown

real    0m15.011s
user    0m0.007s
sys 0m0.004s
$ time (echo '{{ec2tag "foo"}}' | ./gomplate)

real    0m10.279s
user    0m0.010s
sys 0m0.006s

I think the right approach is to do 2 things:

  1. make an initial call to the EC2 Instance Metadata API, and track success - short-circuit further ec2 functions to use defaults after that (Short-circuit ec2 function defaults when not in AWS #60)
  2. cache EC2 API calls to the same URLs so that we don't needlessly make repeated calls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant