uwazi
uwazi copied to clipboard
Server performs requests to itself on SSR
SSR uses client api to request for the initial data instead of getting the data from the server app itself. this has some problems that i have detected.
- It is slower.
- It creates more requests handles in the server.
- It throws errors when performing a gracefull shutdown (a request can be in the SSR stage before the gracefull shutdown, when the ssr stage starts with the requests to the api the server is already not accepting connections, throwing errors).
There are 2 different places where this requests happen.
The first one is probably the easier to solve since its full server code, its the initial data every page needs to be rendered, this is the only one i have made some measurements locally changing all requests to application gets with as much a 20% performance improvement.
https://github.com/huridocs/uwazi/blob/2a449a202feab197f18744c2cae702b364244273/app/react/entry-server.tsx#L122-L139
The second one is the client itself, we use a requestState static function on our client routes and the same exact function for server side rendering, i have not tested changing this one or the impact it could have on performance.
https://github.com/huridocs/uwazi/blob/2a449a202feab197f18744c2cae702b364244273/app/react/entry-server.tsx#L160-L220