Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Danny van Kooten:
Moving from PHP (Laravel) to Go
Apr 27, 2017 @ 10:14:04

Danny van Kooten has an interesting post on his site sharing his experience in converting a Laravel-based application to Go, briefly describing some of the changes made, performance differences and the lines of code required.

Earlier this year, I made an arguably bad business decision. I decided to rewrite the Laravel application powering Boxzilla in Go.

No regrets though.

Just a few weeks later I was deploying the Go application. Building it was the most fun I had in months, I learned a ton and the end result is a huge improvement over the old application. Better performance, easier deployments and higher test coverage.

He talks about why he selected Go and some of the external services he would need to interface with to make the transition complete. He then gets into the actual porting of the codebase and some of the challenges involved to replace Laravel functionality. With the application ported, he then compares the performance of the Laravel application versus the Go version, sharing the request of requests/second for each. He finishes out the post looking at a lines of code comparison between the two and how testing was handled on the Go side.

tagged: laravel move rewrite application go summary experience performance

Link: https://dannyvankooten.com/laravel-to-golang/

Exakat Blog:
Moving from array to class
Apr 12, 2017 @ 11:18:42

In a new post to the Exakat blog there's a proposal to replace uses of arrays with classes to make scripts more efficient and handle resources better behind the scenes.

Ever since I started using PHP, arrays have always been my friend. They are versatile, they have a wide range of functions, and they are easy to use. I kept using them versions after versions, and even with PHP 7.2, I still rely on them a lot. Over the years, classes have also made their way into my toolset. They have a different usage : classes are for complex data structures, for business logic. Simple data structures get an array. Until we tried what seemed impossible : a moving from an array to a class.

He mentions some of the recent changes in PHP 7 that make the use of classes over arrays a bit more advantageous. He then gets into how to take advantage of these efficiency benefits in moving from arrays to classes. He uses an example from his own work in the Exacat engine, how he performed the replacement and a small caveat he found when working with functions requiring array input. He ends the post with some of the other benefits from making the move including performance enhancements, readability and reduced memory usage.

tagged: array class performance difference tutorial php7

Link: https://www.exakat.io/moving-from-array-to-class/

Frank de Jonge:
Battle Log: Symfony Routing performance considerations.
Feb 28, 2017 @ 10:55:24

In a new post to his site Frank de Jonge shares his "battle log" when looking into routing performance considerations in Symfony after a "deep dive" into the component's code.

Last week I took a deep dive into Symfony's Routing Component. A project I worked on suffered from a huge performance penalty caused by a routing mistake. This lead me on the path to discovering some interesting performance considerations. Some common practices align nicely with Symfony's optimisations, let's look into those.

He starts off by describing the process he took to start the investigation and what prompted him to investigate the performance issue. He talks about his use of profiling to locate the bottleneck and track down the root cause. He answers the five "why's" about the issue and uses that to guide an approach. Ultimately he located the source of the issue - YAML parsing that shouldn't have been needed - and what the component does to make it more performant in non-development environments. He ends the post with a list of four performance considerations as you're going through your own development to get the most out of the component.

tagged: symfony performance routing considerations deepdive

Link: https://blog.frankdejonge.nl/symfony-routing-performance-considerations/

Hooks, Line, and Sinker: WordPress’ New WP_Hook Class
Jan 25, 2017 @ 10:34:02

The Delicious Brains site has a new post looking at an addition to the WordPress platform allowing you to hook into the core - the WP_Hook class. In the latest release of WordPress this system received a major overhaul and in this article they share what's been updated and what kind of impact it should have on your code.

The hooks system is a central pillar of WordPress and with the 4.7 release a major overhaul of how it works was merged. The Trac ticket that initially raised an issue with the hooks system was logged over 6 years ago. After a few attempts, the updates finally made it into the 4.7 release and the venerable hooks system was overhauled. In this post I want to go over some of the technical changes and decisions that went into the new WP_Hook class. I’ll also go over some of the more interesting aspects of WordPress core development and look into what it takes to overhaul a major feature in WordPress core.

The post starts out with what's changed related to the hooks handling, mostly that the functionality has moved out into a new "WP_Hook" class. This migrates it way from being handled right next to the plugin logic. He details some of the behind the scenes changes to the code and changes made to help improve performance. The post finishes out looking at the backwards compatibility of these changes and what it means for developers upgrading to this new WordPress version (hint: not much).

tagged: tutorial wordpress hooks upgrade class improvement performance

Link: https://deliciousbrains.com/hooks-line-sinker-wordpress-wp-hook-class/

Freek Van der Herten:
Using Varnish on a Laravel Forge provisioned server
Jan 05, 2017 @ 14:19:15

Freek Van der Herten has a post to his site showing you how to set up Varnish with a Laravel Forge server. Forge is a service that makes it simpler to set up and manage servers and the applications installed without having to mess with the details yourself.

For a project we’re working on at Spatie we’re expecting high traffic. That’s why we spent some time researching how to improve the request speed of a Laravel application and the amount of requests a single server can handle. There are many strategies and services you can use to speed up a site. In our specific project one of the things we settled on is Varnish. In this post I’d like to share how to set up Varnish on a Forge provisioned server.

He gives a high level overview of what Varnish is and what benefit it provides to your application (complete with illustrations) and includes a link to a presentation introducing Varnish to PHP developers. Then he moves on to installing Varnish on the server, updating the VCL configuration file and opening a port for you to use when connecting to the Varnish service. He shows the difference in the response headers when Varnish handles the response and the updates you'll need to make to get your Laravel application to play nicely with Varnish with this package.

He ends the post with examples of how to test the performance difference and some final steps to update the config and have it run on port 80 instead of the default 6081.

tagged: laravel forge varnish provision server tutorial setup configure performance

Link: https://murze.be/2017/01/varnish-on-a-laravel-forge-server/

Toon Verwerft:
Optimizing PHP performance by using fully-qualified function calls
Dec 22, 2016 @ 12:27:55

Toon Verwerft has a post on his site with details about a micro-optimization you can use in your PHP application by using fully-qualified function calls, specifying the namespace even for root level PHP functions.

Today, a little conversation on Twitter escalated rather quickly. Apparently PHP runs function calls differently depending on namespaced or non namespaced context. When calling functions in a namespaced context, additional actions are triggered in PHP which result in slower execution. In this article, I'll explain what happens and how you can speed up your application.

The conversation started with [this tweet]. To understand the difference between global and namespaced function calls better, I'll explain what is going on under the hood.

He starts with this "under the hood" functionality, showing an example of a user-defined, root level function and the opcodes that result. He compares this to the opcodes generated when a namespaced function is called and the extra checking that goes into it (including checking both the namespace and the root levels). Another tweet implied that, because of this difference in checking, fully-qualified function calls would result in a performance increase. He set out to prove it as fact and used the phpbench tool to run four tests with various namespaced and non-namespaced examples. He includes the code he used for the testing and the results from a sample execution. There is, in fact, a slight performance gain from the fully-qualified version. He finishes up the post with some suggestions on using this knowledge including the root-level namespacing for built-in PHP functions.

tagged: performance optimize fullyqualified function call benchmark

Link: http://veewee.github.io/blog/optimizing-php-performance-by-fq-function-calls/

Blackfire.io Blog:
PHP 7 performance improvements (5 Part Series)
Dec 13, 2016 @ 11:54:21

The Blackfire.io blog has just wrapped up their series of posts covering some of the performance improvements that came along with PHP 7. In each post of the series they get into detail on one area, sharing some brief code samples and screenshots from the service showing the performance different between PHP 7 and PHP 5.

Julien Pauli, PHP contributor and release manager, details what changed between PHP 5 and PHP 7, and how to migrate and make effective use of the language optimizations. All statements are documented with specific examples and Blackfire profiles.

The topics covered are:

While some of the examples are (sort of) Symfony related, they're mostly about generic language level features and include some other considerations to think about when using the feature and the performance impact on your application.

tagged: blackfireio php7 performance improvement series

Link: https://blog.blackfire.io/category/tech

Blackfire.io Blog:
PHP 7 performance improvements (1/5): Packed arrays
Nov 17, 2016 @ 11:06:53

On the Blackfire.io blog a new tutorial has been posted by Julien Pauli looking at some of the features of PHP 7 and how they relate to the overall performance in this latest major version of the language. In this first post in the series Julien talks about packed arrays.

This blog series will show you what changed inside the Zend engine between PHP 5 and PHP 7 and will detail how you, as a developer, may effectively use the new internal optimizations. We are taking PHP 5.6 as a comparison basis.

[...] Packed arrays is the first great PHP 7 optimization. Packed arrays consume less memory and are a bit faster in many operations than traditional arrays.

He gets into the specifics of how the packed arrays work, mentioning the internal optimization the language does, requiring no intervention in user-land code. He shows the difference between the PHP 5.6 performance and PHP 7 using the Blackfire.io tool - a difference of about a 70% gain.

tagged: php7 blackfire performance packed array feature optimize

Link: https://blog.blackfire.io/php-7-performance-improvements-packed-arrays.html

Tumblr Engineering Blog:
PHP 7 at Tumblr
Nov 11, 2016 @ 13:07:07

The Tumblr Engineering blog has a new post with details about how they made the switch to PHP 7 in their previously PHP 5 codebase (and some of the things they learned along the way).

At Tumblr, we’re always looking for new ways to improve the performance of the site. This means things like adding caching to heavily used codepaths, testing out new CDN configurations, or upgrading underlying software.

Recently, in a cross-team effort, we upgraded our full web server fleet from PHP 5 to PHP 7. The whole upgrade was a fun project with some very cool results, so we wanted to share it with you.

They start off with the timeline of events, starting with the original hackday project out through the final PHP 7 deployment in production less than a year later. They cover some of the testing methods they employed during the transition and the impact of the update on their application on request latency, CPU load and memory usage. They wrap up the post talking about some of the PHP 7-specific things they made use of in their update including anonymous functions and scalar type hinting.

tagged: tumblr php7 update php5 hackday project testing performance

Link: https://engineering.tumblr.com/post/152998126990/php-7-at-tumblr

Symfony Finland:
What's in store for PHP performance?
Oct 18, 2016 @ 10:20:51

On the Symfony Finland blog there's a new post looking ahead at what they see in store for PHP's performance in a post-PHP 7.0.x world.

PHP 7.0 made significant improvements in terms of performance and memory use for real applications. Many applications deliver twice the throughput with much less memory just without any changes to the application code.

But with networked API driven architectures individual response times are increasingly critical for end-user experience. Luckily, there are quite a few unbeaten paths for regarding PHP performance.

These other "unbeaten paths" they mention include a trend towards using asynchronous patterns and the use of application servers (long running PHP processes). There's also mentions of JIT (just in time) compilation, defined request and response objects and the improvement of other possible PHP runtimes.

tagged: language future performance improvement opinion

Link: https://www.symfony.fi/entry/whats-in-store-for-php-performance