SlideShare a Scribd company logo
1 of 64
Miviejo amigo
Un pocosobre mi Estoytrabajando con webs desde 2001 Me encantainvestigar y meterme en problemas era solo un poco!
青玉男 ao tama o
ao
Y porquéhablar de 1.4?
Preguntas Las hagoyo!
Quepodemosoptimizar?
Carga de proceso Tiempoquepasa el servidorprocesando la web
Proveedor de Internet Desarrolladores Backend Desarrolladores Frontend
Tiempo de Espera
Miexperiencia
La optimizaciónduele Vale la pena el esfuerzo?
Quepodemosmejorar
Hechos
+ Hechos
Herramientas
Debug Tool Bar Todos la conocemos ya!
sfTimerManager $timer = sfTimerManager::getTimer("test"); . . . var_export( $timer->addTime() );
sfTimerManager
sfTimer $timer = new sfTimer ("test"); $timer->startTimer(); . . . var_export( $timer->addTime() );
Doctrine Quepodemosoptimizar
Optimizando Doctrine
Cantidad de Consultas Optimizando Doctrine
Tiempo de Consulta Optimizando Doctrine Tiempoquenos cuesta buscarinformación en la DB
Tiempo de Hidratación Optimizando Doctrine Quees? http://www.doctrine-project.org/documentation/manual/1_2/en/data-hydrators constHYDRATE_RECORD            = 2; constHYDRATE_ARRAY             = 3; constHYDRATE_NONE              = 4; constHYDRATE_SCALAR            = 5; constHYDRATE_SINGLE_SCALAR     = 6; constHYDRATE_ON_DEMAND         = 7; constHYDRATE_ARRAY_HIERARCHY   = 8; constHYDRATE_RECORD_HIERARCHY  = 9;
Tiempo de Hidratación Optimizando Doctrine Quées lo mínimoqueestamosbuscando?
Tiempo de Hidratación Optimizando Doctrine $clist = Doctrine::getTable("Country") ->createQuery() ->select({fields}) ->execute({strategy});
Tiempo de Hidratación Optimizando Doctrine $conn = Doctrine_Manager::connection(); $data = $conn->execute("select * from countries")->fetchAll();
Tiempo de Hidratación Optimizando Doctrine Para que quiero el ORM? $conn= Doctrine_Manager::connection(); Para manejarlasconexiones!
Doctrine? Unainteresanteparadoja!
Tiempo de Hidratación Optimizando Doctrine Ejemplo!
Tiempo de Hidratación Optimizando Doctrine UserTable::getInstance()         ->createQuery()         ->select ("id, name, surname, age")         ->where("is_deleted = ?", false)         ->andWhere("is_closed = ? ", false)  ->andWhere(”age > ? ",  50 ) ->execute( array(),  Doctrine_Core::HYDRATE_ARRAY); UserTable::getInstance()         ->createQuery()         ->select ("id, name, surname, age")         ->where("is_deleted = ?", false)         ->andWhere("is_closed = ? ", false) 	->andWhere(”age > ? ",  50 ) ->execute( ); Estrategia
Tiempo de Hidratación Optimizando Doctrine Compatibilidad entre estrategias en la vista <td> <?phpecho$user->get("name") ?></td> <td> <?phpecho$user->name ?></td> <?php$user= $user->getRawValue() ?> <td> <?phpecho$user["name"] ?></td>
T.  Conversión de Consulta Optimizando Doctrine $q = Doctrine::getTable("Country")->createQuery(); $q->getSqlQuery(). 0.006 seg Gallery1..n GalleryImagesn..1 Image $q= Doctrine::getTable("Gallery")->createQuery("g")->leftJoin("g.images"); $q->getSqlQuery(); 0.1 seg
Conteo de Registros Optimizando Doctrine $clist = Doctrine::getTable("Country”) ->findAll()->count(); ->createQuery()->count(); ->createQuery()->select("count(id)")->execute( array (), Doctrine::HYDRATE_NONE ); $conn->execute("select count(id) as count from countries")->fetchAll(); 0.2 seg 0.0056 seg 0.01 seg 0.00087 seg
PDO http://es2.php.net/manual/en/book.pdo.php
Select, Joins e Indices Optimizando Doctrine $articles = Doctrine::getTable("Article")->createQuery("a")->leftJoin("a.pages p") ->limit(100)->execute(); ->limit(1000)->execute(); ->limit(100)->execute( array(), Doctrine::HYDRATE_ARRAY ); ->limit(1000)->execute( array(), Doctrine::HYDRATE_ARRAY  ); 2.93 seg 30.80 seg 0.20 seg 1.37 seg
Select, Joins e Indices Optimizando Doctrine SELECT c.id, c.name , c.resume, c.disclaimer, c.product , c.description, br />UNIX_TIMESTAMP(c.valid_start_at) as valid_start, UNIX_TIMESTAMP(c.valid_end_at) as valid_end, UNIX_TIMESTAMP(c.promotion_start_at) as promotion_start, UNIX_TIMESTAMP(c.promotion_end_at) as promotion_end, UNIX_TIMESTAMP(c.publish_at) as publish, br />c.tracking_click, c.tracking_save_count, c.visibility_status_id, c.print_coupon, c.mobile_coupon, c.online_coupon, c.company_id,  cp.comercial_name as company_name, c.redemption_price as redemption_price, br />CONCAT_WS(',', GROUP_CONCAT(DISTINCT ca.attributes_id SEPARATOR ",") ) as attributes, br />CONCAT_WS(',', GROUP_CONCAT(DISTINCT ca.root_id SEPARATOR ",") ) as roots, br />CONCAT_WS(',', GROUP_CONCAT(DISTINCT ca.level SEPARATOR ",") ) as levels, br />CONCAT_WS(',', GROUP_CONCAT(DISTINCT cs.store_id SEPARATOR ",") ) as stores, br />CONCAT_WS(',', GROUP_CONCAT(DISTINCT uc.user_id SEPARATOR ",") ) as users, br />CONCAT_WS(',', GROUP_CONCAT(DISTINCT cs.state_id SEPARATOR ","), IF(online_coupon = 1, 0, null) ) as states,  CONCAT_WS(',', IF( print_coupon = 1, 1,null), IF( mobile_coupon = 1, 2,null), IF( online_coupon = 1, 3,null) ) as types, br />CONCAT_WS(',', GROUP_CONCAT(DISTINCT cs.postal_code SEPARATOR ",") ) as postal_codes_ids, br />CONCAT_WS(' ', GROUP_CONCAT(DISTINCT cs.city_name SEPARATOR " ") ) as cities, br />CONCAT_WS(' ', GROUP_CONCAT(DISTINCT s.road_name SEPARATOR " ") ) as roads, br />CONCAT_WS(' ', GROUP_CONCAT(DISTINCT s.comercial_name SEPARATOR " ") ) as names, br />CONCAT_WS(' ', GROUP_CONCAT(DISTINCT s.postal_code SEPARATOR " ") ) as postal_codes, br />CONCAT_WS(' ', GROUP_CONCAT(DISTINCT sa.name SEPARATOR " ") ) as state_names br />FROM ( ( ( (coupons c LEFT JOIN  coupon_attributes ca ON c.id = ca.coupons_id ) LEFT JOIN coupon_stores cs ON c.id = cs.coupon_id) LEFT JOIN sf_guard_user_coupons uc ON c.id = uc.coupon_id  ) LEFT JOIN stores s ON cs.store_id = s.id ) LEFT JOIN states sa ON cs.state_id = sa.id  LEFT JOIN companies cp ON cp.id=c.company_id br />WHERE  ( c.administrative_status_id = 1 AND c.publish_at < NOW() AND DATE(c.valid_end_at) + INTERVAL 1439 HOUR_MINUTE > NOW() )  br />GROUP BY c.id
Select, Joins e Indices Optimizando Doctrine ✔
Vistas Quepodemosoptimizar
Optimizando Vistas
Inclusión de Partials Optimizando Vistas
Listados y consultasanidadas Optimizando Vistas <?phpforeach($results as $plan): ?> 	<li> 	<?php echo $plan->get(“title”) ?>  	(<?php echo $plan->countAssistants()?> ) </li> <?phpendforeach; ?> Consultasanidadas
La Cache Guardemos en Cache parasalvaralgunos (muchos) milisegundos
La Cache
Cómofuncionan La Cache
Cómofuncionan La Cache la cache de de vistas factories.yml view_cache_manager: class: sfViewCacheManager     param: cache_key_use_vary_headers: true cache_key_use_host_name:    true view_cache: class: sfFileCache     param: automatic_cleaning_factor: 0 cache_dir:                 %SF_TEMPLATE_CACHE_DIR%       lifetime:                  86400       prefix:                    %SF_APP_DIR%/template
Cómofuncionan La Cache la cache de de Doctrine $manager->setAttribute(Doctrine_Core::ATTR_QUERY_CACHE, $cacheDriver); $conn->setAttribute(Doctrine_Core::ATTR_QUERY_CACHE, $cacheDriver); $q = Doctrine_Query::create() ->useQueryCache(new Doctrine_Cache_Apc());  $manager->setAttribute(Doctrine_Core::ATTR_RESULT_CACHE, $cacheDriver); $conn->setAttribute(Doctrine_Core::ATTR_RESULT_CACHE, $cacheDriver); $manager->setAttribute(Doctrine_Core::ATTR_RESULT_CACHE_LIFESPAN, 3600); ->useResultCache(true);
Cómomodificarla La Cache la cache de de vistas
Cómomodificarla La Cache la cache de de vistas class sfViewCacheManager public function setPageCache($uri) public function getPageCache($uri)
Cómomodificarla La Cache la cache de de vistas class xyzCache extendssfCache abstract public function get ($key, $default = null); abstract public function has ($key); abstract public function set ($key, $data, $lifetime = null); abstract public function remove ($key); abstract public function removePattern($pattern); abstract public function clean ($mode = self::ALL);
Drivers La Cache
OptimizandoSymfony Podemoshaceralgo?
No mucho!
Quepodemoshacer? OptimizandoSymfony Desabilitar TODO lo que no se USE Helpers Logs Routing Cache Plugins que no usen100%
Una idea!
Front Controller OptimizandoSymfony require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php'); $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false); sfContext::createInstance($configuration)->dispatch();
Front Controller OptimizandoSymfony require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php'); $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'dev', true); $manager = new sfDatabaseManager($configuration); $data = Doctrine::getTable(“Article”)->createQuery()->etc(); $view = CMSProcess::ProcessData( $data ); echo $view;
Gracias!
Preguntas Ahora si las hacen Uds!
Miviejo amigo josetonyp@latizana.com @josetonyp aotamao@latizana.com

More Related Content

What's hot

4. Метапрограмиране
4. Метапрограмиране4. Метапрограмиране
4. Метапрограмиране
Stefan Kanev
 
Yearning jQuery
Yearning jQueryYearning jQuery
Yearning jQuery
Remy Sharp
 
Itsecteam shell
Itsecteam shellItsecteam shell
Itsecteam shell
ady36
 
Private slideshow
Private slideshowPrivate slideshow
Private slideshow
sblackman
 

What's hot (18)

4. Метапрограмиране
4. Метапрограмиране4. Метапрограмиране
4. Метапрограмиране
 
Shortcodes In-Depth
Shortcodes In-DepthShortcodes In-Depth
Shortcodes In-Depth
 
SugarCon 2010 - Best Practices for Creating Custom Apps in Sugar
SugarCon 2010 - Best Practices for Creating Custom Apps in SugarSugarCon 2010 - Best Practices for Creating Custom Apps in Sugar
SugarCon 2010 - Best Practices for Creating Custom Apps in Sugar
 
What your testtool doesn't tell you
What your testtool doesn't tell youWhat your testtool doesn't tell you
What your testtool doesn't tell you
 
Yearning jQuery
Yearning jQueryYearning jQuery
Yearning jQuery
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBenelux
 
Security: Odoo Code Hardening
Security: Odoo Code HardeningSecurity: Odoo Code Hardening
Security: Odoo Code Hardening
 
Pursuing the Strong, Not So Silent Type: A Haskell Story
Pursuing the Strong, Not So Silent Type: A Haskell StoryPursuing the Strong, Not So Silent Type: A Haskell Story
Pursuing the Strong, Not So Silent Type: A Haskell Story
 
Haskell is Not For Production and Other Tales
Haskell is Not For Production and Other TalesHaskell is Not For Production and Other Tales
Haskell is Not For Production and Other Tales
 
Sk.php
Sk.phpSk.php
Sk.php
 
WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011
WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011
WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011
 
Html
HtmlHtml
Html
 
Nop2
Nop2Nop2
Nop2
 
Odoo - CMS performances optimization
Odoo - CMS performances optimizationOdoo - CMS performances optimization
Odoo - CMS performances optimization
 
Secure Coding With Wordpress (BarCamp Orlando 2009)
Secure Coding With Wordpress (BarCamp Orlando 2009)Secure Coding With Wordpress (BarCamp Orlando 2009)
Secure Coding With Wordpress (BarCamp Orlando 2009)
 
Itsecteam shell
Itsecteam shellItsecteam shell
Itsecteam shell
 
Private slideshow
Private slideshowPrivate slideshow
Private slideshow
 
Speeding up Red Team engagements with carnivorall
Speeding up Red Team engagements with carnivorallSpeeding up Red Team engagements with carnivorall
Speeding up Red Team engagements with carnivorall
 

Viewers also liked

Symfony: Domesticando los Formularios
Symfony: Domesticando los FormulariosSymfony: Domesticando los Formularios
Symfony: Domesticando los Formularios
Jose Antonio Pio
 

Viewers also liked (9)

Clase 4 routing
Clase 4 routingClase 4 routing
Clase 4 routing
 
Symfony: Domesticando las Vistas
Symfony: Domesticando las VistasSymfony: Domesticando las Vistas
Symfony: Domesticando las Vistas
 
Symfony: Domesticando los Formularios
Symfony: Domesticando los FormulariosSymfony: Domesticando los Formularios
Symfony: Domesticando los Formularios
 
Symfony2 and AngularJS
Symfony2 and AngularJSSymfony2 and AngularJS
Symfony2 and AngularJS
 
Desarrollo Web Ágil con Symfony, Bootstrap y Angular
Desarrollo Web Ágil con Symfony, Bootstrap y AngularDesarrollo Web Ágil con Symfony, Bootstrap y Angular
Desarrollo Web Ágil con Symfony, Bootstrap y Angular
 
The Buyer's Journey - by Chris Lema
The Buyer's Journey - by Chris LemaThe Buyer's Journey - by Chris Lema
The Buyer's Journey - by Chris Lema
 
Classroom Management Tips for Kids and Adolescents
Classroom Management Tips for Kids and AdolescentsClassroom Management Tips for Kids and Adolescents
Classroom Management Tips for Kids and Adolescents
 
The Presentation Come-Back Kid
The Presentation Come-Back KidThe Presentation Come-Back Kid
The Presentation Come-Back Kid
 
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job? Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
 

Similar to Symfony 1, mi viejo amigo

Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On Rails
Wen-Tien Chang
 
5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter
nicdev
 
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
Carles Farré
 
Testing persistence in PHP with DbUnit
Testing persistence in PHP with DbUnitTesting persistence in PHP with DbUnit
Testing persistence in PHP with DbUnit
Peter Wilcsinszky
 

Similar to Symfony 1, mi viejo amigo (20)

Using of TDD practices for Magento
Using of TDD practices for MagentoUsing of TDD practices for Magento
Using of TDD practices for Magento
 
What's New in ZF 1.10
What's New in ZF 1.10What's New in ZF 1.10
What's New in ZF 1.10
 
Advanced and Hidden WordPress APIs
Advanced and Hidden WordPress APIsAdvanced and Hidden WordPress APIs
Advanced and Hidden WordPress APIs
 
Smarty
SmartySmarty
Smarty
 
Satchmo
SatchmoSatchmo
Satchmo
 
What's new in Rails 2?
What's new in Rails 2?What's new in Rails 2?
What's new in Rails 2?
 
Curso Symfony - Clase 2
Curso Symfony - Clase 2Curso Symfony - Clase 2
Curso Symfony - Clase 2
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On Rails
 
Plone Interactivity
Plone InteractivityPlone Interactivity
Plone Interactivity
 
State Machines to State of the Art
State Machines to State of the ArtState Machines to State of the Art
State Machines to State of the Art
 
Manish
ManishManish
Manish
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter
 
Django - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosDjango - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazos
 
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
 
Create a web-app with Cgi Appplication
Create a web-app with Cgi AppplicationCreate a web-app with Cgi Appplication
Create a web-app with Cgi Appplication
 
WordPress Standardized Loop API
WordPress Standardized Loop APIWordPress Standardized Loop API
WordPress Standardized Loop API
 
WordPress APIs
WordPress APIsWordPress APIs
WordPress APIs
 
Testing persistence in PHP with DbUnit
Testing persistence in PHP with DbUnitTesting persistence in PHP with DbUnit
Testing persistence in PHP with DbUnit
 
Intro Open Social and Dashboards
Intro Open Social and DashboardsIntro Open Social and Dashboards
Intro Open Social and Dashboards
 

Recently uploaded

Recently uploaded (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Symfony 1, mi viejo amigo

  • 1.
  • 2.
  • 4. Un pocosobre mi Estoytrabajando con webs desde 2001 Me encantainvestigar y meterme en problemas era solo un poco!
  • 6. ao
  • 10. Carga de proceso Tiempoquepasa el servidorprocesando la web
  • 11. Proveedor de Internet Desarrolladores Backend Desarrolladores Frontend
  • 14. La optimizaciónduele Vale la pena el esfuerzo?
  • 19. Debug Tool Bar Todos la conocemos ya!
  • 20. sfTimerManager $timer = sfTimerManager::getTimer("test"); . . . var_export( $timer->addTime() );
  • 22. sfTimer $timer = new sfTimer ("test"); $timer->startTimer(); . . . var_export( $timer->addTime() );
  • 25. Cantidad de Consultas Optimizando Doctrine
  • 26. Tiempo de Consulta Optimizando Doctrine Tiempoquenos cuesta buscarinformación en la DB
  • 27. Tiempo de Hidratación Optimizando Doctrine Quees? http://www.doctrine-project.org/documentation/manual/1_2/en/data-hydrators constHYDRATE_RECORD = 2; constHYDRATE_ARRAY = 3; constHYDRATE_NONE = 4; constHYDRATE_SCALAR = 5; constHYDRATE_SINGLE_SCALAR = 6; constHYDRATE_ON_DEMAND = 7; constHYDRATE_ARRAY_HIERARCHY = 8; constHYDRATE_RECORD_HIERARCHY = 9;
  • 28. Tiempo de Hidratación Optimizando Doctrine Quées lo mínimoqueestamosbuscando?
  • 29. Tiempo de Hidratación Optimizando Doctrine $clist = Doctrine::getTable("Country") ->createQuery() ->select({fields}) ->execute({strategy});
  • 30. Tiempo de Hidratación Optimizando Doctrine $conn = Doctrine_Manager::connection(); $data = $conn->execute("select * from countries")->fetchAll();
  • 31. Tiempo de Hidratación Optimizando Doctrine Para que quiero el ORM? $conn= Doctrine_Manager::connection(); Para manejarlasconexiones!
  • 33. Tiempo de Hidratación Optimizando Doctrine Ejemplo!
  • 34. Tiempo de Hidratación Optimizando Doctrine UserTable::getInstance() ->createQuery() ->select ("id, name, surname, age") ->where("is_deleted = ?", false) ->andWhere("is_closed = ? ", false) ->andWhere(”age > ? ", 50 ) ->execute( array(), Doctrine_Core::HYDRATE_ARRAY); UserTable::getInstance() ->createQuery() ->select ("id, name, surname, age") ->where("is_deleted = ?", false) ->andWhere("is_closed = ? ", false) ->andWhere(”age > ? ", 50 ) ->execute( ); Estrategia
  • 35. Tiempo de Hidratación Optimizando Doctrine Compatibilidad entre estrategias en la vista <td> <?phpecho$user->get("name") ?></td> <td> <?phpecho$user->name ?></td> <?php$user= $user->getRawValue() ?> <td> <?phpecho$user["name"] ?></td>
  • 36. T. Conversión de Consulta Optimizando Doctrine $q = Doctrine::getTable("Country")->createQuery(); $q->getSqlQuery(). 0.006 seg Gallery1..n GalleryImagesn..1 Image $q= Doctrine::getTable("Gallery")->createQuery("g")->leftJoin("g.images"); $q->getSqlQuery(); 0.1 seg
  • 37. Conteo de Registros Optimizando Doctrine $clist = Doctrine::getTable("Country”) ->findAll()->count(); ->createQuery()->count(); ->createQuery()->select("count(id)")->execute( array (), Doctrine::HYDRATE_NONE ); $conn->execute("select count(id) as count from countries")->fetchAll(); 0.2 seg 0.0056 seg 0.01 seg 0.00087 seg
  • 39. Select, Joins e Indices Optimizando Doctrine $articles = Doctrine::getTable("Article")->createQuery("a")->leftJoin("a.pages p") ->limit(100)->execute(); ->limit(1000)->execute(); ->limit(100)->execute( array(), Doctrine::HYDRATE_ARRAY ); ->limit(1000)->execute( array(), Doctrine::HYDRATE_ARRAY ); 2.93 seg 30.80 seg 0.20 seg 1.37 seg
  • 40. Select, Joins e Indices Optimizando Doctrine SELECT c.id, c.name , c.resume, c.disclaimer, c.product , c.description, br />UNIX_TIMESTAMP(c.valid_start_at) as valid_start, UNIX_TIMESTAMP(c.valid_end_at) as valid_end, UNIX_TIMESTAMP(c.promotion_start_at) as promotion_start, UNIX_TIMESTAMP(c.promotion_end_at) as promotion_end, UNIX_TIMESTAMP(c.publish_at) as publish, br />c.tracking_click, c.tracking_save_count, c.visibility_status_id, c.print_coupon, c.mobile_coupon, c.online_coupon, c.company_id, cp.comercial_name as company_name, c.redemption_price as redemption_price, br />CONCAT_WS(',', GROUP_CONCAT(DISTINCT ca.attributes_id SEPARATOR ",") ) as attributes, br />CONCAT_WS(',', GROUP_CONCAT(DISTINCT ca.root_id SEPARATOR ",") ) as roots, br />CONCAT_WS(',', GROUP_CONCAT(DISTINCT ca.level SEPARATOR ",") ) as levels, br />CONCAT_WS(',', GROUP_CONCAT(DISTINCT cs.store_id SEPARATOR ",") ) as stores, br />CONCAT_WS(',', GROUP_CONCAT(DISTINCT uc.user_id SEPARATOR ",") ) as users, br />CONCAT_WS(',', GROUP_CONCAT(DISTINCT cs.state_id SEPARATOR ","), IF(online_coupon = 1, 0, null) ) as states, CONCAT_WS(',', IF( print_coupon = 1, 1,null), IF( mobile_coupon = 1, 2,null), IF( online_coupon = 1, 3,null) ) as types, br />CONCAT_WS(',', GROUP_CONCAT(DISTINCT cs.postal_code SEPARATOR ",") ) as postal_codes_ids, br />CONCAT_WS(' ', GROUP_CONCAT(DISTINCT cs.city_name SEPARATOR " ") ) as cities, br />CONCAT_WS(' ', GROUP_CONCAT(DISTINCT s.road_name SEPARATOR " ") ) as roads, br />CONCAT_WS(' ', GROUP_CONCAT(DISTINCT s.comercial_name SEPARATOR " ") ) as names, br />CONCAT_WS(' ', GROUP_CONCAT(DISTINCT s.postal_code SEPARATOR " ") ) as postal_codes, br />CONCAT_WS(' ', GROUP_CONCAT(DISTINCT sa.name SEPARATOR " ") ) as state_names br />FROM ( ( ( (coupons c LEFT JOIN coupon_attributes ca ON c.id = ca.coupons_id ) LEFT JOIN coupon_stores cs ON c.id = cs.coupon_id) LEFT JOIN sf_guard_user_coupons uc ON c.id = uc.coupon_id ) LEFT JOIN stores s ON cs.store_id = s.id ) LEFT JOIN states sa ON cs.state_id = sa.id LEFT JOIN companies cp ON cp.id=c.company_id br />WHERE ( c.administrative_status_id = 1 AND c.publish_at < NOW() AND DATE(c.valid_end_at) + INTERVAL 1439 HOUR_MINUTE > NOW() ) br />GROUP BY c.id
  • 41. Select, Joins e Indices Optimizando Doctrine ✔
  • 42.
  • 45. Inclusión de Partials Optimizando Vistas
  • 46. Listados y consultasanidadas Optimizando Vistas <?phpforeach($results as $plan): ?> <li> <?php echo $plan->get(“title”) ?> (<?php echo $plan->countAssistants()?> ) </li> <?phpendforeach; ?> Consultasanidadas
  • 47. La Cache Guardemos en Cache parasalvaralgunos (muchos) milisegundos
  • 50. Cómofuncionan La Cache la cache de de vistas factories.yml view_cache_manager: class: sfViewCacheManager param: cache_key_use_vary_headers: true cache_key_use_host_name: true view_cache: class: sfFileCache param: automatic_cleaning_factor: 0 cache_dir: %SF_TEMPLATE_CACHE_DIR% lifetime: 86400 prefix: %SF_APP_DIR%/template
  • 51. Cómofuncionan La Cache la cache de de Doctrine $manager->setAttribute(Doctrine_Core::ATTR_QUERY_CACHE, $cacheDriver); $conn->setAttribute(Doctrine_Core::ATTR_QUERY_CACHE, $cacheDriver); $q = Doctrine_Query::create() ->useQueryCache(new Doctrine_Cache_Apc()); $manager->setAttribute(Doctrine_Core::ATTR_RESULT_CACHE, $cacheDriver); $conn->setAttribute(Doctrine_Core::ATTR_RESULT_CACHE, $cacheDriver); $manager->setAttribute(Doctrine_Core::ATTR_RESULT_CACHE_LIFESPAN, 3600); ->useResultCache(true);
  • 52. Cómomodificarla La Cache la cache de de vistas
  • 53. Cómomodificarla La Cache la cache de de vistas class sfViewCacheManager public function setPageCache($uri) public function getPageCache($uri)
  • 54. Cómomodificarla La Cache la cache de de vistas class xyzCache extendssfCache abstract public function get ($key, $default = null); abstract public function has ($key); abstract public function set ($key, $data, $lifetime = null); abstract public function remove ($key); abstract public function removePattern($pattern); abstract public function clean ($mode = self::ALL);
  • 58. Quepodemoshacer? OptimizandoSymfony Desabilitar TODO lo que no se USE Helpers Logs Routing Cache Plugins que no usen100%
  • 60. Front Controller OptimizandoSymfony require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php'); $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false); sfContext::createInstance($configuration)->dispatch();
  • 61. Front Controller OptimizandoSymfony require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php'); $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'dev', true); $manager = new sfDatabaseManager($configuration); $data = Doctrine::getTable(“Article”)->createQuery()->etc(); $view = CMSProcess::ProcessData( $data ); echo $view;
  • 63. Preguntas Ahora si las hacen Uds!
  • 64. Miviejo amigo josetonyp@latizana.com @josetonyp aotamao@latizana.com

Editor's Notes

  1. ----- Meeting Notes (02/07/11 00:31) -----COmo se que es un poco aburrido hablar de Sy1 pues les presento a Aotamao
  2. ----- Meeting Notes (02/07/11 00:21) -----Porque trabajamos con estoConocimiento comun de los problemas y posibles soluciones sobre el FWQuiero que sea una session corta
  3. Quiero saber queconocimientos hay sobresymofny 1.xCuantassaben de 1.x Cuantas personas No SabeSy 1.xQuien no sabe nada de Symofny 1.x?Entoncesqueaprenda S2 sin problemas.Cuantos con Doctrine 1.2?Cuantoshantenidoproblemasparalanzar la web porque les vamuy lento?
  4. ----- Meeting Notes (02/07/11 00:31) -----mejorar el uso de los recursos durante el proceso de la web
  5. ----- Meeting Notes (02/07/11 00:34) -----1)2) Rasum Lerdorf3) Creo yo, no se
  6. ----- Meeting Notes (02/07/11 00:34) -----conferencia la hago por mi experiencia preview
  7. ----- Meeting Notes (02/07/11 00:40) ----- vamos a ver a que nos enfrentamos
  8. ----- Meeting Notes (02/07/11 00:40) -----Nos enfrentamos a mejorar estas cosas, son inaceptables sin cache
  9. ----- Meeting Notes (02/07/11 01:03) -----Que buscamos en la DBPara que vamos a la DBUtilizamos doctrine para describir esas busquedas con su DQL, mala idea
  10. PHP Data ObjectsThe PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP.PDO provides a data-access abstraction layer, which means that, regardless of which database you&apos;re using, you use the same functions to issue queries and fetch data.ABSTRACTION !!!
  11. Quedarse con esto en la mente, se puederecupearalasconeccionque no es mas queuna extension de PDO y usarseparallegar a la DB
  12. Cuidado con los JoinsEstas queries esmejorcachearlassi no se van a podermejorar
  13. Quien no sabe nada de Symofny 1.x?Entoncesqueaprenda S2 sin problemas.Cuantostienesquevolver el lunes a trabajar con sy 1.x?Cuantos con Doctrine 1.2?Cuantoshantenidoproblemasparalanzar la web porque les vamuy lento?
  14. Cuestion de reducir los includes y revisarlasconsultasanidadas: Dondeaquipresento 2 ejemplos----- Meeting Notes (02/07/11 01:26) -----No PartialNo Lo Otro
  15. Partial reconstruye el objetoPHPView Con nuevasvariablesPor favor no lo diganporahi
  16. Añadir el join con la tablaEvenAssistantsPonerlímtes a la queryCrear Index para MySQLSeleccionar solo los camposnecesariosContar en otra query y usaruna variable nueva
  17. La cache vino a salvarnos la vida, sin ellamuchas app no salen a producción, vamos a verquepodemoshacer con ella
  18. Empecemosdesde el principio
  19. Esmuchainformacion, solo saber que se puededefinir a nivelconexion y a nivel manager.
  20. Quien no sabe nada de Symofny 1.x?Entoncesqueaprenda S2 sin problemas.Cuantostienesquevolver el lunes a trabajar con sy 1.x?Cuantos con Doctrine 1.2?Cuantoshantenidoproblemasparalanzar la web porque les vamuy lento?