$30 off During Our Annual Pro Sale. View Details »

Antonis Zachopoulos - Scaling WooCommerce - WordCamp Athens 2016

Antonis Zachopoulos - Scaling WooCommerce - WordCamp Athens 2016

WordPress Greek Community

November 19, 2016
Tweet

More Decks by WordPress Greek Community

Other Decks in Programming

Transcript

  1. Scaling WooCommerce
    Challenges, Solutions, Bottlenecks
    Antonis Zachopoulos
    Web Developer @ Nevma

    View Slide

  2. Scaling WooCommerce - WordCamp Athens 2016
    The Case
    Book publishing & trading company
    Vast amount of data
    Sync from remote ERP software

    View Slide

  3. Scaling WooCommerce - WordCamp Athens 2016
    The Case

    View Slide

  4. Scaling WooCommerce - WordCamp Athens 2016
    The Challenges
    Data model differences
    The sheer numbers
    100.000+ products (posts)
    2.500+ product categories (taxonomy terms)
    35.000+ authors (product attribute values, a.k.a. taxonomy terms)
    Synchronization must complete overnight
    E-shops must remain responsive to user-actions
    Stick to native WordPress/WooCommerce

    View Slide

  5. Scaling WooCommerce - WordCamp Athens 2016
    The General Principles

    View Slide

  6. Scaling WooCommerce - WordCamp Athens 2016
    Mark Your Progress
    Why iterate all items daily?
    Use timestamps!
    Assume full catalog updates are rare.

    View Slide

  7. Scaling WooCommerce - WordCamp Athens 2016
    Divide & Conquer
    Batches are your friend!
    Minimize loss in case of a failure
    Resume capability

    View Slide

  8. Scaling WooCommerce - WordCamp Athens 2016
    KISS Principle
    Need a web server for syncing?
    No data to present
    Why worry about server limits?
    Run PHP via CLI instead
    Spawn WordPress yourself

    View Slide

  9. Scaling WooCommerce - WordCamp Athens 2016
    The Hidden Obstacles

    View Slide

  10. Scaling WooCommerce - WordCamp Athens 2016
    Querying by meta_value

    View Slide

  11. Scaling WooCommerce - WordCamp Athens 2016
    Querying by meta_value

    View Slide

  12. Scaling WooCommerce - WordCamp Athens 2016
    Querying by meta_value
    “-Um, maybe you’re overreacting?”
    100.000 products * 0.26 sec
    =
    ~7 hours
    (and no actual work done yet...)

    View Slide

  13. Scaling WooCommerce - WordCamp Athens 2016
    Querying by meta_value

    View Slide

  14. Scaling WooCommerce - WordCamp Athens 2016
    Querying by meta_value

    View Slide

  15. Scaling WooCommerce - WordCamp Athens 2016
    Querying by meta_value
    “-Cool! And will that cut it?”
    100.000 products * 0.0004 sec
    =
    ~40 sec
    (and still got plenty of time left!)

    View Slide

  16. Scaling WooCommerce - WordCamp Athens 2016
    The Object Cache
    The what?

    View Slide

  17. View Slide

  18. View Slide

  19. Scaling WooCommerce - WordCamp Athens 2016
    The Object Cache
    Bulk imports: not the typical case
    Maintaining the cache: cost for no gain!
    Time
    Memory
    Can be suspended!

    View Slide

  20. Scaling WooCommerce - WordCamp Athens 2016
    The Object Cache

    View Slide

  21. Scaling WooCommerce - WordCamp Athens 2016
    The Object Cache
    Object Cache active: ~3 sec
    Object Cache suspended: ~0.05 sec
    Time reduced more than 90%!

    View Slide

  22. Scaling WooCommerce - WordCamp Athens 2016
    Term counting
    WordPress counts term assignment to
    posts
    Products === Posts
    Categories / Attribute values === Terms
    Recalculated on every assignment

    View Slide

  23. Scaling WooCommerce - WordCamp Athens 2016
    Taking it all to the
    front-end

    View Slide

  24. Scaling WooCommerce - WordCamp Athens 2016
    The “Shop” page
    Useful for user navigation?
    Consider listing top-level categories
    instead

    View Slide

  25. Scaling WooCommerce - WordCamp Athens 2016
    Product filters
    Displaying 1.000s of values – A Utopia
    Use with caution on high-level lists
    A cross-platform issue
    Need to think smarter!

    View Slide

  26. Scaling WooCommerce - WordCamp Athens 2016
    Product categories
    widget
    Can't do without it
    Beware of the listing depth though!

    View Slide

  27. Scaling WooCommerce - WordCamp Athens 2016
    The right DB engine
    InnoDB VS MyISAM
    Faster joins

    View Slide

  28. Scaling WooCommerce - WordCamp Athens 2016
    Some aces up sleeve
    Use output compression
    (Content-Encoding: gzip)
    Cache like the wind!
    Varnish
    Caching plugin
    MySQL query caching

    View Slide

  29. Scaling WooCommerce - WordCamp Athens 2016
    Wrapping it up
    100.000+
    products (posts)
    2.500+
    product categories (taxonomy terms)
    35.000+
    authors (product attribute values, a.k.a. taxonomy terms)
    Is it feasible?

    View Slide

  30. Scaling WooCommerce - WordCamp Athens 2016
    Wrapping it up
    Plan in advance
    Code with efficiency in mind
    Love your infrastructure
    Think out of the box
    And have the courage to deal with the
    unforeseen!

    View Slide

  31. Scaling WooCommerce - WordCamp Athens 2016
    Fin!
    Thanks for watching!
    Questions?

    View Slide