Slides from LAX & DEN usergroup meetings
Upcoming SlideShare
Loading in...5
×
 

Slides from LAX & DEN usergroup meetings

on

  • 1,402 views

 

Statistics

Views

Total Views
1,402
Views on SlideShare
1,389
Embed Views
13

Actions

Likes
0
Downloads
7
Comments
1

3 Embeds 13

http://frontrangephp.org 7
http://www.frontrangephp.org 5
http://www.netvibes.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Slides from LAX & DEN usergroup meetings Slides from LAX & DEN usergroup meetings Presentation Transcript

  • Bunch of user groups… 
    Kevin Schroeder
    Technology Evangelist
    Zend Technologies
  • About me
    Kevin Schroeder
    Technology Evangelist for Zend
    Programmer
    Sys Admin
    Author
    IBM i Programmer’s Guide to PHP
    You want to do WHAT with PHP?
    Coming up
    Race Ferraris on the weekend
    My Honda has a dismal win record
  • I blog at eschrade.com
    Follow us!
    Zend Technologies
    http://twitter.com/zend
    http://twitter.com/kpschrade (me!)
  • A quick note on Zendcon… BE THERE!!
    • Learn PHP best practices
    • Discover new advances
    • Gain new insights
    • Deploy and scale large PHP applications
    • Explore new technologies like NoSQL and Cloud Computing
    • Learn how to effectively leverage Zend Framework and Zend Framework 2.0
  • Agenda
    You choose
    Seriously (ad hoc is fun)
    But if not
    Intro to Zend/Zend Products
    Deployment
    Unit Testing
    Queuing/Scalability
  • Why do we use PHP?
  • What does Zend do
    Zend Framework
    Zend Studio (8.0 in public beta 1)
    Zend Server
    Monitoring,
    Code tracing (freaking cool!!)
    Job queuing
    HA Session Clustering
    Zend Server Cluster Manager
    Does all of that in a clustered environment
  • Zend Server
  • Zend Server
    The primary reason to use Zend Server is insight
    What went wrong?
    Who did it happen to?
    What do I need to do to fix it?
  • Why do we need diagnostic tools?
  • Let’s slow that down a bit
  • There are several useful features in Zend Server 5
  • Deployment
  • Before we get going
    Who here is a developer?
    Who here is a system administrator?
    Who here has an existing deployment strategy?
    Who here has edited a file in production?
    Who here has wished they hadn’t?
  • Application Stages
    | 15
    Increasing Maturity of PHP Applications
    Development
    Testing/QA
    Staging
    Production
  • Maturity
    | 16
    Increasing Maturity of PHP Applications
    Uptime!!
    Testing & Validating Environment
    Testing & Validating Application
    Distinct Dev Environments
    Benefit
    Where are you?
    Structure
  • Application considerations
    Build the application to be aware of different environments
    Zend_Config_* is good at this
    Do not set the environment type in your code
    Environment variables can be placed in server config
    It means that you won’t accidentally keep your development settings turned on in production
    Make production your default environment
    Keeps accidental data leakage to a minimum
    bit.ly/phpDepApp
  • Deployment Option 1 – rsync
    Benefits
    Easy
    Already installed on your system
    Drawbacks
    No deployment script can be run
    Not integrated with either PHP or the OS
    Rollbacks require rolling back the entire source server
    Does not understand versioning
    One option is to move the source tree prior to the rsync
    Uses xinetd
    bit.ly/phpDepRsync
  • Deployment Option 2 – Source Control
    Benefits
    Easy
    You should already be using source control
    Has versioning
    Can have pre/post install scripts
    Easy to do automatic deployments
    Drawbacks
    Do you want to put details on how to access your source code on your production box?
    Requires that your source control is accessible from production
    Deny access to .svn directories
    bit.ly/phpDepSVN
  • Deployment Option 3 – PEAR
    Benefits
    Designed for PHP
    Very scriptable
    Natural for doing things like clearing a cache
    Has a better understanding of PHP
    Cross platform compatible
    Drawbacks
    Requires admins to be familiar with PHP code
    Limited to PHP deployment
    Available tooling is restrictive/build your own package.xml
    Define standardized locations (www, library, etc.)
    bit.ly/phpDepPEAR
  • Deployment Option 3 – PEAR
    Creating your PEAR Channel
    pear channel-discover pear.pirum-project.org
    pear install pirum/Pirum-beta
    vi /var/www/pear/pirum.xml
    <server>  <name>qa/pear</name>  <summary>OurOrg PEAR channel</summary>  <alias>helloworld</alias>  <url>http://qa/pear/</url></server>
    php ./pirum build /var/www/pear/
  • Deployment Option 3 - PEAR
    Creating your PEAR package
    php ./build-pear.php
    pear package
    pirum add /var/www/pear/ HelloWorld-0.1.3.tgz
  • Deploying your app
    pear channel-discover qa/pear
    pear config-set www_dir /var/www
    pear install helloworld/HelloWorld
    pear clear-cache
    pear upgrade helloworld/HelloWorld
    Roll Back
    pear uninstall helloworld/HelloWorld
    pear install helloworld/HelloWorld-0.1.3
  • Deployment Option 4 - OS-based
    Benefits
    Easily added as part of your server deployment
    Very cloud friendly
    Admins already know how to use it
    Can describe OS-requirements/dependencies
    Downtime limited to actual install, not network transfer time
    Drawbacks
    Depends on environment
    Any PHP deployment scripting needs to be deployed with the application and executed in %post hook
    bit.ly/phpDepYum
  • Which should you use?
    Need something simple? rsync
    Need to deploy to multiple disparate platforms? PEAR
    Need to deploy internally/with minimal developer input?OS (yum/apt)
    If using the OS consider maintaining an internal “blessed” repository instead of depending on the distribution
  • Which should you use?
    Need something simple? rsync
    Need to deploy to multiple disparate platforms? PEAR
    Need to deploy internally/with minimal developer input?OS (yum/apt)
    If using the OS consider maintaining an internal “blessed” repository instead of depending on the distribution
  • Continuous Deployment
    Using automated deployment
    Very tight end-to-end integration
    Requires a lot of trust that the developers have a fully tested application w/ backend and frontend code
    Probably more work to manage if you can count the servers in your production environment with your fingers
    Could be beneficial but make sure you know what you’re doing
    You will need to have several testing experts
    Also…
    Look at what happened the last time we gave control to the machines
    It didn’t work out so well for the humans
  • Takeaways
    No need for copy-and-paste deployment
    No need for (S)FTP
    Have an easy rollback mechanism
    Prepare for errors in deployment
    Try to minimize the amount of scripting needed for deployment
    Consider using VMs on anything important to keep downtime to zero
  • Unit Testing
  • Unit Testing - partially stolen from Matthew Weier O’Phinney
    Why Unit Test?
    Simplify maintenance
    It defines expectations
    It describes behaviors identified by the application
    It tells us when new changes break existing code and behaviors
  • Terms
    Unit Test
    The piece of code you are testing
    Test
    A piece of code that calls the piece of code you’re testing
    Assertion
    Validating return types or results of the test
    Code Coverage
    A report on which lines of code have been tested
    Used to determine additional tests that need to be written
    Continuous Integration
    The continuous application of quality control, i.e. unit tests
  • Unit Testing – What to use
    PHP testing frameworks PHPT
    Used by PHP, and some PEAR and independent libraries
    SimpleTest
    JUnit-style testing framework
    PHPUnit
    JUnit-style testing framework
    De facto industry standard
  • Writing Unit Tests
    Create a test class
    Create one or more methods describing behaviors
    State the behaviors in natural language
    Write code that creates the behavior(s)
    Write code exercising the API
    Write assertions indicating expectations
  • Examples
    Example 1 – Creating a Unit Test for a model in Zend Studio
    Example 2 – Creating a Unit Test based off of Code Coverage
    Example 3 – Testing a Zend Framework controller
    Using Zend_Test_PHPUnit_ControllerTestCase
  • Queuing/Scalable computing
  • Queuing/Scalable computing
    An interesting problem
    Nobody has built a fully scalable application
  • Typical anatomy of a PHP Application
    PHP: Past and Present
    Presentation
    Not so good for defining small bits/queuable functionality
    Application Control
    Database Access
    Business Logic
    Presentation
    Application Control
    Business Logic
    Presentation
    | 37
  • Options
    Use Cron
    Use Gearman
    Use home-grown (don’t do this)
    Use Zend Server Job Queue
  • Characteristics
    Allow for a sledgehammer to hit a machine
    Scalability and High Availability are yin and yang
    A site that can’t keep running is not scalable
    A site that can’t scale will fail (if it gets really popular)
  • Considerations
    Waste disk space
    Control usage (don’t let users do anything they want)
    Pre-calculate as much as possible
    Calculate and cache/store
    Don’t scan large amounts of data
    Keep data processing off the front end servers
    Don’t just cache
    Don’t let it substitute for thought
    Cache hit rates can be meaningless if you have hundreds of cache hits for a request
  • Considerations
    • Build a deployment mechanism with NO hardcoded values
    Decouple/Partition
    Don’t tie everything into the database
    Use queues/messaging
    Stomp interfaces are really good for PHP
  • The Golden Rule of Scalability
    “It can probably wait”
  • When do you not need current data
    Credit card processing?
    Request for the front page?
    Sign in?
    Viewing a shopping cart?
    Displaying a page with ads?
    Answer?
    Almost always
    Data is “out of date” once it leaves the web server
  • What could this look like?
  • Let’s write some code
    (if we have time)
    (no I’m not copping out. We’re all told to show our work in grade scool)
  • Follow us!
    Zend Technologies
    http://twitter.com/zend
    http://twitter.com/kpschrade (me!)
  • Get this information and all the examples at eschrade.com…
  • Remember… BE THERE!!
    • Learn PHP best practices
    • Discover new advances
    • Gain new insights
    • Deploy and scale large PHP applications
    • Explore new technologies like NoSQL and Cloud Computing
    • Learn how to effectively leverage Zend Framework and Zend Framework 2.0