Rails 8, Native Auth, and Speed Boosts! 🚀
This time it’s more of a backend-work kind of upgrade.
Living on the Edge 😎
So, I watched the Rails World 2024 opening keynote and got way too excited. Next thing you know, I’m upgrading Visualizer to Rails 8 beta 1. The upgrade went surprisingly smoothly, but I did stumble upon a bug with the Devise dependency. And that’s when a truly dangerous idea struck me: “Hey, why not replace Devise with Rails native authentication?”. Several hours later, there was a PR. 😬
I also wrote a technical post on Radan’s blog. Why there? Well, here I don’t want to be too dev focused, and my website gets 0 traffic. Also, the previous post I wrote there on how to implement infinite pagination with Turbo was very well received, so there’s a precedence. 😅
Goodbye Redis, Hello Solid 👋
Given how well all that went I was further inspired to get rid of another dependency: Redis. So I’ve added Solid Cable and Solid Cache, and just like that, I could remove Redis. Fewer service dependencies -> fewer moving parts -> fewer things can break -> happier life. 🥳
Just Thrust it ⚡
But then I added another new thing: Thruster. It’s basically a tiny go server in front of Rails server (Puma in my case) that speeds up static file serving. There was an issue getting it to work, but the lovely people at Fly helped me out.
I also brought most JavaScript files in-house, reducing my reliance on another dependency: CDN. Highcharts is still being a bit…difficult, so it’s staying on CDN for now. But mark my words, one day I’ll conquer that beast! 🐉
Community Search Speedup 🏎️
There was another thing that I mentioned in Discord: I made a big speedup of community/search for all non-premium users. Since I am premium myself (shocking, I know) I did not realize how slow it was for the majority of the users. But one morning I stumbled into the performance tab and saw mean and p90 response times lounging around 600ms. For context, that was about 15 times slower than what I see. But then I found that the issue was the count
of non-premium shots for the banner. I extracted it to an async call, and voilà! Lightning-fast page for everyone.
Why Stop at Fast? 🚀
Today, I went even further and added trigram indexes on the Roaster and Coffee fields, speeding those queries massively. Don’t believe me? Try it out yourself. It’s practically instant. You might even think it’s broken at first. It’s not, I promise.
A Tiny but Important Change 🔍
Oh, and one more thing: Decent profiles downloaded from Visualizer will no longer be prefixed with Visualizer/
. I saw Damian’s Basecamp post about this breaking D-Flow profile editor, so it had to go. If I remember correctly, I did this because some people wanted to differentiate between their own profiles vs. the ones downloaded from Visualizer. I never really liked that, so now it’s gone. ✨
What’s Next? 👀
As always, you can check out all the changes in the diff. And if you look closely, you might spot some seeds of a super-secret, very exciting new project. Stay tuned!
Enjoy the rest of your weekend, and remember: life’s too short for bad coffee…and slow websites. ☕️