Webinar recap: Scalability, asynchronous processing, & optimization for PHP

The first episode in our Ask the PHP Experts webinar series happened today. If you missed it, here’s your recap. If you attended, you might have missed a few nuggets. If you attended and paid very close attention, share this post with your colleagues.

Seven ways to boost your PHP performance

  1. Take advantage of the work done by others. An essential element of open source is the ability to share and gain from contributions. PHP is no exception. With PHP 7 and subsequent releases, CPU use is dramatically lowered and performance is significantly better. Zeev shared a few stats from Badoo and Tumblr to illustrate the gains from the language itself.
  2. Measure performance. Maybe it goes without saying, but Zeev felt it important enough to say, again. Set benchmarks and monitor your performance. He suggested watching the webinar he did last year.
  3. Fine tune your infrastructure. Setting the level of concurrency has a direct impact on the load your web server carries. Too low and you’re wasting your hardware. Too high and you’re spinning with no progress on any one item.
  4. Zeev’s definition says it all: “Caching is saving valuable stuff for later use.” He covered OPcache (“There’s no reason not to use it”), to optimize without recompiling. Full-page caching leads to best performance but you can’t always use it depending on the context. However, you can always turn to data caching. In other words, cache to get cash. He suggested that you determine the right duration for your application. Some companies can cache for hours, others days, depending on the frequency of change, or desired updates. Want to see caching live? Zeev demo’d using Zend Server.
  5. Scale either vertically or horizontally. Most will scale horizontally these days, with cloud as an easy path to more servers. You can use the Zend Server auto-scale templates available on AWS and Azure, which also has the advantage of making the application more robust. You can also scale data storage for both database and sessions, with Zend Server offering a turn-key solution for session scaling. For IBM i environments, vertical scaling, more memory, more disk, and more CPU are more common techniques.
  6. “Never do today what you can put off until tomorrow.” Yep, he said it. And in this context, it makes a lot of sense. Don’t tinker with the time-consuming activities during requests, save those for later. This improves perceived performance and overall user experience. Job queue manages the requests to give users a seamless and expeditious UX.
  7. Stay sharp: Optimize (but not every little thing), isolate, and understand what’s happening in your environment and to your application. Can you see what’s causing delays, timeouts, and excessive server loads? Zeev walked through a Z-Ray demo. You can play with it live here too.

[Register for the remainder of this webinar series now]

Audience questions

With all this rich material, it’s no surprise we ran out of time for all the questions, so here they all are with Zeev’s responses:

Q: Could you put some light on what you should be aware of when upgrading applications from PHP 5.6 to PHP 7?

Zeev: Even though the ‘brain surgery’ we did to double the performance of apps didn’t actually introduce any substantial incompatibilities with PHP 5.6, PHP 7.0 is still not entirely compatible with 5.6 – with the biggest breakage being the informed removal of all features which were deprecated in 5.6 or earlier.

You can enable E_DEPRECATED and run through your apps to verify that you’re not using any deprecated features, before migrating to PHP 7.

There’s a comprehensive list of changes here. There are numerous tools you can use to check for PHP 7 compatibility, and Rogue Wave provides assistance in migrating from PHP 5.x to 7.x as well – a transition where we have ample experience.

Q: Is it possible to selectively clear parts of the cache as, for example, one of those recent posts changes, if you also have other data in that cache?

Zeev: Yes. You can see a detailed list of the APIs here, and more specifically here. It’s possible to use multiple namespaces in the cache and clear them selectively.

Q: Is it beneficial to use page caching for real-time applications?

Zeev: Zend Server page caching is useful for any pages that yield the same results for (relatively) prolonged periods of time. As explained, ‘prolonged periods of time’ can often be as little as 30 seconds or even less – depending on the access frequency to the server. If a given real-time app falls into that category – then yes, page caching can be useful for it.

Q: Are job queues shared between servers (i.e., can you have a specific server processing jobs?) or is it just each server processing its own jobs?

Zeev: Yes. Zend Server job queue is very flexible. It’s generally available to the entire cluster, and you can designate as many or as few servers that will execute on job queue as you would like. You can also create multiple queues – per application and even more than one queue per application (e.g., a separate queue for urgent items, and another one for less time-sensitive items).

Q: Give an example of a shared resource with regards to scaling horizontally.

Zeev: One example of a shared resource is a file on the filesystem – but it can also be data in shared memory, etc.

Q: Which is the better web server to run REST web services, Apache or NGINX along with PHP?

Zeev: NGINX is still considered faster but you also need to consider your available skillset and experience when you come to decide which server to choose. If performance is your top consideration – NGINX with PHP in FPM mode is probably the best choice.

[Register for the remainder of this webinar series now]

The following two tabs change content below.

    Christine Bottagaro

    Christine Bottagaro is Chief Marketing Officer for Rogue Wave Software. She leads the marketing organization, driving branding, product messaging and positioning, go-to-market strategy, and sales enablement. Christine designs and drives global growth for technology companies, including Sybase, SAP, and Rally Software. Christine has authored whitepapers and articles on Agile processes, and has defined and instituted Agile Marketing at both Rally and Rogue Wave Software.

    About Christine Bottagaro

    Christine Bottagaro is Chief Marketing Officer for Rogue Wave Software. She leads the marketing organization, driving branding, product messaging and positioning, go-to-market strategy, and sales enablement. Christine designs and drives global growth for technology companies, including Sybase, SAP, and Rally Software. Christine has authored whitepapers and articles on Agile processes, and has defined and instituted Agile Marketing at both Rally and Rogue Wave Software.

    • download my jio app

      my jio app
      Thank you for taking the reader through the entire process from researching topics
      all the way through emailing influencers and tracking analytics once your post goes live.
      Probably one of the best articles I’ve read on this subject. Great job!