Hi all,
Well, 2 weeks ago, I was working on a brand new Rails application with Rails 8 (I love it). At first, I didn’t pay attention at the very poor performance of my app on my Macbook Pro 2017 laptop because on production, numbers were fine. But I realized that 500ms to render a page with a couple of simple SQL requests was way too long, even on my old laptop.
So I ran some tests and I discovered strange things when hitting the “/health” endpoint. Here what I found:
Macbook PRO 2017 (Intel).
-
Ruby 3.4.1 (YJIT) / Rails 8.0.1 / My app (with a bunch of gems)
Completed 200 OK in 504ms (Views: 0.5ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms).
-
Ruby 3.4.1 (YJIT) / Rails 8.0.1 / Brand new app (no extra gems)
Completed 200 OK in 50ms (Views: 0.7ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms)
-
Ruby 3.4.1 (YJIT) / Rails 7.2.2.1 / Brand new app
Completed 200 OK in 4ms (Views: 0.9ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms)
-
Ruby 3.2.4 (no YJIT) / Rails 8.0.1 / My app
Completed 200 OK in 355ms (Views: 0.4ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.4ms)
-
Ruby 3.2.4 (no YJIT) / Rails 8.0.1 / Brand new app
Completed 200 OK in 42ms (Views: 0.7ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms)
Macbook PRO M2Max
-
Ruby 3.3.6 (no YJIT) / Rails 8.0.1 / My app
Completed 200 OK in 307ms (Views: 0.3ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms)
-
Ruby 3.3.6 (no YJIT) / Rails 8.0.1 / Brand new app
Completed 200 OK in 56ms (Views: 0.2ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms)
-
Ruby 3.3.6 (no YJIT) / Rails 7.2.2.1 / Brand new app
Completed 200 OK in 1ms (Views: 0.3ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms)
Production server (Docker Docker Hub Container Image Library | App Containerization)
- Ruby 3.3.5 (YJIT) / Rails 8.0.1 / My app
Completed 200 OK in 2ms (Views: 1.5ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.0ms)
In short, no matter the size of the app or the Ruby version, on my 2 macbook laptops (intel + silicon), Rails 8.0.1 is slower than Rails 7.x.
In the different scenarii, the health controller performs correctly. I’ve got no idea who/what is slowing down the request. Probably a faulty middleware.
Before going deeper in the code, I wanted to know if I was the only one to have noticed this.
Thanks!