Rails 5在Windows上启动很慢

时间:2022-09-11 15:08:01

I have installed RoR 5 in my laptop

我在我的笔记本电脑上安装了RoR 5。

  • Windows 10
  • Windows 10
  • SSD
  • 固态硬盘
  • 4gb ram
  • 4 gb内存
  • i5 5thgen
  • i5 5 thgen

I started working on a project which i wanted to specificaly test under windows , and i noticed some lags and latency.

我开始做一个项目,我想在windows下进行具体的测试,我注意到一些延迟和延迟。

So i started a new rails app , to rule out my code , and the latency was the same.

所以我启动了一个新的rails应用程序,排除了我的代码,延迟也是一样的。

I also tested Webrick and the latency is still there.

我还测试了Webrick,延迟仍然存在。

Im talking about 28 seconds !!!

我说的是28秒!!!

I know there are many relative issues but most talk about rails in earlier versions.

我知道有很多相关的问题,但大多数都是在早期版本中讨论rails的。

The main reason i wanted to program this app in rails , is to run in a local server , but the user has windows on his machine...

我想在rails中编写这个应用程序的主要原因是在本地服务器上运行,但是用户的机器上有windows……

C:\Users\John\railstestapp\testapp>rails s
=> Booting Puma
=> Rails 5.0.0.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options

Very big time gap here close to 25 seconds

非常大的时间间隔接近25秒

*** SIGUSR2 not implemented, signal based restart unavailable!
*** SIGUSR1 not implemented, signal based restart unavailable!
*** SIGHUP not implemented, signal based logs reopening unavailable!
Puma starting in single mode...
* Version 3.6.0 (ruby 2.2.4-p230), codename: Sleepy Sunday Serenity
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000

as you'd expect this performance continues throughout the page..

正如你所期望的那样,这一表现将贯穿整个页面。

Any ideas? am i missing something? any of you guys developing rails 5 on windows? any tips?

什么好主意吗?我遗漏了什么东西?你们有人在windows上开发rails 5吗?任何建议吗?

I also tested on my main machine

我还在我的主机上进行了测试

  • 16gb low latency ram
  • 16 gb的ram低延迟
  • ssd
  • 固态硬盘
  • AMD FX8350
  • AMD FX8350

same slow response , but a little faster than the laptop!

同样慢的反应,但是比笔记本电脑快一点!

Also weird thing is that , if i run the rails console side by side , i see the rails log printed in the console , but the browser loads for a long time!

同样奇怪的是,如果我并排运行rails控制台,我将看到打印在控制台中的rails日志,但是浏览器会加载很长一段时间!

I thought it was a browser problem , so to rule that out , i browsed the site by another of my local machines , so i can only use the server and not the Windows browser... still no avail , the response time is really slow!

我认为这是一个浏览器问题,所以为了排除这个问题,我用我的本地机器浏览了这个网站,所以我只能使用服务器而不能使用Windows浏览器……仍然没有效果,响应时间真的很慢!

this is Puma on the fast machine

这是快速机器上的Puma

C:\Users\John\SimpleGym\simplegym>rails s
=> Booting Puma
=> Rails 5.0.0.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
*** SIGUSR2 not implemented, signal based restart unavailable!
*** SIGUSR1 not implemented, signal based restart unavailable!
*** SIGHUP not implemented, signal based logs reopening unavailable!
Puma starting in single mode...
* Version 3.6.0 (ruby 2.2.4-p230), codename: Sleepy Sunday Serenity
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
DEPRECATION WARNING: after_filter is deprecated and will be removed in Rails 5.1. Use after_action instead. (called from block (2 levels) in <module:ClassMethods> at C:/Ruby22/lib/ruby/gems/2.2.0/gems/actionpack-5.0.0.1/lib/abstract_controller/callbacks.rb:191)
DEPRECATION WARNING: after_filter is deprecated and will be removed in Rails 5.1. Use after_action instead. (called from block (2 levels) in <module:ClassMethods> at C:/Ruby22/lib/ruby/gems/2.2.0/gems/actionpack-5.0.0.1/lib/abstract_controller/callbacks.rb:191)
Started GET "/" for ::1 at 2016-10-03 18:59:54 +0300
  ActiveRecord::SchemaMigration Load (0.0ms)  SELECT "schema_migrations".* FROM "schema_migrations"
Processing by SessionsController#index as HTML
  Rendering sessions/index.html.erb within layouts/application
  Session Load (0.0ms)  SELECT "sessions".* FROM "sessions"
  Session Load (0.0ms)  SELECT  "sessions".* FROM "sessions" ORDER BY "sessions"."id" DESC LIMIT ?  [["LIMIT", 1]]
   (0.0ms)  SELECT COUNT(*) FROM "students" INNER JOIN "attendances" ON "students"."id" = "attendances"."student_id" WHERE "attendances"."session_id" = ?  [["session_id", 1]]
  Session Load (1.0ms)  SELECT  "sessions".* FROM "sessions" ORDER BY "sessions"."id" DESC LIMIT ?  [["LIMIT", 1]]
  Session Load (1.0ms)  SELECT  "sessions".* FROM "sessions" ORDER BY "sessions"."id" DESC LIMIT ?  [["LIMIT", 1]]
  Session Load (1.0ms)  SELECT  "sessions".* FROM "sessions" ORDER BY "sessions"."id" DESC LIMIT ?  [["LIMIT", 1]]
  Session Load (1.0ms)  SELECT  "sessions".* FROM "sessions" ORDER BY "sessions"."id" DESC LIMIT ?  [["LIMIT", 1]]
   (0.0ms)  SELECT COUNT(*) FROM "students" INNER JOIN "attendances" ON "students"."id" = "attendances"."student_id" WHERE "attendances"."session_id" = ?  [["session_id", 2]]
  Session Load (0.0ms)  SELECT  "sessions".* FROM "sessions" ORDER BY "sessions"."id" DESC LIMIT ?  [["LIMIT", 1]]
  Rendered sessions/index.html.erb within layouts/application (113.0ms)
Completed 200 OK in 621ms (Views: 538.5ms | ActiveRecord: 8.0ms | Solr: 0.0ms)

this is webrick on the fast machine

这是快速机器上的webrick

C:\Users\John\SimpleGym\simplegym>rails server webrick
=> Booting WEBrick
=> Rails 5.0.0.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
[2016-10-03 19:17:19] INFO  WEBrick 1.3.1
[2016-10-03 19:17:19] INFO  ruby 2.2.4 (2015-12-16) [i386-mingw32]
[2016-10-03 19:17:19] INFO  WEBrick::HTTPServer#start: pid=9936 port=3000
DEPRECATION WARNING: after_filter is deprecated and will be removed in Rails 5.1. Use after_action instead. (called from block (2 levels) in <module:ClassMethods> at C:/Ruby22/lib/ruby/gems/2.2.0/gems/actionpack-5.0.0.1/lib/abstract_controller/callbacks.rb:191)
DEPRECATION WARNING: after_filter is deprecated and will be removed in Rails 5.1. Use after_action instead. (called from block (2 levels) in <module:ClassMethods> at C:/Ruby22/lib/ruby/gems/2.2.0/gems/actionpack-5.0.0.1/lib/abstract_controller/callbacks.rb:191)
Started GET "/" for ::1 at 2016-10-03 19:17:30 +0300
  ActiveRecord::SchemaMigration Load (1.0ms)  SELECT "schema_migrations".* FROM "schema_migrations"
Processing by SessionsController#index as HTML
  Rendering sessions/index.html.erb within layouts/application
  Session Load (0.0ms)  SELECT "sessions".* FROM "sessions"
  Session Load (0.0ms)  SELECT  "sessions".* FROM "sessions" ORDER BY "sessions"."id" DESC LIMIT ?  [["LIMIT", 1]]
   (1.0ms)  SELECT COUNT(*) FROM "students" INNER JOIN "attendances" ON "students"."id" = "attendances"."student_id" WHERE "attendances"."session_id" = ?  [["session_id", 1]]
  Session Load (1.0ms)  SELECT  "sessions".* FROM "sessions" ORDER BY "sessions"."id" DESC LIMIT ?  [["LIMIT", 1]]
   (1.0ms)  SELECT COUNT(*) FROM "students" INNER JOIN "attendances" ON "students"."id" = "attendances"."student_id" WHERE "attendances"."session_id" = ?  [["session_id", 2]]
  Session Load (0.0ms)  SELECT  "sessions".* FROM "sessions" ORDER BY "sessions"."id" DESC LIMIT ?  [["LIMIT", 1]]
  Session Load (1.0ms)  SELECT  "sessions".* FROM "sessions" ORDER BY "sessions"."id" DESC LIMIT ?  [["LIMIT", 1]]
  Session Load (0.0ms)  SELECT  "sessions".* FROM "sessions" ORDER BY "sessions"."id" DESC LIMIT ?  [["LIMIT", 1]]
  Session Load (1.0ms)  SELECT  "sessions".* FROM "sessions" ORDER BY "sessions"."id" DESC LIMIT ?  [["LIMIT", 1]]
   (0.0ms)  SELECT COUNT(*) FROM "students" INNER JOIN "attendances" ON "students"."id" = "attendances"."student_id" WHERE "attendances"."session_id" = ?  [["session_id", 3]]
  Session Load (0.0ms)  SELECT  "sessions".* FROM "sessions" ORDER BY "sessions"."id" DESC LIMIT ?  [["LIMIT", 1]]
  Rendered sessions/index.html.erb within layouts/application (135.0ms)
Completed 200 OK in 679ms (Views: 596.3ms | ActiveRecord: 6.0ms | Solr: 0.0ms)



[2016-10-03 19:17:51] ERROR Errno::ECONNABORTED: An established connection was aborted by the software in your host machine. @ io_fillbuf - fd:8
        C:/Ruby22/lib/ruby/2.2.0/webrick/httpserver.rb:80:in `eof?'
        C:/Ruby22/lib/ruby/2.2.0/webrick/httpserver.rb:80:in `run'
        C:/Ruby22/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'
[2016-10-03 19:17:51] ERROR Errno::ECONNABORTED: An established connection was aborted by the software in your host machine. @ io_fillbuf - fd:9
        C:/Ruby22/lib/ruby/2.2.0/webrick/httpserver.rb:80:in `eof?'
        C:/Ruby22/lib/ruby/2.2.0/webrick/httpserver.rb:80:in `run'
C:/Ruby22/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'

Thank you all guys for trying to help me , i tried the solutions with no avail .. seems like rails just wont do it (yet?) ...

谢谢大家的帮助,我已经尽力了。看起来rails并不能做到(现在?)

Nothing seems to provide a good development environment , i advised the client to use it online ..

似乎没有什么能提供良好的开发环境,我建议客户在网上使用它。

// Update

/ /更新

https://drive.google.com/file/d/0B_flcE49VcE1ZmVPeTFuQjUyU2s/view

https://drive.google.com/file/d/0B_flcE49VcE1ZmVPeTFuQjUyU2s/view

Im uploading a video showing this issue.

我上传了一个关于这个问题的视频。

  • Update after trying Ruby 2.3
  • 在尝试Ruby 2.3之后进行更新

There's a world of problems when you try to install ruby 2.3

当您尝试安装ruby 2.3时,会遇到很多问题

  • SSL errors about https://rubygems.org (you have to go http://)
  • 关于https://rubygems.org的SSL错误(您必须使用http://)
  • sqlite3 error 1 (path in rakefile)
  • sqlite3错误1 (rakefile中的路径)
  • sqlite3 after fixing error 1 , error 2 presents an error about sqlite3 adapter.
  • 在修正错误1之后,错误2出现了一个关于sqlite3适配器的错误。

Found no solution regarding error 2 and stopped trying...

发现错误2没有解决方案,停止尝试…

maybe ill switch to PG , only to see if the performance is better and mark this as solved , this requires a bit of time , so ill do it when i have some :)

也许我会换到PG,只是为了看看性能是否更好,并把这个标记为已解决,这需要一点时间,所以当我有一些的时候我会这么做:)

Thanks!

谢谢!

4 个解决方案

#1


4  

The slow boot time on Windows might be caused by OpenSSL.
See the discussion here:

Windows上的缓慢启动时间可能是由OpenSSL造成的。看到这里的讨论:

OpenSSL causing very slow Rails boot time on Windows

OpenSSL会导致Windows上的Rails启动速度非常慢

Also read this answer for a possible temporary solution:
https://*.com/a/36629699/823617

也请阅读此答案以获得可能的临时解决方案:https://*.com/a/36629699/823617

Here's a Rails ticket discussing the issue:
https://github.com/rails/rails/issues/25805

这里有一个讨论这个问题的Rails票据:https://github.com/rails/rails/issues/25805

This issue has now been fixed in Ruby 2.3
https://bugs.ruby-lang.org/issues/12139

这个问题现在已经在Ruby 2.3中得到了解决

#2


2  

I haven't looked at this at all myself but you could potentially try using the new built in Ubuntu that's part of Windows 10. It's in beta though so YMMV. I would test it out by seein if you can firstly install a ruby version manager (like rvm.io) as if that runs your app is likely to run.

我自己还没有看过这个,但是你可以尝试使用Ubuntu的内置系统,这是Windows 10的一部分。它在beta中,不过是YMMV。如果你能先安装一个ruby版本管理器(比如rvm.io),就好像它能运行你的应用程序一样,我将通过seein测试它。

https://blogs.windows.com/buildingapps/2016/03/30/run-bash-on-ubuntu-on-windows

https://blogs.windows.com/buildingapps/2016/03/30/run-bash-on-ubuntu-on-windows

At least then you are much closer to a true posix style terminal.

至少这样,您就更接近一个真正的posix样式终端。

#3


1  

If you are not on Win 10, I always found the default command line pretty average and not including many things taken for granted on other platforms.

如果你不是Win 10,我总是发现默认的命令行很普通,不包括其他平台上的很多事情。

I've found the easiest approach was to download github for Windows and use the configured terminal they provide. (Well they used to provide a terminal it's been a while since I've done it). Worth a try if the Ubuntu approach is a no go.

我发现最简单的方法是为Windows下载github并使用它们提供的配置终端。(他们曾经提供一个终端我已经有一段时间没这么做了)如果Ubuntu方法不可行,值得一试。

https://desktop.github.com

https://desktop.github.com

#4


0  

I forgot to mention this one before, you could also try RailsInstaller http://railsinstaller.org/en it's by the folks at EngineYard and sets up a full rails env for you. Unfortunately it doesn't seem to be under active Dev :/ (one plus, no-body is reporting speed as a problem in their github issues FWIW)

我之前忘记提到过这个,你也可以试试RailsInstaller http://railsinstaller.org/en它是由EngineYard的人提供的,并为你设置一个完整的rails env。不幸的是,它似乎并没有处于活动Dev:/ (one plus, no-body在github的FWIW问题中报告速度是一个问题)

Yeah I know it's frustrating.

是的,我知道这很令人沮丧。

Just FYI, when I was doing Windows Dev previously I personally ended up installing virtualbox and installing Ubuntu on there, that worked fine for local Dev but yeah "install a virtual machine" isn't really the answer ur looking for and that was before most of these other options existed.

当我在做Windows Dev的时候,我个人最终安装了virtualbox并在那里安装了Ubuntu,这对本地的Dev来说很不错,但是“安装虚拟机”并不是你想要的答案,这是在大多数其他选项存在之前。

#1


4  

The slow boot time on Windows might be caused by OpenSSL.
See the discussion here:

Windows上的缓慢启动时间可能是由OpenSSL造成的。看到这里的讨论:

OpenSSL causing very slow Rails boot time on Windows

OpenSSL会导致Windows上的Rails启动速度非常慢

Also read this answer for a possible temporary solution:
https://*.com/a/36629699/823617

也请阅读此答案以获得可能的临时解决方案:https://*.com/a/36629699/823617

Here's a Rails ticket discussing the issue:
https://github.com/rails/rails/issues/25805

这里有一个讨论这个问题的Rails票据:https://github.com/rails/rails/issues/25805

This issue has now been fixed in Ruby 2.3
https://bugs.ruby-lang.org/issues/12139

这个问题现在已经在Ruby 2.3中得到了解决

#2


2  

I haven't looked at this at all myself but you could potentially try using the new built in Ubuntu that's part of Windows 10. It's in beta though so YMMV. I would test it out by seein if you can firstly install a ruby version manager (like rvm.io) as if that runs your app is likely to run.

我自己还没有看过这个,但是你可以尝试使用Ubuntu的内置系统,这是Windows 10的一部分。它在beta中,不过是YMMV。如果你能先安装一个ruby版本管理器(比如rvm.io),就好像它能运行你的应用程序一样,我将通过seein测试它。

https://blogs.windows.com/buildingapps/2016/03/30/run-bash-on-ubuntu-on-windows

https://blogs.windows.com/buildingapps/2016/03/30/run-bash-on-ubuntu-on-windows

At least then you are much closer to a true posix style terminal.

至少这样,您就更接近一个真正的posix样式终端。

#3


1  

If you are not on Win 10, I always found the default command line pretty average and not including many things taken for granted on other platforms.

如果你不是Win 10,我总是发现默认的命令行很普通,不包括其他平台上的很多事情。

I've found the easiest approach was to download github for Windows and use the configured terminal they provide. (Well they used to provide a terminal it's been a while since I've done it). Worth a try if the Ubuntu approach is a no go.

我发现最简单的方法是为Windows下载github并使用它们提供的配置终端。(他们曾经提供一个终端我已经有一段时间没这么做了)如果Ubuntu方法不可行,值得一试。

https://desktop.github.com

https://desktop.github.com

#4


0  

I forgot to mention this one before, you could also try RailsInstaller http://railsinstaller.org/en it's by the folks at EngineYard and sets up a full rails env for you. Unfortunately it doesn't seem to be under active Dev :/ (one plus, no-body is reporting speed as a problem in their github issues FWIW)

我之前忘记提到过这个,你也可以试试RailsInstaller http://railsinstaller.org/en它是由EngineYard的人提供的,并为你设置一个完整的rails env。不幸的是,它似乎并没有处于活动Dev:/ (one plus, no-body在github的FWIW问题中报告速度是一个问题)

Yeah I know it's frustrating.

是的,我知道这很令人沮丧。

Just FYI, when I was doing Windows Dev previously I personally ended up installing virtualbox and installing Ubuntu on there, that worked fine for local Dev but yeah "install a virtual machine" isn't really the answer ur looking for and that was before most of these other options existed.

当我在做Windows Dev的时候,我个人最终安装了virtualbox并在那里安装了Ubuntu,这对本地的Dev来说很不错,但是“安装虚拟机”并不是你想要的答案,这是在大多数其他选项存在之前。