spree-performance
Installation
SKILL.md
Spree Performance
Most Spree performance work has more leverage than generic Rails tuning because the bottleneck is usually in one of a few known hotspots. This skill covers those.
The biggest leverage areas
In rough order of impact for typical Spree stores:
- Cart pipeline cost on every cart change.
Spree::Cart::Recalculateis the most-run service in the app — every line-item add, remove, and quantity change fires it. A slow recalculate makes the storefront feel sluggish. - Catalog rendering N+1s. Product listing pages load Products, then prices, then images, then variants, then categories — easy to hit dozens of queries per product.
- Search provider latency. Database search degrades past ~10K products. Meilisearch's network round-trip + result deserialization adds up if not bounded.
- Image processing. Generating image variants is slow and CPU-bound — variants are pre-generated in background transform jobs at upload time, and bulk uploads can flood the queue.
- Sidekiq queue backlog. Per-queue weights matter — image processing flooding the
defaultqueue blocks event subscribers from firing in time. - Admin product table. The N+1 problem with 100+ products and all-columns-visible is real.
The cart pipeline
Every cart change runs Spree.cart_recalculate_service (default: Spree::Cart::Recalculate). The chain reads line items, prices, adjustments, shipments, promotions, computes totals, and writes the order back.