Speeding up Rails 7's Controller Actions using ActiveRecord's #load_async

Most of the time in a web application, a single API request consists of multiple database queries. For example: class DashboardsController < ApplicationController def dashboard @users = User.some_complex_scope.load_async @products = Product.some_complex_scope.load_async @library_files = LibraryFile.some_complex_scope.load_async end end Quoting snippet from load_async PR description from rails repository. The queries are executed synchronously, which mostly isn’t a huge concern. But, as the database grows larger in size, the response time of requests is getting longer. A significant part of the query time is often just I/O waits.

Working with Rails Time-zone

How to work with time-zone in rails Time-zone leaks: This is an issue where time-zone of one request is passed to another request. Ex Scenario: Lets say we have web-server running on a single dyno and we have three different users with different timezones('Mumbai', 'Central America' and 'London'). Here is my code setup that will produce time-zone leaks, class UserController def method_one_with_time_zone puts Time.zone #before_filter sets the time zone for this method execution. end def method_two_without_time_zone puts Time.zone #This method doesn't call any before filter, So it will