-
Notifications
You must be signed in to change notification settings - Fork 276
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
Call setSitecoreContext silently during SSR #402
Conversation
…path and a new hash the new page isn't being retrieved (Sitecore#373)
@erzr I think, in this case subscribers will not be called in server side at all, am I right? Seems that it's correct. |
@aweber1 @nickwesselman @kamsar @erzr Guys, please, look at my comment, maybe you can advice something. I propose to re implement
|
Theoretically you could use the And are we saying we somehow end up w/ more than one subscriber in SSR though with usage in the sample app, and thus multiple calls to Regarding the need for this in SSR, a use case to test would potentially be use checking the page mode to display something only when in the Experience Editor. Is that page mode accurate if we disable the update to the subscribers? |
I tested it and understood, that we can't do such changes.
Try to open page directly: |
Looks like we are leaking subscribers because |
@nickwesselman You are right. I was thinking about it. So it's a cause, why i'm trying to get rid of subscribers and try to use one subscriber. I'm preparing PR, I'll notify you, when I'll open it. I tried to build flame graph when I use one subscriber and it's totally different, SitecoreContext doesn't hot. And yes, I logged subscribers on server side, it cannot be unsubscribed. You can look at: https://itnext.io/tips-for-server-side-rendering-with-react-e42b1b7acd57
|
Opened PR related to my idea: #414 |
I close this PR, as have already merged #414 that includes refactoring of SitecoreContext, that fixes memory leak issue |
During some profiling Server-Side Rendering of the sample application
setSitecoreContext
stood out quite a bit and it seems like that when setSitecoreContext is called with the initial SSR state, this triggers subscribers to be called, which ends up calling forceUpdate.This doesn't seem to be necessary during SSR and skipping the notification of subscribers seems to increase throughput of SSR by ~30% in my testing:
Before:
After
This could use some test coverage, which I can add if this change is adopted. Open to any/all questions here.
Motivation
Increase performance of Server-Side Rendering.
How Has This Been Tested?
Limited local testing, using https://artillery.io/ to simulate load against proxy.
artillery quick --count 100 -n 20 http://localhost:3000
Types of changes
/docs
directory)Checklist: