Test scenario 1:SSR cache option not activated, low concurrency
SSR optimization engine setting:
const ngExpressEngine = NgExpressEngineDecorator.get(engine, { timeout: 10000, debug: true, concurrency: 2,
forcedSsrTimeout:30000,
maxRenderTime:40000 });
jMeter setting:sending 10 requests for the same page simultaneously
Test result:
The 9 requests get CSR fallback result;
The last request gets SSR result
CSR fallback observed in the backend:
Test scenario 2:SSR cache option activated, low concurrency
SSR optimization engine:
const ngExpressEngine = NgExpressEngineDecorator.get(engine, { timeout: 10000, debug: true, concurrency: 2,
forcedSsrTimeout:30000,
maxRenderTime:40000,
cache:true, cacheSize: 20 });
When I send the first group of 10 requests, the same test result as Scenario 1.
And when I send the second group of 10 requests, all those 10 results are served by cached SSR result.
Test scenario 3:SSR cache option not activated, high concurrency
SSR Optimization engine:
const ngExpressEngine = NgExpressEngineDecorator.get(engine, { timeout: 10000, debug: true, concurrency: 20,
forcedSsrTimeout:30000,
maxRenderTime:40000});
Test result: the same as scenario 1.
Test scenario 4:SSR cache option activated, high concurrency
SSR Optimization engine:
const ngExpressEngine = NgExpressEngineDecorator.get(engine, { timeout: 10000, debug: true, concurrency: 20,
forcedSsrTimeout:30000,
maxRenderTime:40000,
cache:true, cacheSize: 20 });
Test result is exactly the same as in scenario 2:
Test scenario 5:SSR cache option activated, high concurrency, enlarge timeout value
SSR optimization engine:
const ngExpressEngine = NgExpressEngineDecorator.get(engine, { timeout: 90000, debug: true, concurrency: 20,
forcedSsrTimeout:90000,
maxRenderTime:100000,
cache: true, cacheSize: 10});
Test result is the same as in scenario 2.
Conclusion
-
When a lot of requests for the same page reach SSR server simultaneously, only the request which picked up first by SSR server ( let's call it request A) can succeed SSR process, all other requests will fall back CSR due to the rendering flag in SSR Optimization engine.
-
Enlarging timeout or maxRenderTime value will NOT change above behavior.
-
If cache option is applied, the situation could be mitigated to some degree, that is, as long as one request is finished by SSR successfully, all other subsequent request on the same page could be directly served by cached result ( see scenario 2,4,5)
更多Jerry的原创文章,尽在:"汪子熙":
网友评论