Benchmark Profile and Boost your Symfony application

86 %
14 %
Information about Benchmark Profile and Boost your Symfony application
Technology

Published on March 10, 2014

Author: liuggio

Source: slideshare.net

Description

@symfonyday portugal

RATIONALLYBOOST SYMFONY2APPLICATION 2014 VERSION

welcometothe bundle.com@liuggiowelcometothebundle.com

PERFORMANCE PROBLEM?

PERFORMANCE PROBLEM?TODAY SPEED IS A FEATURE

BUSINESSNEEDSSPEED? (speed in terms of adding a new feature, bug hunting ...)

load balancer reverse proxy CDN web server MQ DB cache session storage DB internal storage BROWSER private cache shared cache DNS ISP your company

GUESS PRIDE PREJUDICE AND GUESSING

THEENDLESSCYCLE make change benchmark profile

benchmarking ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchm the process of comparing … sterilized environment - disable profiler 1

ab $ apt-get install apache-utils $ ab -e output.csv -c 10 -t 10 http://book.local $ ab -p post.txt -T application/x-www-form-urlencoded -e output.csv -kc 10 -t 10 http://book.local ● http_load simple ● siege complete ● jmeter complex ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchm

ProfilingXHProf demo ...2 ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchm make change benchmark profile

->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchm

->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchm

->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchm

->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchm

->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchm

Make Changes ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchm 3 make change benchmark profile

404 silver bullet Not Found ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma

● Think as readonly filesystem ● Don’t let the user wait ● Caches are your friends ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma ● Try to quit from the optimization-cycle

PHPAPC ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma ● apc.stat=0 (need maintenance) ● fragmentation (symfony is not slow! opcode, php 5.4, apc)

● Zend Opcode ● ACPu (emulate all the apc_* calls) ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma PHP5.5

HHVM ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma (hhvm - HPHPc - Performance on real application)

HHVM = PHP++ ? ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma (HHVM is a great opportunity for Symfony and for object oriented lovers)

symfonyecosystem ● $ composer dump-autoload --optimize ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma ● twig extension http://twig.sensiolabs.org/doc/installation.html

symfonyecosystem ● [ASSETIC] use assetic and CDN, compress and minify files ● [SWIFT MAILER] email in the spool like Redis/Gearman or MQ (remember to flush) ● [PROXY] no logic in the constructor! <service id="foo" class="AcmeFoo" lazy="true" /> ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma

[MONOLOG] don’t log to file in production debugging: Sentry or Graylog ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma

yourcachewarmup ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma

liip/LiipDoctrineCacheBundle Doctrine/Common/Cache Without bundle services.yml in your application Use a bundle ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma

doctrineORM ● Database Abstraction Layer (DBAL) ● Object Relational Mapper (ORM) ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma

ORMcaches metadata, query, result ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change

understandUOW Unit Of Work ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma

UOWeffect TLDR; keeps track changes of objects and coordinates the writing ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma Maintains a list of objects affected by a business transaction and coordinates the writing out of changes and the resolution of concurrency problems

UnitofWork Managed ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma

UnitofWork Managed ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma

UOWeffect flush is expensive* while { …. $this->em->persist($v); $this->em->flush() } ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma * profile your domain first.

Reducing the flush cost* — Number of managed Entities — Type of entities (Read-Only) $em->flush($entity); /** * @Entity * @READONLY*/ Class Status { $em->getUnitOfWork() ->markReadOnly($entity); ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma * if you really need

Reducing the flush cost* /** @Entity * @ChangeTrackingPolicy("DEFERRED_EXPLICIT”) tracking policy implicit DB === UOW explicit DB != OUW ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma * if you really need

doctrineORM ● Reference ● Partial object* ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma $q = $em->createQuery("select partial u.{id,name} from DomainUser u"); $comment->setPost($em->getReference(‘AcmeBundleEntityPost’, $postId)); * smelling tip, inconsistent objects

doctrineORM ● Change Hydration * HYDRATE_OBJECT $query->setHydrationMode(DoctrineORMQuery::HYDRATE_ARRAY); HYDRATE_SCALAR HYDRATE_SINGLE_SCALAR HYDRATE_SIMPLEOBJECT ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma * Object Oriented will cry.

theHidden Hydrationcache * ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma * Be careful, only for Read operations

->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma theHydrationcache * With ResultCache With HydrationCache * profile data from my domain not yours.

cacheproblem ● invalidation ● cache miss storm morelesscache ● pre-caching cache-back ● microcaching ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma

doctrineORMassociation ● Fetching is LAZY by default ● Changing for some queries ● Fetching EXTRA LAZY $query = … $query->setFetchMode(“Order”, “Cart”, “LAZY”); ->contains($entity); ->count(); ->slice($offset, $length); /*** @ManyToOne(targetEntity=”Cart”, cascade={“all”}, fetch=”EAGER”) ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma

->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma HTTPCache ● http specification ● validation / expiration ● safe methods ● Edge Side Included http://symfony.com/doc/current/book/http_cache.html

measure … and Metrics? ● Behaviour ● Measure applications data ● Don’t use for benchmarking Visual tool to better understand the reality ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma

benchmark->profile->make change metrics produces graphs decisions composer install liuggio/statsd-client-bundle ~1

Optimizing dev tool ->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchmark->profile->make change->benchma https://www.flickr.com/photos/itomcash/12953162645/sizes/l/ (multiple xdebug configs, db on ram, tricks, shared and private fixtures)

OOD, SOA, DDD, 12factors Architecture

BALANCED OPTIMIZATION vs MAINTAINABILITY BE

References 1. http://labs.qandidate.com/blog/2013/10/21/running-symfony-standard-on-hhvm/ 2. http://www.appdynamics.com/blog/php/php-performance-crash-course-part-1-the-basics/ 3. https://support.cloud.engineyard.com/entries/26902267-PHP-Performance-I-Everything-You-Need- to-Know-About-OpCode-Caches 4. https://speakerdeck.com/dshafik/lonestar-php-fast-not-furious-how-to-identify-and-fix-slow-code 5. http://share.ez.no/learn/ez-publish/ez-publish-performance-optimization-part-1-of-3-introduction- and-benchmarking/%28page%29/5 6. http://www.linuxhelp.in/2012/11/benchmarking-with-http-load.html 7. https://speakerdeck.com/bastianhofmann/profiling-php-applications 8. http://www.symfony.com 9. http://blog.ircmaxell.com/2013/09/rambling-on-internals.html 10. .P of EAA page 184 Patterns of Enterprise Application Architecture by Martin Fowler 11. https://doctrine-orm.readthedocs.org/en/latest/reference/unitofwork.html 12. http://docs.doctrine-project.org/en/latest/reference/change-tracking-policies.htmlFlush optimization 13. http://slides.seld.be/?file=2011-10-20+High+Performance+Websites+with+Symfony2.html#1 Credits: https://www.flickr.com/photos/kelehen/8962203423 https://www.flickr.com/photos/itomcash/12953162645

QUESTIONSARE ALWAYSBETTER THANANSWERS @liuggio https://joind.in/10783

Add a comment

Related presentations

Presentación que realice en el Evento Nacional de Gobierno Abierto, realizado los ...

In this presentation we will describe our experience developing with a highly dyna...

Presentation to the LITA Forum 7th November 2014 Albuquerque, NM

Un recorrido por los cambios que nos generará el wearabletech en el futuro

Um paralelo entre as novidades & mercado em Wearable Computing e Tecnologias Assis...

Microsoft finally joins the smartwatch and fitness tracker game by introducing the...

Related pages

Symfony, High Performance PHP Framework for Web Development

Symfony is a set of ... The standard foundation on which the best PHP applications ... Speed up the creation and maintenance of your PHP web ...
Read more

Why should I use a framework? - Symfony, High Performance ...

... because a framework provides you with the ... the structure that a framework provides for the application ... In the case of Symfony ...
Read more

.NET profiler to improve application speed | ANTS ...

Profile and boost the performance of your ... ANTS Performance Profiler is an application profiler ... Profile database requests your application ...
Read more

Intel® Extreme Tuning Utility (Intel® XTU) Information

... we present you a fully integrated overclocking software application which allows you to ... In order to save a profile or benchmark score to ...
Read more

MongoDB with PHP and symfony - ServerGroveServerGrove

... you have to change your schema, making application upgrades one of the ... to store something in MongoDB you follow these ... MongoDB, ODM and symfony.
Read more

13 PHP Frameworks to Help Build Agile Applications - Mashable

Building software applications can be a complex, time consuming process, however utilizing a framework can help you develop projects faster (by ...
Read more

Intel® Turbo Boost Technology Improves Application ...

Intel® Turbo Boost Technology 2.0 detects when ... The browser version you are using is not ... Intel® Turbo Boost Technology Improves Application ...
Read more

Migrate to Red Hat JBoss Middleware | Red Hat

Your Red Hat account gives you access to your member profile ... Hat JBoss Middleware let you ... migrating applications to Red Hat JBoss ...
Read more