migrate php e-commerce site to go

Post on 12-Jul-2015

155 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Migrate PHPE-Commerce Site to Go

Weng Wei, Zalora South East Asia ArchitectDec 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

Aliceproduct

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

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

• 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

top related