In-Memory in Solidus
Sorry about the digression into the world of LLM's last week. I'd spent too much energy thinking about that situation (and discussing it with people) to not put at least some of my thoughts down on it.
Today, I want to talk about Solidus. Specifically, about a cool think we did. This PR:
In-memory order updater by benjaminwil · Pull Request #5872 · solidusio/solidus · GitHub
Summary This pull request proposes a replacement to the default Spree::OrderUpdater that has new and improved functionality. We don't expect this to be the default order updater implementation ...
Don't worry. I'm not expecting you to read through that PR, or even have any context on how Solidus works. It's pretty easy to explain what this does and why it's so important.
When you make a change to an order in Solidus (adding/removing an item, for example), Solidus has to do a bunch of work. It might need to recalculate shipping rates, re-evaluate whether promotions are still valid, check whether new promotions need to be applied, calculate tax, and at the end, store all the computed totals (included tax total, additional tax total, shipping total, item total, etc.) on the order.
Previously, the code responsible for this (which we call "the order updater") wrote out changes to database as it went through the various steps involved in this recalculation process. As result, a single order update often involved a ton of separate queries writing to the database.
This PR introduces a new order updater that makes zero writes to the database until the recalculation is fully complete. This has two consequences:
- It made order updates much faster on production systems. We're writing to some of the busiest tables in the database, so reducing the number of writes has a significant impact. Zach from Framework reported 50% faster responses on one endpoint, and 10-20% on others. That's a huge improvement.
- It makes it possible to preview a change to the order. Because the order-updating code now only writes in one place, we've made it possible to disable that write. This is a huge benefit for a variety of use cases, especially subscription businesses who can now deterministically preview subscription orders for customers without actually creating those orders.
I have future dreams for a fully redesigned order updater that uses a configurable middleware design, but this is a great first step towards improving this core piece of the Solidus architecture.
If you're using Solidus, the new order updater is available right now on main and will be in the next release, but not as the default. Please try it out!
I've been slamming through my back log of albums I haven't listened to at a pretty good pace this week. As I write this, I'm half way through Cruel Force's new record. It's classic speed/thrash at its finest. Worth a listen if that's your thing, but I haven't assembled my thoughts on it yet.
I've only listened to two records this week multiple times in between all the new-ish releases; the Neurosis album that I recommended last week and Course of Fate's latest, Behind the Eclipse.
Prog-metal is pretty hit or miss for me. Sometimes the concept resonates with me, but often I'm left bored. No such problem here. One reviewer used the phrase "melancholic anger" to describe the sound of Behind the Eclipse, and I wholly agree. Without that edge, this would be merely a compositionally solid album. The emotional edge turns it into something more.
Check it out.