我是用 win 系统安装的 docker,再在 docker 上搭建了 rails 开发环境。如上图,本地访问个文章列表花了我 4s 多,有什么好的方法优化一下吗?
Started GET "/articles" for 172.20.0.1 at 2023-07-25 09:34:33 +0000
Cannot render console from 172.20.0.1! Allowed networks: 127.0.0.0/127.255.255.255, ::1
Processing by ArticlesController#index as HTML
Rendering layout layouts/application.html.erb
Rendering articles/index.html.erb within layouts/application
[1m[36mArticle Load (0.4ms)[0m [1m[34mSELECT "articles".* FROM "articles"[0m
↳ app/views/articles/index.html.erb:10
Rendered articles/index.html.erb within layouts/application (Duration: 3.5ms | Allocations: 742)
Rendered layout layouts/application.html.erb (Duration: 5.4ms | Allocations: 1492)
Completed 200 OK in 3646ms (Views: 6.1ms | ActiveRecord: 0.4ms | Allocations: 1846)
Started GET "/articles" for 172.20.0.1 at 2023-07-25 09:34:54 +0000
Cannot render console from 172.20.0.1! Allowed networks: 127.0.0.0/127.255.255.255, ::1
Processing by ArticlesController#index as HTML
Rendering layout layouts/application.html.erb
Rendering articles/index.html.erb within layouts/application
[1m[36mArticle Load (0.4ms)[0m [1m[34mSELECT "articles".* FROM "articles"[0m
↳ app/views/articles/index.html.erb:10
Rendered articles/index.html.erb within layouts/application (Duration: 3.1ms | Allocations: 742)
Rendered layout layouts/application.html.erb (Duration: 5.1ms | Allocations: 1480)
Completed 200 OK in 3899ms (Views: 6.0ms | ActiveRecord: 0.4ms | Allocations: 1851)
Started GET "/articles" for 172.20.0.1 at 2023-07-25 09:35:04 +0000
Cannot render console from 172.20.0.1! Allowed networks: 127.0.0.0/127.255.255.255, ::1
Processing by ArticlesController#index as HTML
Rendering layout layouts/application.html.erb
Rendering articles/index.html.erb within layouts/application
[1m[36mArticle Load (0.4ms)[0m [1m[34mSELECT "articles".* FROM "articles"[0m
↳ app/views/articles/index.html.erb:10
Rendered articles/index.html.erb within layouts/application (Duration: 3.1ms | Allocations: 742)
Rendered layout layouts/application.html.erb (Duration: 5.1ms | Allocations: 1477)
Completed 200 OK in 3748ms (Views: 6.0ms | ActiveRecord: 0.4ms | Allocations: 1832)
感觉和文件系统有关,在 mac docker 下都是秒回,win docker 测试了几遍拉文章列表,都要 3 秒多了
类似的问题我在 windows 的 wsl2 中遇到过,当项目文件放在 windows 的文件系统上时,响应会特别慢,把项目文件放在 wsl2 里后,速度就正常了