This repository has been archived by the owner on Dec 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 141
(perf) consume streams in parallel and flush them in series #256
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
affa999
to
eea9995
Compare
Codecov Report
@@ Coverage Diff @@
## master #256 +/- ##
=========================================
Coverage ? 99.54%
=========================================
Files ? 17
Lines ? 665
Branches ? 126
=========================================
Hits ? 662
Misses ? 3
Partials ? 0
Continue to review full report at Codecov.
|
ruiaraujo
reviewed
Sep 7, 2018
@ruiaraujo Its ready for review. |
ruiaraujo
reviewed
Sep 10, 2018
👍 |
1 similar comment
👍 |
mo-gr
approved these changes
Sep 10, 2018
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously we were consuming and processing the fragment streams in order they were declared in the template. This PR does the following things
Consume the fragment streams on fragment buffer in parallel and process them in series while flushing them in to the client to guarantee the order in which fragments are declared on the page.
This would ideally improve the time to last byte and latency. Check benchmarks below.
Note: One caveat might be increase in the memory usage of the application since we are buffering the response. We are clearing the buffer once the stream is written to the output stream, But it might be a issue if fragments are sending huge data. We can figure this out and warn by listening on
fragment:response
event which has the size of responseBenchmarks
In order to show the clear picture of the results, I created a dummy fragment server which creates known delays in producing the response so its easy to compare with before and after the changes
The following changes are made to reduce the influence of other code in the benchmarks
Ran load test with 100 req/sec for 30 seconds
Before
After
Huge thanks to @watson for the idea 👍