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

Improve streaming /order_book endpoint #644

Closed
tomquisel opened this issue Sep 10, 2018 · 2 comments
Closed

Improve streaming /order_book endpoint #644

tomquisel opened this issue Sep 10, 2018 · 2 comments
Assignees
Labels

Comments

@tomquisel
Copy link
Contributor

tomquisel commented Sep 10, 2018

It looks like Horizon's streaming /order_book endpoint is unaware of changes to the data. It sends the entire orderbook every second over the eventstream.

Check out the Stellar Lab for an example.

Ideally it could do one of the following:

  • Only transmit the entire orderbook when there's a change to the orderbook
  • Even better, transmit a list of added & removed bids + asks when a change occurs
  • Best of all, compute both and transmit whichever is shorter

Either way, it could be rate limited to send at most an update every 200ms (configurable), to avoid flooding the client with a very busy order book.

@bartekn @tomerweller

@bartekn
Copy link
Contributor

bartekn commented Sep 11, 2018

Good idea, I think I vote for:

  • Only transmit the entire orderbook when there's a change to the orderbook

it's easy to check the difference in the client side (especially in React apps where you can simply push a new state to the app) and sending a diff would complicate this endpoint a lot.

I think along this change we could also keep a local cache of each active order book (that has listening clients) and send updates if there is a change. Then even if there are thousands of listening clients to a single order book it will only send a single DB query every X seconds. This still will be a bit slow if you send many requests to different order books but given there are only a few popular markets (so far) it will largely improve performance.

But first, let's check if we can optimize the GetOrderBookSummary query to be faster.

I'm adding this to Horizon 0.14.X milestone as it's a performance fix but would be really great to have this.

Either way, it could be rate limited to send at most an update every 200ms (configurable), to avoid flooding the client with a very busy order book.

There will be no changes between ledgers so this can be updated every new ledger (2-5 sec.).

@bartekn bartekn added this to the Horizon v0.14.x - patch releases milestone Sep 11, 2018
@howardtw howardtw self-assigned this Jan 12, 2019
@bartekn bartekn modified the milestones: Horizon patch releases, Horizon v0.16.0 Jan 29, 2019
@howardtw
Copy link
Contributor

Closed by #828

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants