Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Advanced Serializing in PHP: Speed it up!

Advanced Serializing in PHP: Speed it up!

Building an API for the biggest retailer of Switzerland has some challenges. We are an API with a lot of extremely complex data. Our bottleneck is and always has been serializing. It has been a long journey for us to get the most performance out of this. We are proud of what we’ve accomplished.

Let me first share what advanced serialization is, and what tools there are out there to solve any needs you may have, we tried them all.

Then I will share our personal journey trying them out. And in the end: A colleague wrote php-to-go so that we could GO beyond PHP, using PHP and GoLang together, for an amazing performance boost.

(Spoiler alert: We found a solution in PHP that we ended up with, and open sourced)

Michelle Sanver

January 24, 2020
Tweet

More Decks by Michelle Sanver

Other Decks in Programming

Transcript

  1. @michellesanver Agenda – Biggest retailer of Switzerland has complex data

    needs! – Advanced serialization in PHP – Using GoLang to GO beyond PHP and speed it up! – Why most PHP serialization libraries are slow for complex data – How we solved the problem in PHP: A 55% overall performance gain, over using JMS. Including a small demo!
  2. DEV: Rae Knowler DEV: Tobias Schultze DEV: Christian Riesen DEV:

    Thereza Scherrer DEV: Martin Janser DEV: Emanuele Panzeri DEV: Michelle Sanver “Cloud Tamer”: Chregu PO: Timur Erdag PO: Colin Frei SM: Léo Davesne DEV: David Buchmann Team: 8 developers, 2 PO’s 1 SM, and… Chregu @michellesanver
  3. @michellesanver API: Lots of data “Out of memory exception on

    100 products… But I’m not gonna wait for 50”
  4. @michellesanver #dpc19 <?php $srcGlob = './models/*.php'; $targetDirectory = getenv('GOPATH').'/src/github.com/ mweibel/php-to-go-tests';

    $packageName = 'models'; $ignoredFiles = []; $ignoredPropertyNames = []; $verbose = true; $generator = new PHPToGo\CodeGenerator($srcGlob, $targetDirectory, $packageName, $ignoredFiles, $ignoredPropertyNames, $verbose); $generator->generate();
  5. @michellesanver #dpc19 <?php use Spiral\Goridge; require "vendor/autoload.php"; $rpc = new

    Goridge\RPC(new Goridge\SocketRelay("127.0.0.1", 6001)); $product = $rpc->call("App.Serialize", “Products"); https://github.com/spiral/goridge
  6. @michellesanver Github Repositories Liip Serializer: liip/serializer Meta data parser: liip/metadata-parser

    JMS Adapter: liip/serializer-jms-adapter Demo code: michellesanver/liip-serializer-demo
  7. @michellesanver Serialization is cool You can do a lot with

    your data, with an advanced serializer alone
  8. @michellesanver You (probably)… Don’t need Liip/Serializer Options out there are

    fast, performant, and easy to use for 99% of the cases.