How can I improve React.Net / SuperchargedReact server-side rendering performance for concurrent requests?

时间:2015-12-15 01:19:22

标签: performance clearscript

I am experimenting with server-side rendering of React components from within a ASP.NET website using both React.Net and SuperchargedReact implementations.

My initial load test results show that a single request can be handled reasonably quickly (circa 100ms) but that performance quickly degrades under concurrent requests (> 4 seconds). Details below.

It's probably I'm not using these tools to their potential and testing was cursory, but I need some advise on where to start on improving performance.

Questions

  1. Roughly what level of concurrency should I expect? E.g. Is concurrency limited to the number of javascript engine instances I can hold in memory. Or is it dependent on the number of IIS worker processes. Or something else.

  2. Where should I start looking to improve performance - tips? tricks? resources?

  3. What could explain SuperchargedReact underperforming React.Net when it supposedly implements a number of performance improvements.

Testing Details

I constructed a js bundle from ES6 sources via browserify/babelify/gulp-minify. Then the react components were exposed via global variables. The react-router was not included and some small modifications were made to SuperchargedReact to get it working without the router.

I requested a single server-side rendered page of about 5kb from JMeter on another server with different numbers of threads and request-per-minute limits.

Results for React.Net

10 threads

req/min | avg ms | min ms | max ms

    100 |    138 |     90 |  1,161

    500 |    256 |      4 |  2,049

   1000 |    566 |     31 |  4,969

20 threads

req/min | avg ms | min ms | max ms

    100 |    284 |     88 |  1,964

    500 |    432 |     52 |  3,649

   1000 |  1,557 |     75 |  4,405

50 threads

req/min | avg ms | min ms | max ms

    100 |  1,393 |     91 |  4,693

    500 |  1,723 |     19 | 10,523

   1000 |  4,418 |     97 | 32,769

Results for SuperchargedReact

10 threads

req/min | avg ms | min ms | max ms

    100 |    763 |      7 |  2,194

    500 |  2,149 |    263 |  5,160

   1000 |  2,270 |    149 |  4,865

I stopped testing SuperchagedReact at this point since it looked significantly worse than React.Net

1 个答案:

答案 0 :(得分:1)

这有助于我们:

ReactSiteConfiguration.Configuration.AllowMsieEngine = false;
ReactSiteConfiguration.Configuration.ReuseJavaScriptEngines = false;
  • 强制使用V8而不是IE的Javascript引擎。如果您没有安装VC ++ 2013运行时,有时V8可能无法加载。
  • 禁用JS引擎池,我们发现它是错误的。
  • 我们有遗留的Razor视图,所以我们只在需要渲染React组件的页面上调用.ReactWithInit。这使我们可以避免在每个页面上调用.ReactInitJavascript,这大大减少了JS引擎的工作量。

希望有所帮助。