You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/server-side-rendering.md
+33-20Lines changed: 33 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ There are lots of articles about comparing dotnet core and nodejs, I will only m
32
32
* F# is a compiled language, which means it's generally considered faster then a dynamic language, like js.
33
33
* Nodejs's single thread, event-driven, non-blocking I/O model works well in most web sites, but it is not good at CPU intensive tasks, including html rendering. Usually we need to run multi nodejs instances to take the advantage of multi-core systems. DotNet support non-blocking I/O (and `async/await` sugar), too. But the awesome part is that it also has pretty good support for multi-thread programming.
34
34
35
-
In a simple test in my local macbook, rendering on dotnet core is about ~2x faster then nodejs (with ReactDOMServer.renderToString + NODE_ENV=production). You can find more detail in the bottom of this page.
35
+
In a simple test in my local macbook, rendering on dotnet core is about ~3x faster then nodejs (with ReactDOMServer.renderToString + NODE_ENV=production). You can find more detail in the bottom of this page.
36
36
37
37
In a word, with this approach, you can not only get a better performance then nodejs, but also don't need the complexity of running and maintaining nodejs instances on your server!
38
38
@@ -257,31 +257,44 @@ cd ./fable-react/Samples/SSRSample/
257
257
258
258
## Run simple benchmark test in sample app
259
259
260
-
The result of dotnet core is already printed in console when your server started, here are some commands to run benchmark of ReactDOMServer on nodejs.
260
+
The SSRSample project also contains a simple benchmark test, you can try it in you computer by:
261
261
262
262
```sh
263
-
cd ./Samples/SSRSample/src/Client
264
-
dotnet fable npm-run buildClientLib
265
-
NODE_ENV=production node ./bin/lib/Bench.js
266
-
```
267
263
268
-
### Benchmark result in my laptop (MacBook Pro with 2.7 GHz Intel Core i5, 16 GB 1867 MHz DDR3):
264
+
cd ./Samples/SSRSample
265
+
./build.sh bench # or ./build.cmd bench on windows
269
266
270
-
```sh
267
+
```
271
268
272
-
# SSR on dotnet core with Debug mode
273
-
# dir: fable-react/Samples/SSRSample/src/Server
274
-
$ dotnet run
275
-
render 10000 timesin dotnet core: 3731ms
269
+
Here is the benchmark result in my laptop (MacBook Pro with 2.7 GHz Intel Core i5, 16 GB 1867 MHz DD~R3), rendering on dotnet core is about ~4x faster then on nodejs in a single thread. To take the advantage of multi-core systems, we also tested with multi-thread on dotnet core and cluster mode in nodejs, the dotnet core version is still about ~3x faster then nodejs version, with less memory footprint!
0 commit comments