18 \ May 2019 \ http://www.phparch.com
FEATURE
Department of Breaking Changes:
Launching PHP 7 in a Highly Available Web World
Grant Dickie
For many legacy code bases, upgrading to the latest version of PHP 7 presents an opportunity
not just to use the latest syntax and features, but to address technical debt and streamline
infrastructure. In this article, I’ll share how in moving to PHP 7, the Digital Media team at NPR
prepared to make the move and modernized our deployment practices.
1 Source comes from Google Analytics for
NPR.org
2 NPR One: https://one.npr.org
At Digital Media, a large part of our
job is to manage the digital presence for
National Public Radio. We run twen-
ty-seven servers to serve all of the needs
of our website, our APIs, and even parts
of our on-premises CMS tool, Seamus.
These are highly trafficked applications:
up to 2.5 million unique visitors come
to our website alone^1. All of our web
machines hosting the website are virtual
machines with packages and critical
system settings managed by our private
Chef repository. In 2018, Digital Media
set as a department goal to upgrade
PHP because we knew ahead of time
that PHP 5.6 was reaching end-of-life.
The work eventually got picked up by
the DevOps team because of our versa-
tility in handling both infrastructure
and coding goals. The DevOps team
at Digital Media is heavily Sys Admin
focused, with developers occasionally
cycling onto the team. Tickets usually
focus on quick fixes or improvements
to infrastructure, domain handling,
and general systems support.
Finding Our Scope
For this project, we had two devel-
opers cycle on to the team: myself and
Jason Grosman, a veteran Digital Media
software engineer. As developers, our
mission was to facilitate handling code
issues with our large website codebase.
A project such as this required tedious
amounts of code analysis to watch for
PHP 7.x deprecations and elevated
exceptions. We knew from the start
it wasn’t going to be as simple as apt
update php on all machines and calling it
a day. It had to involve surgically refac-
toring code and upgrading our systems
managed by Chef after refactoring
much of the cookbook code normally
used in our web environments. It was
a balance of classic code auditing and
bare-metal machine management. As
time went on, we found it meant much
more.
Initially, Tyler Sullens, then Senior
DevOps Engineer, wanted to keep
things simple. However, as research
and assumption gathering commenced,
complexity reared its ugly head. First
was the scope of the website codebase
itself. Our website is a monolith, with
pieces added on to it over ten years. As
with other monoliths, it doesn’t just
do what it advertises (i.e., display web
pages). Portions of the website code
run other products like the Carbon
API, the backbone of applications like
NPR One^2. Also part of the codebase is
a fully functional image cropping tool
used in Seamus. It meant that the scope
now covered not just infrastructure, but
multiple codebases and teams.
Figure 1. NPR.org