Rails Kitchen

It's a place to write on stuff I learned recently.

Profile API Endpoints Using Rack-mini-profiler

| Comments

rack-mini-profiler is a great tool for fine tuning our Ruby on Rails application. This gem will show all information about the queries in the web page we are loading. By checking this list, we can understand which part of our code takes the longest time and optimize that part of code.

This is very useful to inspect the performance of HTML pages, but it does not provide any default ways to review the performance of API endpoints. After some searching, I found out that, by default, the rack-mini-profiler gem collects the previous JSON call and will show all previous requests in the next loading HTML page. Using this feature we can achieve profiling API endpoints.

Following are the steps that I did to profile API request.

1- Make an API request using Postman or another client.
2- Reload an HTML page, I loaded 404.html page by hitting URL http://localhost:3000/404.html
3- This web page will show all profile information of previous API call.