mage titans usa 2016 - ivan chepurnyi - creating micro-services for magento 2.0 performance

28
MICRO-SERVICES MAGENTO 2.0 PERFORMANCE by Ivan Chepurnyi

Upload: stacey-whitney

Post on 08-Jan-2017

89 views

Category:

Technology


0 download

TRANSCRIPT

MICRO-SERVICESMAGENTO 2.0 PERFORMANCE

by Ivan Chepurnyi

 

 

 

 

 

 

ABOUT MEOne of lucky former members of Magento 1.x Core TeamI love to optimize performanceI give trainings and independent consultancy

Let's talk about PHP APP evolution

All started from the good old Apache'smod_php

mod_php

Spawns  new PHP process

Server Thread

Executes PHP script

PHP Initialization

Executes Business Logic

Application Bootstrap

Rendering thePage

DRAWBACKSDynamic server processes was not limitedPHP process is alive unless all bytes transfered to aremote connectionEvery new PHP process takes time to start

Who is still running mod_php on production?

Then started an era of PHP-FPM

PHP-FPM

Waits for Response

Server Thread

Executes PHP File

Takes runningprocess

FPMFastCGI Process

Manager

Process Pool1..n

Executes Business Logic

Application Bootstrap

Rendering thePage

DRAWBACKNot controlling your memory usage, might results in

memory over-usage by one of the processes

Now the era of async I/O PHP apps isemerging...

Application Process Manager

Waits for Response

Server Thread

Fork/Re-use Process with Business Logic

ApplicationMaster Process

Rendering thePage

DRAWBACKSYou have to control used memoryYou have to ensure async IO on any operationIf single line of code fails, all app crashes

Is it possible with Magento 2?

The answer is micro-services...

What is a micro-service?

Micro-service is a component that runs as a separateapplication

MICRO-SERVICE CANDIDATES IN MAGENTO 2.0

SESSIONSEvery page load requires I/O operation to cache storageDynamic requests in Varnish bootstrap full application

SESSION APPLICATION

Start ServerGC Inactive

Sessions every 5minutes

Stop Server

IO to Redis IO to Redis

Lazy Load aSession 

IO to Redis

STOCK PROCESSINGEvery order place request requires database lock on stocktableYou usually sacrifice stock integrity for performancereasons

STOCK APPLICATIONLive proof of concept demo

QUOTE (SHOPPING CARTS)Every change shopping cart is a write DB operation

QUOTE APPLICATIONStore quotes in memoryDelayed DB syncronizationEndless BI possibilities

IMAGE RESIZEImages has to be resized sequentiallyCold image cache perfromance hit

IMAGE MICROSERVICEImage can be resized in parallelMain Application can utilize Async I/O

LEARN MOREReactPHP: PHPFastCGI: Sample counter server:

http://reactphp.org/http://phpfastcgi.github.io/

http://bit.ly/counter-sample

Q&A@IvanChepurnyi

[email protected]