Download as odp, pdf, or txt
Download as odp, pdf, or txt
You are on page 1of 17

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 frameworks-


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

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
Copyright 2008 MySQL The World’s Most Popular Open Source Database 6
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”
Copyright 2008 MySQL The World’s Most Popular Open Source Database 7
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) • YUI (for AJAX)
– Session Management – Build new interfaces
– Authentication – Create quick AJAX
– REST Server applications
– Access Control Lists • Smarty (for HTML)
– Different types of – Defines Views
architectures (do you want – Move the presentation
MVC?) around without affecting
– Forms the code
– DB Objects

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

You might also like