jeudi 12 octobre 2017

Slow loading Rails 5.1.4 with Ruby 2.3.3-p222

I have standard view with 1 database query (MySQL). I am using Devise and method for checking is it user logged in layouts/application.html.erb:

<% unless user_signed_in? %>
    <%= render 'partials/login_modal' %>
    <%= render 'partials/registration_modal' %>
<% end %>

Layout is with 4 partials included (_header.html.erb and _footer.html.erb, too). All generated HTML (from html tag to html) is around 320 lines.

In production I set : config.assets.raise_runtime_errors = false.

The site loads really slow, but only the first time, right after starting server and it doesn't matter which page loads, it is same for all .

In production:

  • FontAwesome loads for 20ms;
  • the CSS file for 8ms,
  • JS file - 14 ms and three images around 10-20ms each.

The page which is 11Kb loads for more than 9 seconds.

In development, same page, I have different requests for assets (9 CSS/JS/img files, each between 20 -50ms for loading) and same page (11.4Kb) loads for more than 11 seconds.

I read in the console when it s development mode:

Started GET "/contacts" for 127.0.0.1 at 2017-10-12 23:33:48 +0300

(1.0ms) SET @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483

(1.0ms) SELECT schema_migrations.version FROM schema_migrations ORDER BY schema_migrations.version ASC

Processing by ContactsController#index as HTML

Rendering index.html.erb within layouts/application

Rendered index.html.erb within layouts/application (1.0ms)

Rendered partials/_header.html.erb (1.0ms)

Rendered partials/_footer.html.erb (0.0ms)

Rendered partials/_login_modal.html.erb (1.0ms)

Rendered partials/_registration_modal.html.erb (0.0ms)

I am using Windows 10, but is same on Ubuntu. It is same and if I upload site to Heroku and only first time when browser loads the site.

Aucun commentaire:

Enregistrer un commentaire