Transcript
Page 1: Migrate PHP E-Commerce Site to Go

Migrate PHPE-Commerce Site to Go

Weng Wei, Zalora South East Asia ArchitectDec 2013

Page 2: Migrate PHP E-Commerce Site to Go

Zalora South East Asia

• Founded 2012

• Biggest Fashion E-Commence Site in SEA

• SG MY ID HK VN TH PH BN

• About 1000 employee(IT Department 40)

Page 3: Migrate PHP E-Commerce Site to Go

PoC start in Aug

Page 4: Migrate PHP E-Commerce Site to Go

1st Release in Nov

Page 5: Migrate PHP E-Commerce Site to Go

Currently

• 1st release has been rolled back

• Restructuring, fighting for 2nd release

Page 6: Migrate PHP E-Commerce Site to Go

Today

• Share my painful yet joyful experience

Page 7: Migrate PHP E-Commerce Site to Go

Original Platform• Classic LAMP

• Alice: Front-end site for catalog display

• Memcached / Solr

• Bob: Back-end site for shopping cart & order processsing

• MySQL

Page 8: Migrate PHP E-Commerce Site to Go

Why migrate?

• PHP to memcached is fast, but php to solr…

• PHP’s synchronous executing mechanism is the bottleneck

• Related sharing from shooter.cn: https://bitbucket.org/PinIdea/fcgi_ext/ (Chinese)

• I enjoy challenge ^_^

Page 9: Migrate PHP E-Commerce Site to Go

• 1st release is experimental

Page 10: Migrate PHP E-Commerce Site to Go

• They said Google is “simple”, only 2 pages

• zalora is two time complicate, it has 4 pages

• catalog

• product detail

• shopping cart

• payment

Page 11: Migrate PHP E-Commerce Site to Go

Experiment Plan

• Rewrite “all 4 pages” in GO!

• Maybe migrate “1 page” in GO first

• nginx route different page to PHP / GO

Page 12: Migrate PHP E-Commerce Site to Go

nginx Alice

memcache

solrAll URLs

BOB

ZRS

Tracking (GA / Webtrekk / etc)

worker

Page 13: Migrate PHP E-Commerce Site to Go

Aliceproduct

cart..

catalog

nginx

Tracking (GA / Webtrekk / etc)

Eve(GO)

memcache

solr

BOB

ZRS

worker

Page 14: Migrate PHP E-Commerce Site to Go

Some Prerequisite

Page 15: Migrate PHP E-Commerce Site to Go

Compatible with PHP stack

• Support PHP serialisation/deserialisation in GO

• https://github.com/Wuvist/gophpserialize

• https://github.com/Wuvist/gophpserialize/pull/1

Page 16: Migrate PHP E-Commerce Site to Go
Page 17: Migrate PHP E-Commerce Site to Go

Risk Management• Go / PHP stack co-exist

• Go Deployment requite no code change at PHP stack

• Separate deployment for Go

• nginx switch

• Go live & rollback at anytime

Page 18: Migrate PHP E-Commerce Site to Go

PM’s request

• user experience of catalog page need improvement

• PM:”Give me AJAX…”

Page 19: Migrate PHP E-Commerce Site to Go

Look Good

• Step by step improvement

• Improve user experience: meet PM’s need

• Migrate tech stack: R & D like challenge

Page 20: Migrate PHP E-Commerce Site to Go

Ambitious Plan

• Split Alice PHP(Alice):

• AngularJS (Eve) Front-end MVVM

• GO (Costa) Back-end API

Page 21: Migrate PHP E-Commerce Site to Go

No more PHP

• AngularJS for all page rendering

• GO for all API

Page 22: Migrate PHP E-Commerce Site to Go
Page 23: Migrate PHP E-Commerce Site to Go

• Everything was good, GO live!

• Until I took an arrow on my knee

• Until I share the new page link to Facebook

Page 24: Migrate PHP E-Commerce Site to Go

OpenGraph

• Unlike Google Plus, FB crawler doesn’t support AJAX

• All FB OpenGraph meta(title / text / picture)are wrong

• OpenGraph is important to marketing

Page 25: Migrate PHP E-Commerce Site to Go

• AngularJS + Go API architecture is not design to support such case

• Eve (AngularJS) approach can’t be used

Page 26: Migrate PHP E-Commerce Site to Go

Other Concern

• Why AngularJS? Can’t just jQuery?

• PHP page rendering is fast

Page 27: Migrate PHP E-Commerce Site to Go

Costa (GO) is cool

Page 28: Migrate PHP E-Commerce Site to Go

2nd Release

• PHP + GO, targeted mid Dec

• No AngularJS

Page 29: Migrate PHP E-Commerce Site to Go

Experience

• “Think more before do”

• PHP is good for what it does

• Team consensus is more important

• Better understanding of Go’s potential

Page 30: Migrate PHP E-Commerce Site to Go

• New department for migrate back-end modules

Page 31: Migrate PHP E-Commerce Site to Go

Go’s potential

• GroupCache (Migrate Memcached)

• Shopping Cart

• Order Processing

• Full Page cache on CDN

Page 32: Migrate PHP E-Commerce Site to Go

Q & A


Top Related