PHP, AWS, & Sleep
Confidently deploy PHP applications to the cloud…
and get some sleep!
Guillermo
(gee-YEAR-moe)
I sorta blog at guillermoandraefisher.com
and infrequently post content using the
@guillermoandrae moniker on various
social media networks.
We’re hiring!
Find opportunities at careers.dominionenterprises.com.
Agenda
◈ Sleep
◈ Continuous Delivery
◈ PHP: The Right Way
◈ Amazon Web Services (AWS)
◈ A Deployment Pipeline
“
Resilience to stress,
emotional regulation, and
interpersonal relationships
are impaired by sleep
deficiency.
Why is Sleep Important?, Michael Twery, Ph.D., Director,
National Center on Sleep Disorders Research, the National
Heart, Lung, and Blood Institute
America’s Most Sleep-Deprived Jobs
America’s 10 Most Sleep-Deprived Jobs, The New York Times, February 22, 2012
#1 6h 57m
Home Health
Aides
#3 7h 1m Police Officers
#4 7h 2m
Physicians,
Paramedics
#7 7h 3m
Computer
Programmers
#9 7h 7m Plant Operators
My Sleeping Problems
◈ Children
My Sleeping Problems
◈ Children
◈ Sleep apnea
“
Sleep apnea is a common
disorder in which you
have one or more pauses
in breathing or shallow
breaths while you sleep.
What is Sleep Apnea?, National Heart, Lung, and
Blood Institute
60+/hour
A diagnosis of severe sleep apnea is given when upwards of 30 apnea
episodes occur every hour.
Symptoms of Sleep Apnea
◈ Loud snoring
◈ Episodes of breathing cessation
◈ Abrupt awakenings w/ shortness of breath
◈ Dry mouth or sore throat
◈ Morning headache
◈ Insomnia
◈ Hypersomnia
◈ Attention problems
◈ Irritability
My Sleeping Problems
◈ Children
◈ Sleep apnea
◈ Code deployments
My Sleeping Problems
◈ Children
◈ Sleep apnea
◈ Dysfunctional code deployments
My Sleeping Solutions
◈ Children Stop having children
My Sleeping Solutions
◈ Children Stop having children
◈ Sleep apnea Diet + exercise or CPAP machine
“
CPAP, or continuous
positive airway pressure,
is a treatment that uses
mild air pressure to keep
the airways open.
What is CPAP?, National Heart, Lung, and Blood
Institute
Choice #1
Eat less steak, exercise more.
EAT LESS STEAK!
Choice #2
Vader sleep.
My Sleeping Solutions
◈ Children Stop having children
◈ Sleep apnea Diet + exercise or CPAP machine
My Sleeping Solutions
◈ Children Stop having children
◈ Sleep apnea Diet + exercise or CPAP machine
◈ Dysfunctional code deployments ?
Symptoms of Dysfunctional Deployments
◈ Inconsistency across environments
◈ Unplanned outages
◈ Infrequent deployments
◈ Little confidence in stability of code changes
◈ Developer burnout
“
Deployment pain can tell you a lot about
your IT performance...We found that where
code deployments are most painful, you’ll find
the poorest IT performance, organizational
performance and culture.
2015 State of DevOps Report, Puppet Labs
$> ssh widget-app-01 # because you might have to make manual
configuration changes, or you need to verify that all of the necessary
files made it onto the server during the deployment, or you need to tail
logs
$> tail -n 100 -f /var/log/httpd/error_log # because the
error reporting policy in place is insufficient/non-existent and/or
your application monitoring system raises so many false alarms that it
is entirely useless
$> mysql -u widget -h db-prod.widgetapp.com -p # because
you’re trying to get fired
My Sleeping Solutions
◈ Children Stop having children
◈ Sleep apnea Diet + exercise or CPAP machine
◈ Dysfunctional code deployments Quit!
11:12 AM Boss: Guillermo, on the smilie face scale, what is the automated test
and deployment procedure like for <REDACTED> ?
11:14 AM Me: There is no smily face sad enough… I build the code, publish the
DLLs, copy it up to staging manually, then execute a series of scripts to
deploy
11:16 AM Boss: Would you be ok getting on that immediately. Sure you know what
needs to be done.
11:17 AM Me: OK. I will have to familiarize myself with a few things in order
to do that but I will get started immediately
Boss: Jenkins is alwasy a good bet, but it is your call. Worth reaching out to
<REDACTED> to exchange ideas.
Thank you
Me: Sure
11:12 AM Boss: Guillermo, on the smilie face scale, what is the automated test
and deployment procedure like for <REDACTED> ?
11:14 AM Me: There is no smily face sad enough… I build the code, publish the
DLLs, copy it up to staging manually, then execute a series of scripts to
deploy
11:16 AM Boss: Would you be ok getting on that immediately. Sure you know what
needs to be done.
11:17 AM Me: OK. I will have to familiarize myself with a few things in order
to do that but I will get started immediately
Boss: Jenkins is alwasy a good bet, but it is your call. Worth reaching out to
<REDACTED> to exchange ideas.
Thank you
Me: Sure
My Sleeping Solutions
◈ Children Stop having children
◈ Sleep apnea Diet + exercise or CPAP machine
◈ Dysfunctional code deployments Continuous
Delivery!
“
Continuous Delivery is a
software development
discipline where you build
software in such a way that the
software can be released to
production at any time.
Continuous Delivery, Martin Fowler
Continuous Delivery
◈ Your software is deployable throughout its lifecycle
◈ Your team prioritizes keeping the software deployable over
working on new features
◈ Anybody can get fast, automated feedback on the production
readiness of their systems any time somebody makes a
change to them
◈ You can perform push-button deployments of any version of
the software to any environment on demand
24xFaster recovery from failure
2.2xEmployees more likely to recommend organization as a great place to work
3xLower change failure rate
Continuous Delivery
◈ Configuration management
◈ Test automation
◈ Build automation
◈ Application monitoring
◈ Infrastructure automation
Continuous Delivery
◈ Configuration management
◈ Test automation
◈ Build automation
◈ Application monitoring
◈ Infrastructure automation
Continuous Delivery
◈ Configuration management
◈ Test automation
◈ Build automation
◈ Application monitoring
◈ Infrastructure automation
Continuous Delivery w/ PHP
◈ PHP: The Right Way
◈ The PHP QA Toolchain
◈ Jenkins
◈ Phing
PHP: Use the current stable version (7.0)
Scalar type
declarations
Now enforceable:
string, int, float
and bool (in addition
to the other types
introduced in PHP 5:
class names,
interfaces, array and
callable)
Anonymous classes
Support for
anonymous classes
has been added via
new class. These can
be used in place of full
class definitions for
throwaway objects.
Group use
declarations
Classes, functions and
constants being
imported from the
same namespace can
now be grouped
together in a single
use statement.
PHP: Use the current stable version (7.0)
PHP7 Infographic, Zend
Mandelbrot fractal
rendering time (s)
PHP 7 0.281
Ruby 2.1 0.684
Python 2.7.8 1.128
Perl 5.18.4 2.083
SOLID Object-Oriented Design
Single Responsibility
Principle (SRP)
A class should have only a single
responsibility
Open/Closed
Principle (OCP)
“software entities … should be
open for extension, but closed for
modification.”
Liskov Substitution
Principle (LSP)
“objects in a program should be
replaceable with instances of
their subtypes without altering
the correctness of that program.”
Interface Segregation
Principle (ISP)
“many client-specific interfaces
are better than one
general-purpose interface.”
Dependency
Inversion Principle
(DIP)
“Depend upon Abstractions. Do
not depend upon concretions.”
The PHP Quality Assurance Toolchain
PHPUnit
The de-facto standard
for unit testing in PHP
projects
vfsStream
A stream wrapper for
a virtual file system
PHPLOC
A tool for quickly
measuring the size of
a PHP project
PHP Mess Detector
Scans PHP source
code and looks for
potential problems
PHP_CodeSniffer
Detects violations of a
defined set of coding
standards
phpDox
The documentation
generator for PHP
projects
Continuous Delivery
◈ Configuration management
◈ Test automation
◈ Build automation
◈ Application monitoring
◈ Infrastructure automation
Getting Started with AWS
Virtual Private Cloud
(VPC)
Isolated cloud
resources
Elastic Compute
Cloud (EC2)
Virtual servers in the
cloud
Relational Database
Service (RDS)
Managed relational
database service
Identity & Access
Manager (IAM)
Manage user access
and encryption keys
CloudWatch
Monitor resources
and applications
Trusted Advisor
Optimize
performance and
security
Getting Started with AWS
Simple Storage
Service (S3)
Scalable storage in the
cloud
CloudFront
Global content
delivery network
Elastic File System
(EFS)
Fully managed file
system for EC2
Route 53
Scalable DNS and
domain name
registration
Simple Email Service
(SES)
E-mail sending and
receiving service
ElastiCache
In-memory cache
“
AWS Elastic Beanstalk is an
easy-to-use service for deploying and
scaling web applications and services
developed with Java, .NET, PHP,
Node.js, Python, Ruby, Go, and Docker
on familiar servers such as Apache,
Nginx, Passenger, and IIS.
AWS Elastic Beanstalk, Amazon Web Services
The .ebextensions Directory
◈ Used to configure EB environments
◈ Can be added to project source code
◈ YAML documents with a .config extension
Continuous Delivery
◈ Configuration management
◈ Test automation
◈ Build automation
◈ Application monitoring
◈ Infrastructure automation
A Deployment Pipeline
Any questions?

PHP, AWS, and Sleep - Hampton Roads DevFest 2016

  • 1.
    PHP, AWS, &Sleep Confidently deploy PHP applications to the cloud… and get some sleep!
  • 2.
    Guillermo (gee-YEAR-moe) I sorta blogat guillermoandraefisher.com and infrequently post content using the @guillermoandrae moniker on various social media networks.
  • 3.
    We’re hiring! Find opportunitiesat careers.dominionenterprises.com.
  • 4.
    Agenda ◈ Sleep ◈ ContinuousDelivery ◈ PHP: The Right Way ◈ Amazon Web Services (AWS) ◈ A Deployment Pipeline
  • 5.
    “ Resilience to stress, emotionalregulation, and interpersonal relationships are impaired by sleep deficiency. Why is Sleep Important?, Michael Twery, Ph.D., Director, National Center on Sleep Disorders Research, the National Heart, Lung, and Blood Institute
  • 6.
    America’s Most Sleep-DeprivedJobs America’s 10 Most Sleep-Deprived Jobs, The New York Times, February 22, 2012 #1 6h 57m Home Health Aides #3 7h 1m Police Officers #4 7h 2m Physicians, Paramedics #7 7h 3m Computer Programmers #9 7h 7m Plant Operators
  • 7.
  • 8.
    My Sleeping Problems ◈Children ◈ Sleep apnea
  • 9.
    “ Sleep apnea isa common disorder in which you have one or more pauses in breathing or shallow breaths while you sleep. What is Sleep Apnea?, National Heart, Lung, and Blood Institute
  • 10.
    60+/hour A diagnosis ofsevere sleep apnea is given when upwards of 30 apnea episodes occur every hour.
  • 11.
    Symptoms of SleepApnea ◈ Loud snoring ◈ Episodes of breathing cessation ◈ Abrupt awakenings w/ shortness of breath ◈ Dry mouth or sore throat ◈ Morning headache ◈ Insomnia ◈ Hypersomnia ◈ Attention problems ◈ Irritability
  • 12.
    My Sleeping Problems ◈Children ◈ Sleep apnea ◈ Code deployments
  • 13.
    My Sleeping Problems ◈Children ◈ Sleep apnea ◈ Dysfunctional code deployments
  • 14.
    My Sleeping Solutions ◈Children Stop having children
  • 15.
    My Sleeping Solutions ◈Children Stop having children ◈ Sleep apnea Diet + exercise or CPAP machine
  • 16.
    “ CPAP, or continuous positiveairway pressure, is a treatment that uses mild air pressure to keep the airways open. What is CPAP?, National Heart, Lung, and Blood Institute
  • 19.
    Choice #1 Eat lesssteak, exercise more.
  • 20.
    EAT LESS STEAK! Choice#2 Vader sleep.
  • 22.
    My Sleeping Solutions ◈Children Stop having children ◈ Sleep apnea Diet + exercise or CPAP machine
  • 23.
    My Sleeping Solutions ◈Children Stop having children ◈ Sleep apnea Diet + exercise or CPAP machine ◈ Dysfunctional code deployments ?
  • 24.
    Symptoms of DysfunctionalDeployments ◈ Inconsistency across environments ◈ Unplanned outages ◈ Infrequent deployments ◈ Little confidence in stability of code changes ◈ Developer burnout
  • 25.
    “ Deployment pain cantell you a lot about your IT performance...We found that where code deployments are most painful, you’ll find the poorest IT performance, organizational performance and culture. 2015 State of DevOps Report, Puppet Labs
  • 26.
    $> ssh widget-app-01# because you might have to make manual configuration changes, or you need to verify that all of the necessary files made it onto the server during the deployment, or you need to tail logs
  • 27.
    $> tail -n100 -f /var/log/httpd/error_log # because the error reporting policy in place is insufficient/non-existent and/or your application monitoring system raises so many false alarms that it is entirely useless
  • 28.
    $> mysql -uwidget -h db-prod.widgetapp.com -p # because you’re trying to get fired
  • 29.
    My Sleeping Solutions ◈Children Stop having children ◈ Sleep apnea Diet + exercise or CPAP machine ◈ Dysfunctional code deployments Quit!
  • 30.
    11:12 AM Boss:Guillermo, on the smilie face scale, what is the automated test and deployment procedure like for <REDACTED> ? 11:14 AM Me: There is no smily face sad enough… I build the code, publish the DLLs, copy it up to staging manually, then execute a series of scripts to deploy 11:16 AM Boss: Would you be ok getting on that immediately. Sure you know what needs to be done. 11:17 AM Me: OK. I will have to familiarize myself with a few things in order to do that but I will get started immediately Boss: Jenkins is alwasy a good bet, but it is your call. Worth reaching out to <REDACTED> to exchange ideas. Thank you Me: Sure
  • 31.
    11:12 AM Boss:Guillermo, on the smilie face scale, what is the automated test and deployment procedure like for <REDACTED> ? 11:14 AM Me: There is no smily face sad enough… I build the code, publish the DLLs, copy it up to staging manually, then execute a series of scripts to deploy 11:16 AM Boss: Would you be ok getting on that immediately. Sure you know what needs to be done. 11:17 AM Me: OK. I will have to familiarize myself with a few things in order to do that but I will get started immediately Boss: Jenkins is alwasy a good bet, but it is your call. Worth reaching out to <REDACTED> to exchange ideas. Thank you Me: Sure
  • 32.
    My Sleeping Solutions ◈Children Stop having children ◈ Sleep apnea Diet + exercise or CPAP machine ◈ Dysfunctional code deployments Continuous Delivery!
  • 33.
    “ Continuous Delivery isa software development discipline where you build software in such a way that the software can be released to production at any time. Continuous Delivery, Martin Fowler
  • 34.
    Continuous Delivery ◈ Yoursoftware is deployable throughout its lifecycle ◈ Your team prioritizes keeping the software deployable over working on new features ◈ Anybody can get fast, automated feedback on the production readiness of their systems any time somebody makes a change to them ◈ You can perform push-button deployments of any version of the software to any environment on demand
  • 35.
    24xFaster recovery fromfailure 2.2xEmployees more likely to recommend organization as a great place to work 3xLower change failure rate
  • 36.
    Continuous Delivery ◈ Configurationmanagement ◈ Test automation ◈ Build automation ◈ Application monitoring ◈ Infrastructure automation
  • 37.
    Continuous Delivery ◈ Configurationmanagement ◈ Test automation ◈ Build automation ◈ Application monitoring ◈ Infrastructure automation
  • 39.
    Continuous Delivery ◈ Configurationmanagement ◈ Test automation ◈ Build automation ◈ Application monitoring ◈ Infrastructure automation
  • 40.
    Continuous Delivery w/PHP ◈ PHP: The Right Way ◈ The PHP QA Toolchain ◈ Jenkins ◈ Phing
  • 41.
    PHP: Use thecurrent stable version (7.0) Scalar type declarations Now enforceable: string, int, float and bool (in addition to the other types introduced in PHP 5: class names, interfaces, array and callable) Anonymous classes Support for anonymous classes has been added via new class. These can be used in place of full class definitions for throwaway objects. Group use declarations Classes, functions and constants being imported from the same namespace can now be grouped together in a single use statement.
  • 42.
    PHP: Use thecurrent stable version (7.0) PHP7 Infographic, Zend Mandelbrot fractal rendering time (s) PHP 7 0.281 Ruby 2.1 0.684 Python 2.7.8 1.128 Perl 5.18.4 2.083
  • 44.
    SOLID Object-Oriented Design SingleResponsibility Principle (SRP) A class should have only a single responsibility Open/Closed Principle (OCP) “software entities … should be open for extension, but closed for modification.” Liskov Substitution Principle (LSP) “objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.” Interface Segregation Principle (ISP) “many client-specific interfaces are better than one general-purpose interface.” Dependency Inversion Principle (DIP) “Depend upon Abstractions. Do not depend upon concretions.”
  • 46.
    The PHP QualityAssurance Toolchain PHPUnit The de-facto standard for unit testing in PHP projects vfsStream A stream wrapper for a virtual file system PHPLOC A tool for quickly measuring the size of a PHP project PHP Mess Detector Scans PHP source code and looks for potential problems PHP_CodeSniffer Detects violations of a defined set of coding standards phpDox The documentation generator for PHP projects
  • 47.
    Continuous Delivery ◈ Configurationmanagement ◈ Test automation ◈ Build automation ◈ Application monitoring ◈ Infrastructure automation
  • 49.
    Getting Started withAWS Virtual Private Cloud (VPC) Isolated cloud resources Elastic Compute Cloud (EC2) Virtual servers in the cloud Relational Database Service (RDS) Managed relational database service Identity & Access Manager (IAM) Manage user access and encryption keys CloudWatch Monitor resources and applications Trusted Advisor Optimize performance and security
  • 50.
    Getting Started withAWS Simple Storage Service (S3) Scalable storage in the cloud CloudFront Global content delivery network Elastic File System (EFS) Fully managed file system for EC2 Route 53 Scalable DNS and domain name registration Simple Email Service (SES) E-mail sending and receiving service ElastiCache In-memory cache
  • 52.
    “ AWS Elastic Beanstalkis an easy-to-use service for deploying and scaling web applications and services developed with Java, .NET, PHP, Node.js, Python, Ruby, Go, and Docker on familiar servers such as Apache, Nginx, Passenger, and IIS. AWS Elastic Beanstalk, Amazon Web Services
  • 60.
    The .ebextensions Directory ◈Used to configure EB environments ◈ Can be added to project source code ◈ YAML documents with a .config extension
  • 61.
    Continuous Delivery ◈ Configurationmanagement ◈ Test automation ◈ Build automation ◈ Application monitoring ◈ Infrastructure automation
  • 62.
  • 64.