Skip to content

Instantly share code, notes, and snippets.

@gmacdougall
Last active August 29, 2015 14:09
Show Gist options
  • Save gmacdougall/868779d05133680f3859 to your computer and use it in GitHub Desktop.
Save gmacdougall/868779d05133680f3859 to your computer and use it in GitHub Desktop.
Spree Performance Improvements

Goals

  1. Identify Areas of Performance Problems
  2. Prioritize by Pain
  3. Short Term Fixes
  4. Long term Fixes
  5. Bencharks measurements

Areas of Performance Problems

  • touching
    • cascade of touching
  • callbacks
    • after_save, after_update
    • state matchine transitions
  • poor performing DB queries
    • missing index
  • order.update!, order.reload
    • delete & recreate shipments (for no reason)
    • delete & recreate adjustments (for no reason)
  • adjustments & promotions
    • very slow
    • recalculation triggered too foten
  • N + 1 queries
  • Preferences & Configuration

Top 4 things that cause us problems

  • order.update! & reload
  • adjustments & promotions
  • callbacks
  • touching

Short Term Fixes

  • order.update! & reload

    • less persistence
    • what is the correct order of all calculations?
    • what do we actually need to update?
    • can we wait to persist things?
  • adjustments & promotions

    • recalculate in memory
    • persist only if changed
    • investigate storing order data in cache
  • callbacks

    • catalogue where & why?
    • look by class (Order + children, Product + children)
    • remove unnecessary
    • simplify if possible
    • do the same by checkout_flow
  • touching

    • delay touch gem
    • review if touches are needed

Long Term Fixes

  • order.update! & reload

    • splite persistence from logic
    • delay insertion until last possible moment
    • eliminate the state machine
    • improve the state maching & prevent bypassing
    • eliminate order.reloads
    • re-write controller
    • eliminiate need for while order.next
  • adjustments & promotions

    • explicitly define tax & shipping rather than grouping into adjustments
    • delay insertion until last possible moment
    • make the API better and use it internally
  • callbacks

    • move to a set of service objects
    • stop contributors from adding more callbacks
  • touching

    • get support in Rails for delayed touching
    • improve delay touch gem to batch update all records in a table

Benchmark Measurements

  • What is important to be fast?
    • checkout (start to finish)
      • with promos, taxes, zones, multiple stock locations, etc.
    • producxt create (with Variants)
    • product show
    • add to cart
    • update cart
    • promo recalculate
    • home page
  • Tools for measuring performance
    • flood & blits with JMeter scipts
  • Investigate CI query reporting
  • Target Benchmarks
    • memory footprint
    • average response time

Misc. Stuff

  • active Job
  • admin searcher class
  • cart_link
  • review configs that shouldbe on store
  • index guest token
  • country & state cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment