Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Refacoring vs Rewriting WixStores

652 views

Published on

Published in: Software
  • Be the first to comment

  • Be the first to like this

Refacoring vs Rewriting WixStores

  1. 1. Wix eCommerce Case Study Refactoring vs Rewriting Doron Rosenstock doron@wix.com
  2. 2. What is Wix? What is WixStores?
  3. 3. Agenda Part I Overview of old system Problems with the old system Refactoring vs rewriting Part II Problems and solutions Part III Lessons learned 3
  4. 4. PART I Wix eCommerce aka the “old system”
  5. 5. Architecture One monolithic server Magento as a base Written in PHP MySql DB Redis Cache
  6. 6. Some Numbers ~1M stores Over 5M http requests per day Average response time of ~300 ms 2 data centers + 1 cloud (AWS) Couple of seconds for store provision
  7. 7. The Good Stable system Mature product Lots of satisfied customers Domain knowledge
  8. 8. Sounds good right?
  9. 9. ? MONOLITH SERVER CAN’T SCALE LOW DEV VELOCITY DEAD TECHNOLOGY
  10. 10. Rewriting?Refactoring?
  11. 11. Pros Will continue to deliver Only critical sections fixed Cons Stuck with dead tech Still different stack than Wix Rewriting? Refactoring?
  12. 12. Pros If done correctly, solves old system’s problems Cons Product freeze for 6 months Might fail Pros Will continue to deliver Only critical sections fixed Cons Stuck with dead tech Still different stack than Wix Rewriting?Refactoring?
  13. 13. PART II aka the “new system”
  14. 14. The Problem: Monolithic Server
  15. 15. What’s the problem with Mono-server? One server to rule them all - single point of failure Dependency between unrelated features Need to deploy the entire system each time
  16. 16. What’s the problem with Mono-server? One server to rule them all - single point of failure Dependency between unrelated features Need to deploy the entire system each time
  17. 17. Monolithic Server
  18. 18. Micro-services Each microservice is relatively small Each service can be deployed independently of other services Easier to scale development Improved fault isolation Each service can be developed and deployed independently Eliminates any long-term commitment to a technology stack
  19. 19. Did we solve our problems?
  20. 20. Did we solve our problems? One server to rule them all - single point of failure Dependency between unrelated features Need to deploy the entire system each time
  21. 21. Did we solve our problems? One server to rule them all - single point of failure Dependency between unrelated features Need to deploy the entire system each time
  22. 22. Lessons Learned about Micro-Services Error handling and log tracing in the cluster Synced micro-services (WIP) Configuration of micro-services (WIP) Backward and forward compatibility design
  23. 23. Backward and forward compatibility Service1 V1 Service2 V1
  24. 24. Backward and forward compatibility Service1 V1 Service2 V1PRODUCT
  25. 25. Backward and forward compatibility Service1 V1 Service2 V1PRODUCT Service1 V2
  26. 26. Backward and forward compatibility Service1 V1 Service2 V1PRODUCT Service1 V2 PRODUCT
  27. 27. Backward and forward compatibility Service2 V1 Service1 V2 PRODUCT
  28. 28. Backward and forward compatibility Service2 V1 Service1 V2 PRODUCT Service2 V2
  29. 29. PRODUCT’ Backward and forward compatibility Service2 V1 Service1 V2 PRODUCT Service2 V2
  30. 30. PRODUCT’ Backward and forward compatibility Service1 V2 Service2 V2
  31. 31. Backward and forward compatibility Service1 V1 Service2 V1
  32. 32. Backward and forward compatibility Service1 V1 Service2 V1PRODUCT
  33. 33. Backward and forward compatibility Service1 V1 Service2 V1PRODUCT Service1 V2
  34. 34. Backward and forward compatibility Service1 V1 Service2 V1PRODUCT Service1 V2 PRODUCT
  35. 35. Backward and forward compatibility Service1 V1 Service2 V1PRODUCT Service1 V2 PRODUCT Service2 V2
  36. 36. PRODUCT’ Backward and forward compatibility Service1 V1 Service2 V1PRODUCT Service1 V2 PRODUCT Service2 V2
  37. 37. The Problem: Dev Velocity
  38. 38. Web App DBClient Traditional CRUD
  39. 39. Web App DBClient Traditional CRUD upadteProduct PRODUCT
  40. 40. Web App DBClient Traditional CRUD upadteProduct PRODUCT
  41. 41. Web App DBClient Traditional CRUD getProduct PRODUCT
  42. 42. Web App DBClient Traditional CRUD getProduct PRODUCT
  43. 43. someCommand Event Sourcing Web App DBClient COMMAND
  44. 44. someCommand Event Sourcing Command = “Change product X price to 3$“ Web App DBClient COMMAND
  45. 45. someCommand Event Sourcing Command = “Change product X price to 3$“ Web App DBClient COMMAND
  46. 46. someCommand Event Sourcing Command = “Change product X price to 3$“ Web App DBClient COMMANDEVENT event = “Product X price was changed to 3$“
  47. 47. someCommand Event Sourcing Command = “Change product X price to 3$“ Web App DBClient EVENT event = “Product X price was changed to 3$“
  48. 48. Event Sourcing Web App DBClient EVENT EVENT EVENT
  49. 49. getProduct Event Sourcing Web App DBClient EVENT EVENT EVENT
  50. 50. getProduct Event Sourcing Web App DBClient EVENT EVENT EVENT
  51. 51. getProduct Event Sourcing Web App DBClient VIEW
  52. 52. getProduct Event Sourcing Web App DBClient VIEW
  53. 53. Event Sourcing @ WixStores Flexible Immutable Stateless
  54. 54. DB view
  55. 55. Lessons Learned about Event Sourcing Paradigm shifts - convincing the team… Code complexity Invest time in your framework - it will pay up Solves backward and forward compatibly problem DB size - space problem?
  56. 56. getProduct Web App DBClient EVENT EVENT EVENT
  57. 57. Web App Events DB Client EVENT EVENT EVENT
  58. 58. getProduct Web App Events DB Client EVENT EVENT EVENT
  59. 59. getProduct Web App Events DB Client EVENTEVENTEVENT
  60. 60. getProduct Web App Events DB Client VIEWVIEW
  61. 61. getProduct Web App Events DB Client VIEW SnapShots VIEW
  62. 62. getProduct Web App Events DB Client VIEW SnapShots VIEW Command Query Responsibility Segregation
  63. 63. @WixStores SLA concerns: Strong consistency vs Eventual consistency Viewer vs Editor
  64. 64. Lessons Learned about CQRS Again - Code complexity Self-healing DevOps - two DB’s (Mysql + Mongo) Performance
  65. 65. So… When should we stop and think?
  66. 66. CQRS CUTTING EDGE TECHNOLOGY ! MICRO-SERVICES EVENT-SOURCED LOW DEV VELOCITY DEAD TECHNOLOGY MONOLITH SERVER CAN’T SCALE ?
  67. 67. CQRS CUTTING EDGE TECHNOLOGY ! MICRO-SERVICES EVENT-SOURCED LOW DEV VELOCITY DEAD TECHNOLOGY MONOLITH SERVER CAN’T SCALE ?
  68. 68. Extra Reading Micro-Services: http://www.slideshare.net/aviranwix/scaling-wix-with-microservices-architecture http://martinfowler.com/articles/microservices.html CQRS: http://www.udidahan.com/2009/12/09/clarified-cqrs/ Event Sourcing: http://martinfowler.com/eaaDev/EventSourcing.html http://blog.confluent.io/2015/01/29/making-sense-of-stream-processing/ http://esrad.org/
  69. 69. Questions? il.linkedin.com/in/dorosen doron@wix.com http://engineering.wix.com

×