SlideShare a Scribd company logo
Migrate PHP

E-Commerce Site to Go
Weng Wei, Zalora South East Asia Architect

Dec 2013
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)
PoC start in Aug
1st Release in Nov
Currently
• 1st release has been rolled back
• Restructuring, fighting for 2nd release
Today
• Share my painful yet joyful experience
Original Platform
• Classic LAMP
• Alice: Front-end site for catalog display
• Memcached / Solr
• Bob: Back-end site for shopping cart & order
processsing
• MySQL
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 ^_^
• 1st release is experimental
• They said Google is “simple”, only 2 pages
• zalora is two time complicate, it has 4 pages
• catalog
• product detail
• shopping cart
• payment
Experiment Plan
• Rewrite “all 4 pages” in GO!
• Maybe migrate “1 page” in GO first
• nginx route different page to PHP / GO
nginx Alice
memcache
solrAll URLs
BOB
ZRS
Tracking (GA / Webtrekk / etc)
worker
Alice
product

cart..
catalog
nginx
Tracking (GA / Webtrekk / etc)
Eve

(GO)
memcache
solr
BOB
ZRS
worker
Some Prerequisite
Compatible with PHP stack
• Support PHP serialisation/deserialisation in GO
• https://github.com/Wuvist/gophpserialize
• https://github.com/Wuvist/gophpserialize/pull/1
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
PM’s request
• user experience of catalog page need
improvement
• PM:”Give me AJAX…”
Look Good
• Step by step improvement
• Improve user experience: meet PM’s need
• Migrate tech stack: R & D like challenge
Ambitious Plan
• Split Alice PHP(Alice):
• AngularJS (Eve) Front-end MVVM
• GO (Costa) Back-end API
No more PHP
• AngularJS for all page rendering
• GO for all API
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
OpenGraph
• Unlike Google Plus, FB crawler doesn’t support
AJAX
• All FB OpenGraph meta(title / text / picture)
are wrong
• OpenGraph is important to marketing
• AngularJS + Go API architecture is not design to
support such case
• Eve (AngularJS) approach can’t be used
Other Concern
• Why AngularJS? Can’t just jQuery?
• PHP page rendering is fast
Costa (GO) is cool
2nd Release
• PHP + GO, targeted mid Dec
• No AngularJS
Experience
• “Think more before do”
• PHP is good for what it does
• Team consensus is more important
• Better understanding of Go’s potential
• New department for migrate back-end modules
Go’s potential
• GroupCache (Migrate Memcached)
• Shopping Cart
• Order Processing
• Full Page cache on CDN
Q & A

More Related Content

Migrate PHP E-Commerce Site to Go