olebedev / go-starter-kit

[abandoned] Golang isomorphic react/hot reloadable/redux/css-modules/SSR starter kit
Other
2.82k stars 358 forks source link

slow performance #17

Closed ramboza closed 8 years ago

ramboza commented 8 years ago

Awesome work !

But a bit slow (just 16 resp/sec)

ab -n 1000 -c 64 http://localhost:5001/
This is ApacheBench, Version 2.3 <$Revision: 1663405 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
......
Completed 1000 requests
Finished 1000 requests

Server Software:
Server Hostname:        localhost
Server Port:            5001

Document Path:          /
Document Length:        1519 bytes

Concurrency Level:      64
Time taken for tests:   59.692 seconds
Complete requests:      1000
Failed requests:        813
   (Connect: 0, Receive: 0, Length: 813, Exceptions: 0)
Total transferred:      1687799 bytes
HTML transferred:       1527799 bytes
Requests per second:    16.75 [#/sec] (mean)
Time per request:       3820.269 [ms] (mean)
Time per request:       59.692 [ms] (mean, across all concurrent requests)
Transfer rate:          27.61 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0       2
Processing:  1987 3766 277.8   3795    4348
Waiting:     1987 3766 277.8   3795    4347
Total:       1987 3766 277.8   3796    4349

Percentage of the requests served within a certain time (ms)
  50%   3796
  66%   3870
  75%   3920
  80%   3956
  90%   4037
  95%   4095
  98%   4166
  99%   4221
 100%   4349 (longest request)
olebedev commented 8 years ago

First of all you testing a dev server that loads react app each time, per request It's toooooo slow, of course. Also you testing a node.js proxy.

To test production performance you need to build app for production and start it like that:

$ NODE_ENV=production make build
...
$ ./bin/app run -c production > /dev/null

and test it with

$ boom -n 1000 -c 64 http://localhost:5000/
1000 / 1000 Booooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo! 100.00 % 

Summary:
  Total:    4.4886 secs.
  Slowest:  0.8239 secs.
  Fastest:  0.0158 secs.
  Average:  0.2788 secs.
  Requests/sec: 222.7886
  Total Data Received:  1533526 bytes.
  Response Size per Request:    1533 bytes.

Status code distribution:
  [200] 1000 responses

Response time histogram:
  0.016 [1] |
  0.097 [50]    |∎∎
  0.177 [43]    |∎∎
  0.258 [43]    |∎∎
  0.339 [797]   |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  0.420 [17]    |
  0.501 [19]    |
  0.581 [24]    |∎
  0.662 [5] |
  0.743 [0] |
  0.824 [1] |

Latency distribution:
  10% in 0.2018 secs.
  25% in 0.2782 secs.
  50% in 0.2854 secs.
  75% in 0.2925 secs.
  90% in 0.3055 secs.
  95% in 0.4168 secs.
  99% in 0.5551 secs.

Duktape itself slower than v8 about 2-5 times. There is bad news - react apps render is pretty slow an node.js too. It depends of components amount of you app. Mostly this problems solved via front cache proxy inside the server app or outside. It's up to you which tool to use. If you write performant app you have to use cache independently of render engine, django or RoR or React+Duktape and so on.

olebedev commented 8 years ago

Due to performance improvement there are new benchmarks - Requests/sec: 432.2885 for OS X 10.10.4 (14E46), 2,7 GHz Intel Core i5, 8 GB 1867 MHz DDR3

/cc @ramboza

Full boom output is:

$ boom -n 1000 -c 64 http://localhost:5000/
1000 / 1000 Booooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo! 100.00 % 

Summary:
  Total:    2.3133 secs.
  Slowest:  0.3573 secs.
  Fastest:  0.0077 secs.
  Average:  0.1437 secs.
  Requests/sec: 432.2885
  Total Data Received:  1534073 bytes.
  Response Size per Request:    1534 bytes.

Status code distribution:
  [200] 1000 responses

Response time histogram:
  0.008 [1] |
  0.043 [46]    |∎∎∎
  0.078 [24]    |∎
  0.113 [41]    |∎∎∎
  0.148 [502]   |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  0.182 [294]   |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
  0.217 [42]    |∎∎∎
  0.252 [20]    |∎
  0.287 [12]    |
  0.322 [14]    |∎
  0.357 [4] |

Latency distribution:
  10% in 0.1081 secs.
  25% in 0.1328 secs.
  50% in 0.1413 secs.
  75% in 0.1598 secs.
  90% in 0.1785 secs.
  95% in 0.2188 secs.
  99% in 0.3072 secs.
ramboza commented 8 years ago

Wow Oleg, 2x faster!! Thanks !!