Here’s the scenario: you’ve wrote a PHP application that is designed to run on Linux, Apache, and MySQL Now you have a customer that wants to run it on Windows. Or using Oracle. Or they like Memcache instead of APC. How do you do it, without sacrificing performance, stability, simplicity, and your own sanity?
In this talk, we’ll look at how we approached this problem at SugarCRM, and what lessons we learned in the process.
2. Why deployable apps still matter 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 2
3. What I’ll cover Code portability Performance Configuration and Customization Testing/QA @2010 SugarCRM Inc. All rights reserved. 7/22/2010 3
4. Code Portability 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 4 Source: http://www.flickr.com/photos/25339258@N05/2389910825/
5. What we do Limit support to the most common configurations As of SugarCRM 6.0 we officially support: Operating System Windows XP, 2003, 2008, Vista Red Hat 4.x, 5.x Oracle Enterprise Linux 5.1 CentOS 4.x, 5.x Web Server Apache 1.3, 2.0, 2.2 IIS 6/7 using FastCGI Database MySQL 5.0, 5.1 SQL Server 2005, 2008 Oracle 9i, 10g 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 5
6. What we do (cont) PHP Support Matrix 5.2.1 - 5.2.6, 5.2.8 - 5.2.13, 5.3.0 - 5.3.2 Support most common configurations options mbstring.func_overload = 7 error_reporting = E_ALL Require only the most mainline extensions, plus Mbstrings ( for i18n support ) Imap ( if using mail support ) Specific database extension ( mysql, mysqli, oci8, mssql, sqlsrv ) 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 6
7. Build and Deploy We build all 3 editions of SugarCRM from 1 codebase We add code tags around sections specific to a certain version. To test under each different edition, developers can run the build locally Removes code not belonging to the given edition Add appropriate license headers Each check-in triggers a lint check and unit test run against each edition across different platforms. We run nightly builds to run functional tests and to send to QA for manual testing. SODA / SodaMachine – tool to easily write functional tests that run under Watir. 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 7
8. Performance 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 8 Source: http://www.flickr.com/photos/tech1987/501427718/
9. What we do to help performance Caching, and lots of it Smarty template caching Data caching Combine, minify, and version JS / CSS / images Keep SQL queries as simple as possible Provide configuration options to turn off heavy features Enable the application to take advantage of it’s environment Examples: Use APC, memcache, Zend_Cache, wincache with little to no configuration Leverage a slave database for heavy queries Detect Full Text Indexing on SQL Server Detect for certain PHP extensions being enabled. 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 9
10. How we gauge performance Formal testing Use Jmeter (http://jakarta.apache.org/jmeter/) on a load test cluster to test raw response speed. MeterMaid / SugarMMM – open source tool we created to make writing tests easier TidBit – open source tool we created to make huge datasets Instance analysis Monitor web server logs to look for non-cached items Track slow queries Ad-hoc testing Profile PHP execution with XDebug Use Firebug to measure CSS / JS / image payload 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 10
11. Configuration and Customization 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 11 Source: http://www.flickr.com/photos/miskypig/400004362/
12. Making it simple yet powerful for end users Expose configuration options thru multiple channels Remember, not everyone has source access Allow users to customize their UI interface easily Make what should be simple, simple 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 12
13. Making it simple yet powerful for developers Create a safe place to make customizations Avoid painful upgrades Create an easy to use API Well defined and supported. Don’t break it! Create easy to use hooks for modifying existing / adding new functionality Examples from SugarCRM include: Metadata driven views Logic Hooks 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 13
14. Testing/QA 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 14 Source: http://www.flickr.com/photos/cglock/386033158/
15. Testing different configurations Impossible for us to test every single permutation. We use VM stacks; for SugarCRM 6, we use Windows Vista IIS-7 (FastCGI)PHP 5.2.8 MSSQL-2005 (PHPmssql driver) Windows Server 2003 IIS-6 (FastCGI)PHP 5.2.11 MSSQL-2005 (PHPmssql driver) CentOS5 Apache-2.2.11PHP 5.2.9 MySQL-5.1.33 Windows Server 2008 IIS-7 (FastCGI)PHP 5.3.1 MSSQL-2008 (Microsoft sqlsrv driver 1.1) Windows XP Apache-1.3.41PHP 5.2.13 MySQL-5.0.83 Oracle Enterprise Linux 5.1 Apache-2.0.63PHP 5.3.2 ORCL-10g We test both new installations and upgrade scenarios Even customer instances! 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 15
16. About me and my company John Mertic http://jmertic.wordpress.com Twitter: @jmertic jmertic@sugarcrm.com ( Work ) jmertic@php.net ( PHP ) Slides available on slidesharehttp://bit.ly/a7NOR1 SugarCRM http://www.sugarcrm.com We’re hiring! Learn more about SugarCRM’sopen source tools at http://developers.sugarcrm.com/opensource 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 16 Buy my book!
People fear the cloudPeople can’t use the cloudPeople want to use different cloudsOur customer base reflects this ( 1/3 sugar cloud, 1/3 on site, 1/3 on other clouds )
User base is diverse, likes different offerings, and will move between them.Lots of choices ( Web Servers / OSes / Databases / PHP versions ) as well as config possibilitiesHave to cover lots of platforms; can rely on particular hardware or software being available.
PHP matrix covers most of the recent linuxdistros, and updates are easily available if your stack doesn’t match up
Performance story about GNs; very particular to make go fastNeed to balance performance and configurability; make the performance choices that make the most difference, and enable ways for those working with your software to make more.
Try to avoid subqueries as much as possible.
Relate in picture, mention about balance for needed control and simplicity.Talk about how we made this a big deal in Sugar 6