Slides from LAX & DEN usergroup meetings

1,430 views

Published on

Published in: Technology
1 Comment
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total views
1,430
On SlideShare
0
From Embeds
0
Number of Embeds
16
Actions
Shares
0
Downloads
9
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide

Slides from LAX & DEN usergroup meetings

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

×