1

I have a view similar to this:

<h1>Example restaurant</h1>

<% @restaurant.menus.each do |menu| %>

  Here a long menu is generated (expensive operation)

<% end %>

I already use fragment caching for speeding up the next requests. However when the cache is cold the request is extremely slow.

Is there a reliable way to render each element in parallel? (Or at least concurrently, if using MRI)

Note that each element (i.e. restaurant menu) is independent from the other.

collimarco
  • 34,231
  • 36
  • 108
  • 142
  • maybe something like this? https://blog.saeloun.com/2021/03/31/rails-adds-ability-to-query-async.html . it's on edge rails so not sure if u can use it – Joel Blum May 14 '21 at 19:22
  • 1
    I'd also take a look at your queries - r u sure everything is optimized there? maybe there's some n+1 or something? – Joel Blum May 14 '21 at 19:22

0 Answers0