Integration of Frameworks for Rapid Web Development

Markus Popp & Duleepa “Dups” Wijayawardhana MySQL Web Team

Download the presentation here http://www.db4free.net/mysqluc2008/frameworks.odp http://www.dups.ca/mysqluc2008/frameworks.odp

Copyright 2008 MySQL

The World’s Most Popular Open Source Database

1

Introduction
• The goal of this presentation:
– – – – give ideas on how to extend PHP/MySQL Web Sites ideas for different development practices ideas to produce more complex sites and applications faster integrating with different technologies including providing a better user experience without you having to recreate the wheel every time.

We'll examine a real-world case study in deploying a frameworksbased architecture on a high capacity, highly available PHP/MySQL web application:
– The MySQL Web Site

Judge for yourself: A sample application – Constellation Phoenix

Copyright 2008 MySQL

The World’s Most Popular Open Source Database

2

A brief introduction to Frameworks (and what we mean by that term)

If a web site was a house that we were building then you could describe it thus:

● ●

The foundation is the server and operating system. LAMP is our foundation The underlying code forms the plumbing, the wooden frame, the electrical wiring and so on. The paint and the decoration is the site and the CSS The people who come to visit and live in it are our users.

We want to make the house building easier. Remember though: every house is different :)

Copyright 2008 MySQL

The World’s Most Popular Open Source Database

3

Frameworks...
• Any code/platform which you can ease and automate the building of an application. New Google App Engine is a framework/platform built on a framework :) • A framework can be for any language that you choose to use on your website: PHP, Java, Javascript/AJAX, HTML, XML, Python, Ruby, Flex. • While LAMP still holds true, the future of the web is about a LAMP stack with added “furniture” from many different sources that truly create a beautiful place to come visit.

Copyright 2008 MySQL

The World’s Most Popular Open Source Database

4

Frameworks: The Good and The Bad
• Easy to deploy, better documentation • Core development is elsewhere • Contribute to the maturing of the Framework independently • Rapid Development: no need to reinvent yourself every time • Good business sense: protection from core developers leaving • Potentially less efficient • Bugs in code of the framework can affect you • The “ARRGH-why-does-itthink-I-am-stupid” scenario – Frameworks can be the Idiot's Guides to programming • The need for work-arounds for specific use-cases (more screaming and thumping of screens)

Copyright 2008 MySQL

The World’s Most Popular Open Source Database

5

Case Study: The MySQL Story

200,000+ Visits/Day with 60,000 downloads and climbing Highly ranked on Alexa. Typical LAMP stack with load balanced servers, dbs etc. The site has grown organically over a decade with various developers coming in and out. We are now 5 developers situated in Australia, Austria, Russia, Canada and the USA
The World’s Most Popular Open Source Database 6

Copyright 2008 MySQL

The Problem
• • • • • • • • Organically grown PHP site Little documentation Little maintenance on the core infrastructure Spending a lot of time on manual processes instead of development. Difficult for a dispersed team to introduce new members So much old code that upgrades to even things at the MySQL/PHP level were frightening things :) Site and processes seemed slow but no metrics to support it. Too much knowledge centred on one or two individuals which increased the “bus factor”
The World’s Most Popular Open Source Database 7

Copyright 2008 MySQL

The Solution?
• Establish the Zend Framework as the PHP Framework for the site combined with existing Smarty and officially adopt YUI as one of the Javascript Frameworks. • Why ZF?
– Zend is a MySQL/Sun Partner – Allows us to break it apart and intermingle with our current site – Much easier to hack to get our current content functioning so we could move on to improve – Favourable initial profile through xdebug and kcachegrind – Well documented – Strong community – Possible move to MVC if we required.

• Oh yeah, and we started to clean up all our code. Mind boggling task...
Copyright 2008 MySQL The World’s Most Popular Open Source Database 8

Copyright 2008 MySQL

The World’s Most Popular Open Source Database

9

Xdebug Profile: MySQL Before
• Profile of the site using code before the reorganization and use of the Zend Framework

Copyright 2008 MySQL

The World’s Most Popular Open Source Database

10

Xdebug Profile: MySQL After
• Final xdebug profile showed that Zend Framework plus our site content was about 1.7 - 2 times faster in processing

Copyright 2008 MySQL

The World’s Most Popular Open Source Database

11

A note about performance tuning
• Profiling is important: Only so much you can do though! • Look to your end-users for true performance tuning • Examine other reasons for performance degradation:
– – – – Bad memory Disk I/O Caching MySQL Performance

• Things like Yslow can give you some good and interesting tips: http://developer.yahoo.com/yslow/

Copyright 2008 MySQL

The World’s Most Popular Open Source Database

12

Sample Application: Constellation Phoenix
• Time for an application built from the ground up:
– http://phoenix.db4free.net

• Remember there are many coding/architecture philosophies, we are not advocating one over the other, in the old PERL motto: TMTOWTDI – There's More Than One Way To Do It – Tim Toady!

Copyright 2008 MySQL

The World’s Most Popular Open Source Database

13

Prototyping with a Framework
Creating a site with a Framework-based platform gives us a very quick prototyping tool for very advanced web sites... here's what it all gives us: • Zend (for PHP)
– – – – – Session Management Authentication REST Server Access Control Lists Different types of architectures (do you want MVC?) – Forms – DB Objects

• YUI (for AJAX)
– Build new interfaces – Create quick AJAX applications

• Smarty (for HTML)
– Defines Views – Move the presentation around without affecting the code

Copyright 2008 MySQL

The World’s Most Popular Open Source Database

14

Now the application...

Copyright 2008 MySQL

The World’s Most Popular Open Source Database

15

Finally...
• Do Experiment! • Don't get caught up in spiritual debates about Frameworks • Analyze based on your needs • Don't try to reinvent the wheel everytime, unless you plan on making a better wheel • Do join the community and help make all this even better! And....

Copyright 2008 MySQL

The World’s Most Popular Open Source Database

16

QUESTIONS?!

Copyright 2008 MySQL

The World’s Most Popular Open Source Database

17

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.