Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 5 very slow startup on Windows

I have installed RoR 5 in my laptop

  • Windows 10
  • SSD
  • 4gb ram
  • i5 5thgen

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

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

I also tested Webrick and the latency is still there.

Im talking about 28 seconds !!!

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

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...

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

*** 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?

I also tested on my main machine

  • 16gb low latency ram
  • ssd
  • 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!

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!

this is Puma on the fast machine

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

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?) ...

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

Im uploading a video showing this issue.

  • Update after trying Ruby 2.3

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

  • SSL errors about https://rubygems.org (you have to go http://)
  • sqlite3 error 1 (path in rakefile)
  • sqlite3 after fixing error 1 , error 2 presents an error about sqlite3 adapter.

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

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 :)

Thanks!

like image 347
frcake Avatar asked Oct 03 '16 21:10

frcake


2 Answers

One cause of the slow boot times could be OpenSSL.
See the discussion here:

OpenSSL causing very slow Rails boot time on Windows

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

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

According to this ticket, the OpenSSL issue has now been fixed in Ruby 2.3:
https://bugs.ruby-lang.org/issues/12139

like image 184
Casper Avatar answered Nov 15 '22 04:11

Casper


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.

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.

like image 1
Evolve Avatar answered Nov 15 '22 05:11

Evolve