SlideShare a Scribd company logo
1 of 92
Download to read offline
Symfony in the Cloud
                                      Kris Wallsmith




                                      February 17, 2010



Wednesday, February 17, 2010
Kris Wallsmith
                 • Freelance web developer,              • JavaScript (moo)
                       consultant, training, audits...
                                                         • @kriswallsmith
                 • 10 years using PHP
                                                         • CTO of Nebul.us
                 • 3 years using symfony
                 • Author of (too) many plugins
                 • 1 year on symfony core team

Wednesday, February 17, 2010
Wednesday, February 17, 2010
What is Nebul.us ?

                 •      Nebul.us is a vibrant and visual life aggregator. In real time you can see
                        what your friends and the public are sharing and discovering online!

                 •      Passively share what you’re doing online

                 •      Show don’t tell




Wednesday, February 17, 2010
Wednesday, February 17, 2010
Wednesday, February 17, 2010
What is Nebul.us really?

                 •      Symfony Framework

                 •      Doctrine ORM

                 •      Zend Framework

                 •      Swift mailer

                 •      and more…


Wednesday, February 17, 2010
What is Nebul.us really?

                 •      Web site

                 •      XML services (Flash and Atom)

                 •      JSON services (browser plugins)

                     •     Up to 12 requests per minute when browsing



Wednesday, February 17, 2010
Prototype



Wednesday, February 17, 2010
Prototype
                                           HTTP

                                            PHP




                                                                    Local Filesystem
                                             Sessions



                                                          Uploads
                               MySQL




                                        ServerGrove VPS

Wednesday, February 17, 2010
What is “The Cloud”?



Wednesday, February 17, 2010
I don’t know.



Wednesday, February 17, 2010
What is “The Cloud”?

                 •      Adds a (big) black box to your stack

                 •      Several virtualized resources

                 •      Scale based on the level of traffic

                 •      Pay only for what you use

                 •      Elastic!

Wednesday, February 17, 2010
It’s cloudy out there

                 •      Amazon

                 •      Rackspace

                 •      Microsoft

                 •      Rightscale



Wednesday, February 17, 2010
Wednesday, February 17, 2010
Production



Wednesday, February 17, 2010
Production
                                            HTTP

                                             PHP




                                                                     Local Filesystem
                                              Sessions



                                                           Uploads
                               MySQL




                                         ServerGrove VPS

Wednesday, February 17, 2010
Production
                                            HTTP

                                             PHP




                                                                     Local Filesystem
                                              Sessions



                                                           Uploads
                               MySQL




                                         ServerGrove VPS

Wednesday, February 17, 2010
No really, it’s that easy.



Wednesday, February 17, 2010
Writing a scalable
                               symfony application
                                     Kris Wallsmith




                                     February 17, 2010



Wednesday, February 17, 2010
Upgrade Points

                 •      Database connections

                 •      File uploads

                 •      Session storage

                 •      Local development

                 •      Deploying


Wednesday, February 17, 2010
Database Connections



Wednesday, February 17, 2010
Database Connections



                 •     Typical database configuration




Wednesday, February 17, 2010
Wednesday, February 17, 2010
Wednesday, February 17, 2010
Database Connections


                 •     One writable “master” connection


                 •     One or more read-only “slave”
                       connections




Wednesday, February 17, 2010
Managing Connections


                 •     Organize read and write connections
                       using a naming convention


                 •     Choose a random read connection




Wednesday, February 17, 2010
Wednesday, February 17, 2010
Wednesday, February 17, 2010
Extend the Doctrine ORM

                 •     Use the appropriate connection

                     • Doctrine_Query
                     • Doctrine_Record
                     • Doctrine_Collection



Wednesday, February 17, 2010
Wednesday, February 17, 2010
Wednesday, February 17, 2010
Wednesday, February 17, 2010
Congure Doctrine


                 •     Set custom query and collection class
                       attributes in manager


                 •     Set custom record class in builder
                       options




Wednesday, February 17, 2010
Wednesday, February 17, 2010
Using the Doctrine DBAL


                 • Doctrine_Manager::connection()
                 • $table->getConnection()




Wednesday, February 17, 2010
Wednesday, February 17, 2010
Wednesday, February 17, 2010
Using the Doctrine DBAL

                 • Doctrine_Manager::getInstance()
                         ->getConnection('master')


                 • $context->getDatabaseManager()
                         ->getDatabase('master')
                         ->getDoctrineConnection()


                 • $configuration
                         ->getWriteConnection()




Wednesday, February 17, 2010
How do we test this?



Wednesday, February 17, 2010
Connection Listener


                 •     Listen to every connection


                 •     Compare type of query to type of
                       connection




Wednesday, February 17, 2010
Wednesday, February 17, 2010
Wednesday, February 17, 2010
Connection Listener


                 •     Add connection listener to debug
                       mode and test suite




Wednesday, February 17, 2010
Wednesday, February 17, 2010
Multiple Connections


                 •     Configure multiple connections to the
                       same database




Wednesday, February 17, 2010
Wednesday, February 17, 2010
Do you want it?
                               Introducing sfDoctrineMasterSlavePlugin




Wednesday, February 17, 2010
File Uploads



Wednesday, February 17, 2010
File Uploads



                 •     Typical upload form




Wednesday, February 17, 2010
Wednesday, February 17, 2010
Wednesday, February 17, 2010
View Layer



                 •     Render the uploaded image




Wednesday, February 17, 2010
Wednesday, February 17, 2010
Amazon S3 Integration


                 •      Must handle file uploads

                 •      Must integrate with the view layer

                 •      Must be disable-able




Wednesday, February 17, 2010
Stream Wrapper


                 •     Zend Amazon S3 stream wrapper

                 • s3://mybucket/image.jpg




Wednesday, February 17, 2010
Wednesday, February 17, 2010
Read / write paths


                 •     Configure read and write upload
                       paths




Wednesday, February 17, 2010
Wednesday, February 17, 2010
Congure Amazon S3


                 •     Toggle integration on/off


                 •     Environment buckets




Wednesday, February 17, 2010
Wednesday, February 17, 2010
Congure File Uploads


                 •     Upload to the write directory


                 •     Custom validated file class




Wednesday, February 17, 2010
Wednesday, February 17, 2010
Wednesday, February 17, 2010
Amazon S3 ACL


                 •     ACL defaults to private


                 •     Extend and change to public-read




Wednesday, February 17, 2010
t, ...
                                  ss ew
                                Ps th
                               M at




Wednesday, February 17, 2010
Wednesday, February 17, 2010
Wednesday, February 17, 2010
View Layer

                 •     Nothing magic


                 •     Custom helper function that uses the
                       congured upload read path


                 •     Search and replace…




Wednesday, February 17, 2010
Wednesday, February 17, 2010
Wednesday, February 17, 2010
Wednesday, February 17, 2010
Session Storage



Wednesday, February 17, 2010
Session Storage



                 •     Default factories configuration




Wednesday, February 17, 2010
Wednesday, February 17, 2010
Wednesday, February 17, 2010
Session Storage



                 •     Store session data in the database




Wednesday, February 17, 2010
Database Session Storage



                 •     Migrate the database




Wednesday, February 17, 2010
Wednesday, February 17, 2010
Local Development



Wednesday, February 17, 2010
Local Development


                 •      One database

                 •      Save uploads to the local filesystem

                 •      Present correct upload path in view layer




Wednesday, February 17, 2010
Deploying



Wednesday, February 17, 2010
Deploying


                 •      Subversion

                     •     svn update

                     •     svn checkout + symlink




Wednesday, February 17, 2010
Deploy with svn update

                 1. Disable

                 2. Update the working copy

                 3. Rebuild model les

                 4. Migrate the database

                 5. Enable


Wednesday, February 17, 2010
Deploy with svn checkout
                 1. Checkout a fresh working copy

                 2. Setup les not in the repository

                 3. Build model les

                 4. Disable current working copy

                 5. Migrate the database

                 6. Update symlink

Wednesday, February 17, 2010
Deploy with svn update

                 1. Disable

                 2. Update the working copy

                 3. Build model les

                 4. Migrate the database

                 5. Enable


Wednesday, February 17, 2010
Deploy with svn checkout
                 1. Checkout a fresh working copy

                 2. Setup les not in the repository

                 3. Build model les

                 4. Disable current working copy

                 5. Migrate the database

                 6. Symlink the new working copy

Wednesday, February 17, 2010
Deployment Strategies

                 •      svn update

                     •     fewer steps

                 •      svn checkout + symlink

                     •     less downtime



Wednesday, February 17, 2010
Automated Deployment



                 •     Rightscale API




Wednesday, February 17, 2010
Wednesday, February 17, 2010
Wednesday, February 17, 2010
Questions?



Wednesday, February 17, 2010

More Related Content

Viewers also liked

Viewers also liked (11)

Symfony und Ember.js auf einer Seite #codetalks14
Symfony und Ember.js auf einer Seite #codetalks14Symfony und Ember.js auf einer Seite #codetalks14
Symfony und Ember.js auf einer Seite #codetalks14
 
Drupal8 for Symfony Developers
Drupal8 for Symfony DevelopersDrupal8 for Symfony Developers
Drupal8 for Symfony Developers
 
Matters of State
Matters of StateMatters of State
Matters of State
 
TomĂĄĹĄ Votruba - Hot news! PHP 7.0, 7.1 a Symfony 3.1, 3.2 a 3.3
TomĂĄĹĄ Votruba - Hot news! PHP 7.0, 7.1 a Symfony 3.1, 3.2 a 3.3TomĂĄĹĄ Votruba - Hot news! PHP 7.0, 7.1 a Symfony 3.1, 3.2 a 3.3
TomĂĄĹĄ Votruba - Hot news! PHP 7.0, 7.1 a Symfony 3.1, 3.2 a 3.3
 
Integrating React.js with PHP projects
Integrating React.js with PHP projectsIntegrating React.js with PHP projects
Integrating React.js with PHP projects
 
Debugging Effectively - PHP UK 2017
Debugging Effectively - PHP UK 2017Debugging Effectively - PHP UK 2017
Debugging Effectively - PHP UK 2017
 
Serverless Architecture
Serverless ArchitectureServerless Architecture
Serverless Architecture
 
New Symfony Tips & Tricks (SymfonyCon Paris 2015)
New Symfony Tips & Tricks (SymfonyCon Paris 2015)New Symfony Tips & Tricks (SymfonyCon Paris 2015)
New Symfony Tips & Tricks (SymfonyCon Paris 2015)
 
Docker workshop
Docker workshopDocker workshop
Docker workshop
 
Unleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ PlatformUnleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ Platform
 
PHP 7.x - past, present, future
PHP 7.x - past, present, futurePHP 7.x - past, present, future
PHP 7.x - past, present, future
 

Similar to Symfony in the Cloud

Node.js and Ruby
Node.js and RubyNode.js and Ruby
Node.js and Ruby
Michael Bleigh
 
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume LaforgeGaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Guillaume Laforge
 

Similar to Symfony in the Cloud (20)

Debugging and Profiling Symfony Apps
Debugging and Profiling Symfony AppsDebugging and Profiling Symfony Apps
Debugging and Profiling Symfony Apps
 
Node.js and Ruby
Node.js and RubyNode.js and Ruby
Node.js and Ruby
 
The Reluctant SysAdmin : 360|iDev Austin 2010
The Reluctant SysAdmin : 360|iDev Austin 2010The Reluctant SysAdmin : 360|iDev Austin 2010
The Reluctant SysAdmin : 360|iDev Austin 2010
 
Building Distributed JavaScript Widgets with jQuery
Building Distributed JavaScript Widgets with jQueryBuilding Distributed JavaScript Widgets with jQuery
Building Distributed JavaScript Widgets with jQuery
 
Large Files without the Trials
Large Files without the TrialsLarge Files without the Trials
Large Files without the Trials
 
GGUG:Practical DSL Design
GGUG:Practical DSL DesignGGUG:Practical DSL Design
GGUG:Practical DSL Design
 
Couchdb
CouchdbCouchdb
Couchdb
 
Architecting for the Enterprise
Architecting for the EnterpriseArchitecting for the Enterprise
Architecting for the Enterprise
 
BRAINREPUBLIC - Powered by no-SQL
BRAINREPUBLIC - Powered by no-SQLBRAINREPUBLIC - Powered by no-SQL
BRAINREPUBLIC - Powered by no-SQL
 
Http Push
Http PushHttp Push
Http Push
 
When is a Website Not Enough? Now.
When is a Website Not Enough? Now.When is a Website Not Enough? Now.
When is a Website Not Enough? Now.
 
Unobtrusive CSS
Unobtrusive CSSUnobtrusive CSS
Unobtrusive CSS
 
Vagrant at LA Ruby
Vagrant at LA RubyVagrant at LA Ruby
Vagrant at LA Ruby
 
No sql findings
No sql findingsNo sql findings
No sql findings
 
Large Files without the Trials
Large Files without the TrialsLarge Files without the Trials
Large Files without the Trials
 
Mobile Development with uPortal and Infusion
Mobile Development with uPortal and InfusionMobile Development with uPortal and Infusion
Mobile Development with uPortal and Infusion
 
A Match Made In The Cloud
A Match Made In The CloudA Match Made In The Cloud
A Match Made In The Cloud
 
Persistence Smoothie
Persistence SmoothiePersistence Smoothie
Persistence Smoothie
 
Automation using-phing
Automation using-phingAutomation using-phing
Automation using-phing
 
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume LaforgeGaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
 

More from Kris Wallsmith

Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)
Kris Wallsmith
 

More from Kris Wallsmith (15)

The View From Inside
The View From InsideThe View From Inside
The View From Inside
 
How kris-writes-symfony-apps-london
How kris-writes-symfony-apps-londonHow kris-writes-symfony-apps-london
How kris-writes-symfony-apps-london
 
Drupal, meet Assetic
Drupal, meet AsseticDrupal, meet Assetic
Drupal, meet Assetic
 
How Kris Writes Symfony Apps
How Kris Writes Symfony AppsHow Kris Writes Symfony Apps
How Kris Writes Symfony Apps
 
Love and Loss: A Symfony Security Play
Love and Loss: A Symfony Security PlayLove and Loss: A Symfony Security Play
Love and Loss: A Symfony Security Play
 
How Kris Writes Symfony Apps
How Kris Writes Symfony AppsHow Kris Writes Symfony Apps
How Kris Writes Symfony Apps
 
Assetic (Zendcon)
Assetic (Zendcon)Assetic (Zendcon)
Assetic (Zendcon)
 
Assetic (OSCON)
Assetic (OSCON)Assetic (OSCON)
Assetic (OSCON)
 
Assetic (Symfony Live Paris)
Assetic (Symfony Live Paris)Assetic (Symfony Live Paris)
Assetic (Symfony Live Paris)
 
Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)Introducing Assetic (NYPHP)
Introducing Assetic (NYPHP)
 
Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3
 
Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony Techniques
 
A Practical Introduction to Symfony2
A Practical Introduction to Symfony2A Practical Introduction to Symfony2
A Practical Introduction to Symfony2
 
Symfony 2
Symfony 2Symfony 2
Symfony 2
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 

Symfony in the Cloud