Misskey: brotli圧縮が使用されると異様にレスポンスが遅くなることがある

Created on 6 May 2020  ·  3Comments  ·  Source: syuilo/misskey

💡 Summary

brotli圧縮が使用されると異様にレスポンスが遅くなることがある

Accept-Encoding: br などが来てbrotli圧縮が使用された場合に
レスポンスに7秒くらいかかったりする。

developmentのapp.jsで起きてproductionでは起きないのでサイズによるかも。

たぶんkoa-compress 4.x の brotli のせい
koa-compress 3.1.0 では起きなくて
koa-compress 4.0.1 では起きる
koa-compress 4.0.1 でもbrotliを無効にすれば起きない

$ curl -i -s -w "%{time_starttransfer}\n" -H 'Accept-Encoding: br' http://localhost:3312/assets/app.12.36.1.js
HTTP/1.1 200 OK
Vary: Accept-Encoding
strict-transport-security: max-age=15552000; preload
X-Frame-Options: DENY
Last-Modified: Wed, 06 May 2020 11:49:33 GMT
Cache-Control: max-age=604800
Content-Type: application/javascript; charset=utf-8
Content-Encoding: br
Date: Wed, 06 May 2020 12:35:52 GMT
Connection: keep-alive
Transfer-Encoding: chunked

6.926116

🙂 Expected Behavior

数ミリ秒とかで返ってくる

☹️ Actual Behavior

7秒くらいかかる

📝 Steps to Reproduce

Summary参照

📌 Environment

v12 develop

⚙️Server ⚠️bug?

All 3 comments

なお、nginxやCDN等が前段にある場合は別にNodeで圧縮しなくていい気もする

開発してるときにやけに遅いと思ってたけどこれが原因か〜

ほとんどの場合CloudFlare使いそうなので要らないかも

Was this page helpful?
0 / 5 - 0 ratings