0

I am creating a cinema system in Ruby on Rails and I BIG problem I am having is that the pages take ages to load, and when they do load the buttons don't work so I have to refresh the page.

I don't know why it does it, but I have a huge CSS, and because its a cinema site I have film images and film trailers; in total the directory is 359MB, with the videos folder (in the public folder) being 266MB.

When I first run the server using rails s I get this output:

Screenshot Screenshot Screenshot Screenshot

I am precompiling the videos and images in config/intitializers/assets.rb:

Rails.application.config.assets.version = '1.0'
Rails.application.config.assets.precompile += ['public/videos']
Rails.application.config.assets.precompile += ['app/assets/images']

I am using Firefox (but its the same on all browsers) and Windows 7.

Can someone please advise me on how to improve this issue.

AstroCB
  • 12,337
  • 20
  • 57
  • 73
  • The WEBrick server is not recommended to run in production. Have you every tested the performance with a "real" application server (passenger, unicorn, puma)? – spickermann Apr 11 '15 at 12:59
  • Sorry for sounding thick, but how would I do that? –  Apr 11 '15 at 13:01
  • Let me rephrase: Do you have a plan how to deploy your application to the public? Perhaps Heroku or a server in the Amazon cloud? – spickermann Apr 11 '15 at 13:07
  • No. This is part of a project and would not be used by the public –  Apr 11 '15 at 13:08
  • Start by narrowing down the problem: is it that the view renders slowly, lots of database queries, client side performance problems , an inefficient algorithm in one of your models, something else? – Frederick Cheung Apr 11 '15 at 14:20
  • I think its likely to be slow rendering and client side performance –  Apr 11 '15 at 15:09

1 Answers1

1

I think

Firstly its Windows. Ruby is slow in windows, therby rails is slow.

Secondly try puma

Thirdly altough I can't see what the queries are, but I feel you should preload the whatever association you have, if possible, which would reduce the number of queries.

Fourthly, you could run linux on a VM and run rails on it.

Lastly I haven't tried this, see if it is possible to run rails with jRuby. it supports multi-threading and should be faster.

Here is a tutorial on integration of Jruby with existing rails proj..

From Heroku and From other resource, :) , You can skip the pg sql part and replace the pgsql sql driver with mysqll jdbc driver..

argentum47
  • 2,385
  • 1
  • 18
  • 20
  • I am trying the `puma gem` now, how would I would preload the queries and run rails with `jRuby`? Using Linux isn't really an option unfortuneately –  Apr 11 '15 at 13:46
  • well , I am looking into the jRuby thing, with puma you can setup number of workers, I have also heard that Passenger is also good, but I haven't tried it .. as to how to preload associations, I can give you an example,..supposing user has many comments, you can @user.includes(:comments).each do || in you view .. – argentum47 Apr 11 '15 at 13:50
  • Ok, I am trying to install puma but get the error: `Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.` and I think I already have associations like those –  Apr 11 '15 at 13:52
  • I have posted two links on using jruby with rails.. tell us how the performace .. http://stackoverflow.com/questions/28151812 – argentum47 Apr 11 '15 at 14:01
  • skip the rvm part ... see if this helps http://stackoverflow.com/questions/26261334 and http://stackoverflow.com/questions/3216128/ – argentum47 Apr 11 '15 at 14:10
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/75007/discussion-between-benjs-1-and-argentum47). –  Apr 11 '15 at 14:19