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

Remove delays on startup by caching the last few seconds of data by default #21

Open
sharpe5 opened this issue Feb 12, 2016 · 1 comment

Comments

@sharpe5
Copy link
Member

sharpe5 commented Feb 12, 2016

The only reason that the publisher and subscriber delay by up to a second on startup is to avoid issues on startup. We can avoid all of this by caching the last few seconds of data, until the sockets are properly set up. We could extend this by adding an API call like SubjectReplay(TimeSpan(FromSeconds(5)). We could cache by the seconds value, or the highwater mark, whichever is lower.

For this to work, the subscriber would have to request old values on startup, and the publisher would have to cache outgoing messages in RAM until the publisher is ready.

Ensure that there is always a cap on the number of messages held in RAM, as an easy way to bring down an entire server is for one process to gobble up all of the RAM.

The net effect of this behind-the-scenes magic is that everything just works. We can start the publisher first, then the subscriber, or vice-versa, and we can have reliable subscriptions that don't arbitrarily lose values because they happened to join a network a quarter of a second late.

@sharpe5
Copy link
Member Author

sharpe5 commented Feb 13, 2016

Relates to issue #12.

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

1 participant