Open tanihiro opened 4 years ago
ざっと見繕った感じ、下記のあたりがよさそうだった。
@dameleon 一旦、NestJSとFastifyで簡単なCRUD組むとどんな感じになるだろうか、というのを試してみようと思います。
おけまるです!
@dameleon 一旦軽くですが、NestJSとFastifyをそれぞれ触ってみました。
それぞれのPRにも書きましたが、NestJSは全部入り、Fastifyはシンプル。という印象でした。(NestJS=Rails, Fastify=sinatraみたいな)
個人的には、Architectureの部分を個人が考えてしまうとオレオレ構成になりかねないので、基盤としてちゃんと整えられているNestJSをベースにしてしまっていいのではないかと思いました。
イメージ的には、ガッツリ整えられているものよりも、小さい自由度の高いもののほうが合っているでしょうか? ご意見伺えればと思います。
ちなみに、下記のライブラリの存在をさっき知りまして、NestJSのコントローラーの実装はほぼ下記のを流用している感じですね。Expressでもkoaでも同じような書き方はできそうです。
みました。 NestJS、decoratorがすごい(小並)ので一瞬引きますね。。ただDIまでワンセットでついてくるのはいいなぁという感じ。まさにangularを思い出させる感じだなと思いました。 これってdecoratorも結構自分で書かないといけないやつですかね?ここのコストがかかるのが結構ネックになるかなと思いました。 個人的にはFastify推しです。goくらい薄い層にapplication作っていった方が結局分かりやすいのでは?というイメージ。 ちなみに、同じようなapp書いたときにapache benchとかで雑にベンチ取った結果みたいなの取ってもらってもよかでしょうか
@dameleon 50件のレコードを取得して、JSONで出力するエンドポイントに対して、下記のapache benchを実行してみました。 ORMはどちらもTypeORMを利用しています。
$ ab -n 2000 -c 100 http://localhost:3000/users
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
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)
Server Software:
Server Hostname: localhost
Server Port: 3000
Document Path: /users
Document Length: 2442 bytes
Concurrency Level: 100
Time taken for tests: 4.007 seconds
Complete requests: 2000
Failed requests: 0
Total transferred: 5172000 bytes
HTML transferred: 4884000 bytes
Requests per second: 499.08 [#/sec] (mean)
Time per request: 200.367 [ms] (mean)
Time per request: 2.004 [ms] (mean, across all concurrent requests)
Transfer rate: 1260.38 [Kbytes/sec] received
Connection Times (ms)
¦ ¦ ¦ min mean[+/-sd] median max
Connect: 0 3 3.1 2 26
Processing: 25 194 43.1 184 342
Waiting: 16 184 41.9 174 329
Total: 25 197 43.5 186 350
Percentage of the requests served within a certain time (ms)
50% 186
66% 197
75% 211
80% 221
90% 273
95% 298
98% 312
99% 317
100% 350 (longest request)
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
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)
Server Software:
Server Hostname: localhost
Server Port: 3000
Document Path: /users
Document Length: 2442 bytes
Concurrency Level: 100
Time taken for tests: 4.180 seconds
Complete requests: 2000
Failed requests: 0
Total transferred: 5304000 bytes
HTML transferred: 4884000 bytes
Requests per second: 478.44 [#/sec] (mean)
Time per request: 209.013 [ms] (mean)
Time per request: 2.090 [ms] (mean, across all concurrent requests)
Transfer rate: 1239.08 [Kbytes/sec] received
Connection Times (ms)
¦ ¦ ¦ min mean[+/-sd] median max
Connect: 0 2 2.8 1 37
Processing: 26 203 35.8 202 390
Waiting: 17 193 35.3 192 382
Total: 26 205 35.6 203 397
Percentage of the requests served within a certain time (ms)
50% 203
66% 215
75% 219
80% 226
90% 241
95% 247
98% 311
99% 349
100% 397 (longest request)
このレベルだと、ほとんど差はない感じでした。 ただ、FastifyにTypeORMを組み込んでjestを書いていく際に、たしかにこっちのほうが薄くてやりやすいかもなという印象を抱きました。
ゴール