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

Add backoff strategy and max queue size #4

Conversation

Looooopy
Copy link
Contributor

Problem before:

  1. If the logserver goes down the client keeps sending requests with an interval of 0ms, resulting in unnecessary network traffic and a performance hit on the client.
  2. The message queue grows on the client when the logserver is down and we do not want the browser to crash or become unresponsive.

Our Solution:

  1. Add a support for using a backoff strategy. We start on an interval of 1ms and the interval is doubled with each failed attempt until we reach an interval of 30s. Requests are then continiously made in 30s intervals. Unpon a successful request the interval is reset to 1ms.
  2. Add a max queue size. We set a default max queue size of 500 items. When the queue’s max size is reached we start dropping the oldest message in queue before pushing a new one onto the queue.
    So in case of a logserver outage, only the 500 most recent messages (stored in the queue of the the client) will be sent to the logserver once it becomes available again.
    2.1 Add ability to do something with dropped messages in a callback function, e.g) (msg) => console.log(msg)

kristofferahl and others added 3 commits September 27, 2017 14:02
…ched.

* Optional callback called when a message is dropped.
* Set default timeout of 1ms for sending message.
* Each time we get a response other then HTTP 200, the timeout is doubled.
* A max timeout of 30 seconds is used and the first successful message will reset the timeout to 1ms.
@Looooopy
Copy link
Contributor Author

We know that you merged our previous pull request.

  • Thanks!

Let us know if you need us to rebase our new pull request with the changes you made!

@kutuluk kutuluk changed the base branch from json to backoff September 28, 2017 13:52
@kutuluk kutuluk merged commit dd28c1b into kutuluk:backoff Sep 28, 2017
@kutuluk
Copy link
Owner

kutuluk commented Sep 28, 2017

No need =)

@kutuluk
Copy link
Owner

kutuluk commented Sep 29, 2017

2.1 Add ability to do something with dropped messages in a callback function, e.g) (msg) => console.log(msg)

console.log(msg) will be called in any case by the loglevel. Is it really necessary to have an onMessageDropped handler? I just do not want to complicate the API without the urgent need.

@kutuluk kutuluk mentioned this pull request Sep 29, 2017
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.

None yet

3 participants