Exercises
We learned that handling a web request involves thousands of method calls and allocated Ruby objects. What if skip the Rack middleware and pass the request to the router directly (Rails.application.routes.call(request)
)? What about skipping the router and calling a controller action right away (for example, PostsController.action(:index).call(request)
)? Using trace_location
and GC.stats
, conduct some experiments and analyze the results. What are the overheads of the Rack middleware and the router?