-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
React renderToString / renderToStaticMarkup blocking event loop #368
Comments
Great data, @dmitrif, thank you. |
@dmitrif Thanks! For future reference the issue seems to be tracked here facebook/react#1739. |
It exists a project react-dom-stream to do not block the loop. |
@renholm Not sure if it fixes the same issue as the operation even in a promise would ultimately be part of the event loop, correct? |
@AbrahamAlcaina Very interesting. Will investigate further. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
React
renderToString
&renderToStaticMarkup
are blocking the event loop and therefore delaying further requests.This is not noticeable when the # of requests is in the lower range, but problematic at larger scales. Last request to come in has to wait for all previous requests to render before being able to do the same, resulting in the 90th and 99th percentile of request response times to be abnormally high.
For example, with 1000 requests with concurrency level 1 (production mode):
The variance is fairly small, with the requests being processed at approximately the same speed across the board.
Now with concurrency level 20:
As you can see the variance is dramatically higher. The minimum response time is 54, meanwhile the 50th percentile is already at 292ms.
A partial solution that seems to work is to schedule data fetches on nextTick along with the final renders, giving a chance to all requests to run "concurrently".
The react team seems to be aware and mentioned that they are concentrating on server-side rendering speeds / optimizations in the next six months.
The text was updated successfully, but these errors were encountered: