Skip to content

Add backoff to stream reconnect#62

Merged
drichelson merged 2 commits into
masterfrom
dr/initImprovements
Nov 3, 2016
Merged

Add backoff to stream reconnect#62
drichelson merged 2 commits into
masterfrom
dr/initImprovements

Conversation

@drichelson

@drichelson drichelson commented Nov 2, 2016

Copy link
Copy Markdown
Contributor

Initial changes to initialization. This attempts to address the fact that we aggressively retry streaming connections. There are other improvements to make, but this one is bite-sized and has other corrections as well.

We're also now properly reporting that the client is initialized or not.

Comment thread ldclient/client.py
events_uri='https://events.launchdarkly.com',
connect_timeout=2,
read_timeout=10,
connect_timeout=10,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were lower than what we've seen in the field (5 seconds just for dns lookup) so I'm upping them here.

Comment thread ldclient/client.py
update_processor_ready.wait(start_wait)

if self._update_processor.initialized:
if self._update_processor.initialized() is True:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was not evaluating correctly.. it would indicate success even when the streaming processor had not been initialized.

Comment thread ldclient/streaming.py Outdated
if message_ok is True and self._ready.is_set() is False:
self._ready.set()
except HTTPError as e:
if e.response is not None and e.response.status_code is not None:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now stop the reconnect loop if a 4xx response code is seen.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which begs the question- is it possible for a 404 error to be transient? due to a misconfigured/misbehaving CDN?

@drichelson drichelson changed the title Initial changes to initialization [HOLD] Initial changes to initialization Nov 2, 2016
@drichelson drichelson changed the title [HOLD] Initial changes to initialization Add backoff to stream reconnect Nov 2, 2016
@pkaeding

pkaeding commented Nov 3, 2016

Copy link
Copy Markdown
Contributor

This definitely looks good. It might also be worth not retrying at all when we get a status in the 4xx range, since retrying the same request should result in the same status.

@drichelson drichelson merged commit 44573be into master Nov 3, 2016
@drichelson drichelson deleted the dr/initImprovements branch November 3, 2016 22:05
eli-darkly added a commit that referenced this pull request Jun 19, 2018
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

Successfully merging this pull request may close these issues.

2 participants