Rails development server is slow and takes a long time to load a simple page Rails development server is slow and takes a long time to load a simple page ruby ruby

Rails development server is slow and takes a long time to load a simple page


Copying the answer from the comments (and edited question body) in order to remove this question from the "Unanswered" filter:

I tried what they recommended in this post (Diagnosing the cause of slow view rendering), and it worked. Asset pipeline is enabled, and page loading goes from 20-40 seconds to like 1 second. much better at least.

...

Basically, it turns out the delay was being caused by config.assets.debug = true inside of development.rb. I made it false and it seems to be faster.

The Rails guys say that enabling debug will slow down really complicated apps, but this was just a simple tutorial app with literally 1 model/controller/view. Anyways, I hope these performance gains last, but it does solve my immediate problem.

~ answer per Dave Bowman


Also something important to take into consideration.


If you have caching setup but the credentials are not correct (or have been since updated as was the case for me) then Rails will try to connect to the server several times before giving up and processing the data manually.

For example in this block

@data = Rails.cache.fetch('all_market_data', expires_in: 1.hour) do  Model.all.where(x: y).order('value ASC').each do |c|    # functionality    # proccessing    # etc  end  @dataend

Rails will attempt to connect to whatever cache is configured in your development.rb config file.

Having failed that (approximately 20 seconds of trying) it will give up trying to connect to the cache itself and proccess the data itself (just as if the expiry on the cache had been met)

tldr: If you have caching setup, make sure that your credentials are up to date, and you can establish a connection.