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

REST API blocking async: Solution A, block_in_place #56

Merged
merged 3 commits into from
Mar 6, 2024

Conversation

junderw
Copy link
Member

@junderw junderw commented Oct 2, 2023

I found something in electrs that could greatly increase the stability of the REST API response times. It's an extremely simple fix.

However, there are 2 ways to fix the problem, and they both have tradeoffs and it depends on the number of threads, the number of incoming requests per threads, etc. as to which of the solutions is better for performance.

Knowing how many threads prod uses, and how many requests / second on average it processes will change which solution is best.

If we have N threads waiting to accept requests, and at any given time there are less than N requests being processed, solution A is better.
If we have 5 x N or 10 x N requests waiting to be processed at any given time, solution B is better.
However, anything in between would need to A/B test to figure out which one is better.
There's also a possibility (if the number of requests being processed at any given time never reaches anywhere near N requests ( like 10% of N etc.) that this change won't increase performance a lot.
So I was wondering if at some point we could try an A/B/C test with the A: Solution A, B: Solution B, and C: No changes... and see if latency changes at all.

Out of curiosity, have you felt like the REST API's response time latency is unstable with a lot of variance?

@junderw junderw force-pushed the junderw/use-blocking-spawn branch from fb73e2f to 83301a2 Compare October 3, 2023 04:49
Copy link
Contributor

@mononaut mononaut left a comment

Choose a reason for hiding this comment

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

Tested ACK @ 94cfe27

@wiz
Copy link
Member

wiz commented Mar 5, 2024

Two-Buttons

@mononaut
Copy link
Contributor

mononaut commented Mar 5, 2024

pasting in my earlier recommendations below - I marginally preferred solution A when I reviewed the two PRs, but if we can test real performance in production/staging that would be even better.

merge #58 first, then test #56 and #57 separately in production and compare performance.
otherwise just pick one: both are improvements, and the difference doesn't seem that large testing under heavy load (but I'd lean towards solution A, #56)

@wiz wiz merged commit f85bf8a into mempool Mar 6, 2024
7 checks passed
@wiz wiz deleted the junderw/use-blocking-spawn branch March 6, 2024 07:26
SatoKentaNayoro pushed a commit to boolnetwork/mempool-electrs that referenced this pull request Nov 29, 2024
REST API blocking async: Solution A, block_in_place
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.

3 participants