Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Scaling Data in Magento

Scaling Data in Magento

In this technical session, we will look at how you can scale the database horizontally behind Magento. We will discuss the reasons for scaling through replication and how this may impact on your infrastructure, deployment and Magento implementation. Replication brings with it a great deal of benefits but also some pitfalls and potential problems with things such as high rates of data change. We will present simple solutions with MySQL replication and also using Tungsten by Continuent to bring high availability and high performance to MySQL. This will be backed by real data and metrics from one of the highest volume Magento stores in the UK showing how Magento can be deployed at scale with high availability to serve the UK, USA and Australia from a single implementation generating over $100 million in revenue.

Alistair Stead

October 14, 2014
Tweet

More Decks by Alistair Stead

Other Decks in Programming

Transcript

  1. PERFORMANCE IS A MOVING TARGET BUT IF YOU AIM FOR

    IT, YOU STAND A GREATER CHANCE OF HITTING IT #magetitans
  2. THE APACHE / NGINX PROCESS IS BLOCKING WAITING ON PHP...

    PHP IS WAITING ON THE DATABASE... #magetitans
  3. RE-DESIGN QUERIES NOT RECOMMENDED FOR CORE QUERIES BUT SOMETIMES YOU

    HAVE TO... HOWEVER SEND A PATCH BACK TO MAGENTO FOR INCLUSION IN THE NEXT RELEASE #magetitans
  4. EXPAND QUERY CACHE AS MUCH AS YOU CAN CAN YOU

    FIT YOUR ENTIRE DB INTO MEMORY? #magetitans
  5. USE FULL PAGE CACHE STATING THE OBVIOUS BUT IT PROTECTS

    THE DATABASE AT PEAK LOADS #magetitans
  6. USE PROXY OR EDGE CACHES IF YOU DON'T NEED TO

    EXECUTE PHP DON'T #magetitans
  7. AT SOME POINT YOUR CACHE MUST EXPIRE ON HIGHLY MERCHANDISED

    SITES THEN CACHE IS SIMPLY NOT AS EFFECTIVE #magetitans
  8. STEP 3 ENSURE ALL TABLES ARE INNODB SOME LEGACY CODE

    WILL HAVE CREATED MYISAM #magetitans
  9. YOUR TRANSACTION IS NOT COMMITTED? YOU'RE WAITING FOR EXTERNAL SERVICE

    CALLS OR NONE CRITICAL WRITES... #magetitans
  10. LOGGING CAN BE DONE SOMEWHERE ELSE <?xml version="1.0" encoding="UTF-8"?> <frontend>

    <events> <controller_action_predispatch> <observers><log><type>disabled</type></log></observers> </controller_action_predispatch> <controller_action_postdispatch> <observers><log><type>disabled</type></log></observers> </controller_action_postdispatch> ... </events> </frontend> #magetitans
  11. HTTP 101 ONLY MODIFY STATE ON HTTP POST #TIP 1.

    THIS SIMPLE RULE CAN HELP SO MANY ASPECTS OF SCALING #magetitans
  12. MOVE DATA AND LOGIC TO THE CLIENT IF STATE HAS

    NOT CHANGED THEN THE CLIENT SHOULD KNOW ALL IT NEEDS TO KNOW #magetitans
  13. USE JOB QUEUES NON-CRTICAL WRITE OPERATIONS CAN BE PUSHED TO

    THE QUEUE YOU THEN HAVE TO WORK WITH EVENTUAL CONSISTENCY #magetitans
  14. EXAMPLE MODULE CONFIG.XML <?xml version="1.0" encoding="UTF-8"?> <config> <global> <resources> <module_read>

    <connection> <use>core_write</use> </connection> </module_read> </resources> </global> </config> #magetitans
  15. SMART CONNECTION MANAGER A SMART CONNECTION MANAGER THAT CAN ROUTE

    CONNECTIONS BASED ON QUERY CONTENT #magetitans
  16. CONNECTION MANAGER RUNS ON EVERY SERVER AND ALLOWS THE MASTER

    TO FLOAT AROUND THE CLUSTER #magetitans
  17. THE MASTER DATABASE CAN BE MOVED TO ANY NODE WITHOUT

    CONFIG CHANGES OR DOWNTIME #magetitans
  18. ONE SETTING DOES NOT RULE THEM ALL USE YOUR OWN

    METRICS TO DEFINE THE BEST SETTINGS FOR YOUR APPLICATION #magetitans
  19. ONE CONNECTION DOES NOT FIT ALL TASKS USE MANY TUNED

    CONNECTIONS FOR SPECIFIC OPERATIONS TYPES #magetitans
  20. SHARDING THE SMART CONNECTOR CAN RE-WRITE THE QUERY ON THE

    FLY YOU WILL NEED TO INTRODUCE UUIDS FOR KEY TABLES #magetitans
  21. DO YOU HAVE ENOUGH FILE DESCRIPTORS? THIS WILL BE LIMITED

    UNLESS YOU CONFIGURE THE SYSTEM #magetitans