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)

01da6d807a29ad6d49801c0157518148?s=128

Michelle Sanver

January 24, 2020
Tweet

Transcript

  1. 6.
  2. 9.

    @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!
  3. 11.

    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
  4. 17.

    @michellesanver API: Lots of data “Out of memory exception on

    100 products… But I’m not gonna wait for 50”
  5. 56.
  6. 57.

    @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();
  7. 60.

    @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
  8. 66.

    @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
  9. 68.

    @michellesanver Serialization is cool You can do a lot with

    your data, with an advanced serializer alone
  10. 69.

    @michellesanver You (probably)… Don’t need Liip/Serializer Options out there are

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

    @michellesanver Thank you By the way, we’re hiring ;) Michelle

    Sanver michelle@liip.ch https://joind.in/talk/02645