+ All Categories
Home > Software > Refacoring vs Rewriting WixStores

Refacoring vs Rewriting WixStores

Date post: 16-Jul-2015
Category:
Upload: doron-rosenstock
View: 206 times
Download: 1 times
Share this document with a friend
Popular Tags:
75
Wix eCommerce Case Study Refactoring vs Rewriting Doron Rosenstock [email protected]
Transcript

Wix eCommerce Case Study

Refactoring vs Rewriting

Doron [email protected]

What is Wix? What is WixStores?

AgendaPart I

Overview of old system

Problems with the old system

Refactoring vs rewriting

Part II

Problems and solutions

Part III

Lessons learned

3

PART I Wix eCommerce

aka the “old system”

Architecture One monolithic server

Magento as a base

Written in PHP

MySql DB

Redis Cache

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

The GoodStable system

Mature product

Lots of satisfied customers

Domain knowledge

Sounds good right?

?

MONOLITHSERVER CAN’T SCALE

LOW DEVVELOCITY

DEADTECHNOLOGY

Rewriting?Refactoring?

Pros

Will continue to deliver

Only critical sections fixed

Cons

Stuck with dead tech

Still different stack than Wix

Rewriting?

Refactoring?

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?

PART II

aka the “new system”

The Problem: Monolithic Server

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

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

Monolithic Server

Micro-servicesEach 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

Did we solve our problems?

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

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

Lessons Learned about Micro-ServicesError handling and log tracing in the cluster

Synced micro-services (WIP)

Configuration of micro-services (WIP)

Backward and forward compatibility design

Backward and forward compatibility

Service1 V1 Service2 V1

Backward and forward compatibility

Service1 V1 Service2 V1PRODUCT

Backward and forward compatibility

Service1 V1 Service2 V1PRODUCT

Service1 V2

Backward and forward compatibility

Service1 V1 Service2 V1PRODUCT

Service1 V2

PRODUCT

Backward and forward compatibility

Service2 V1

Service1 V2

PRODUCT

Backward and forward compatibility

Service2 V1

Service1 V2

PRODUCT

Service2 V2

PRODUCT’

Backward and forward compatibility

Service2 V1

Service1 V2

PRODUCT

Service2 V2

PRODUCT’

Backward and forward compatibility

Service1 V2 Service2 V2

Backward and forward compatibility

Service1 V1 Service2 V1

Backward and forward compatibility

Service1 V1 Service2 V1PRODUCT

Backward and forward compatibility

Service1 V1 Service2 V1PRODUCT

Service1 V2

Backward and forward compatibility

Service1 V1 Service2 V1PRODUCT

Service1 V2

PRODUCT

Backward and forward compatibility

Service1 V1 Service2 V1PRODUCT

Service1 V2

PRODUCT

Service2 V2

PRODUCT’

Backward and forward compatibility

Service1 V1 Service2 V1PRODUCT

Service1 V2

PRODUCT

Service2 V2

The Problem: Dev Velocity

Web App DBClient

Traditional CRUD

Web App DBClient

Traditional CRUD

upadteProductPRODUCT

Web App DBClient

Traditional CRUD

upadteProductPRODUCT

Web App DBClient

Traditional CRUD

getProductPRODUCT

Web App DBClient

Traditional CRUD

getProductPRODUCT

someCommand

Event Sourcing

Web App DBClient

COMMAND

someCommand

Event Sourcing

Command = “Change product X price to 3$“

Web App DBClient

COMMAND

someCommand

Event Sourcing

Command = “Change product X price to 3$“

Web App DBClient

COMMAND

someCommand

Event Sourcing

Command = “Change product X price to 3$“

Web App DBClient

COMMANDEVENT

event = “Product X price was changed to 3$“

someCommand

Event Sourcing

Command = “Change product X price to 3$“

Web App DBClient

EVENT

event = “Product X price was changed to 3$“

Event Sourcing

Web App DBClient

EVENT

EVENT

EVENT

getProduct

Event Sourcing

Web App DBClient

EVENT

EVENT

EVENT

getProduct

Event Sourcing

Web App DBClient

EVENTEVENTEVENT

getProduct

Event Sourcing

Web App DBClient

VIEW

getProduct

Event Sourcing

Web App DBClient

VIEW

Event Sourcing @ WixStoresFlexible

Immutable

Stateless

DB view

Lessons Learned about Event SourcingParadigm 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?

getProduct

Web App DBClient

EVENT

EVENT

EVENT

Web App

Events DB

Client

EVENT

EVENT

EVENT

getProduct

Web App

Events DB

Client

EVENT

EVENT

EVENT

getProduct

Web App

Events DB

Client

EVENTEVENTEVENT

getProduct

Web App

Events DB

Client

VIEWVIEW

getProduct

Web App

Events DB

Client

VIEW

SnapShots

VIEW

getProduct

Web App

Events DB

Client

VIEW

SnapShots

VIEW

Command Query Responsibility Segregation

@WixStoresSLA concerns:

Strong consistency vs Eventual consistency Viewer vs Editor

Lessons Learned about CQRSAgain - Code complexity

Self-healing

DevOps - two DB’s (Mysql + Mongo)

Performance

So… When should we stop and think?

CQRS CUTTING EDGE TECHNOLOGY

!

MICRO-SERVICES EVENT-SOURCED

LOW DEV VELOCITY

DEAD TECHNOLOGY

MONOLITH SERVER CAN’T SCALE

?

CQRS CUTTING EDGE TECHNOLOGY

!

MICRO-SERVICES EVENT-SOURCED

LOW DEV VELOCITY

DEAD TECHNOLOGY

MONOLITH SERVER CAN’T SCALE

?

Extra ReadingMicro-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/

Questions?

il.linkedin.com/in/dorosen

[email protected]

http://engineering.wix.com


Recommended