SlideShare a Scribd company logo
1 of 101
Zzz and bla^3
will move your
to the next level.
???
I have not
invented anything
please
read carefully
the references
not yet 
I’m @liuggio
(aka Giulio De Donato)
I LOVE
and its dark passenger
fabpot
_ _ _ and _ _ _
will move your
to the next level.
???
_ _ _ and _ _ _
will move your
to the next level.
Symfony2
application
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/photos/455.jpg HTTP/1.1"
200 986 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like
Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/nav/tab_left_middle.gif
HTTP/1.1" 200 1020 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13
(KHTML, like Gecko) Version/3.1 Safari/525.13" "-"
dyn-530.optus.com.au - - [22/Apr/2009:18:52:51 +1200] "GET /images/photos/5332.jpg HTTP/1.1" 200
244 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)" "-"
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>dhcp-465.telstra.com.au - - [22/Apr/2009:18:52:51
@charset "UTF-8";html,body,div,span,applet,object,iframe,h1,h2,h3,h4,+1200] "GET /gallery.php?
section=entertainment HTTP/1.0" 200 58636 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en)
AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /adclick.php?c=LME2 HTTP/1.1"
302 378 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like
Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/ad/RH4Y.jpeg HTTP/1.1"
200 1031 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like
Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/favicon.ico HTTP/1.1" 200
2824 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like
Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /adclick.php?c=GD52 HTTP/1.1"
302 379 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like
In your company
every minute
data is generated
a lot of
differenttotally
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/photos/455.jpg HTTP/1.1"
200 986 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like
Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/nav/tab_left_middle.gif
HTTP/1.1" 200 1020 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13
(KHTML, like Gecko) Version/3.1 Safari/525.13" "-"
dyn-530.optus.com.au - - [22/Apr/2009:18:52:51 +1200] "GET /images/photos/5332.jpg HTTP/1.1" 200
244 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)" "-"
dhcp-465.telstra.com.au - - [22/Apr/2009:18:52:51 +1200] "GET /gallery.php?section=entertainment
HTTP/1.0" 200 58636 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13
(KHTML, like Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /adclick.php?c=LME2 HTTP/1.1"
302 378 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like
Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/ad/RH4Y.jpeg HTTP/1.1"
200 1031 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like
Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/favicon.ico HTTP/1.1" 200
2824 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like
Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /adclick.php?c=GD52 HTTP/1.1"
302 379 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like
Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /stories.php?date=yesterday
HTTP/1.1" 200 4231 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13
(KHTML, like Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /latest.php HTTP/1.1" 200 991 "-"
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko)
Version/3.1 Safari/525.13" "-"
proxy-622.dsl.clear.net.nz - - [22/Apr/2009:18:52:51 +1200] "GET /latest-news.rss HTTP/1.0" 200 7199
data
- Difficult to read
- Difficulto to measure
- Time consuming
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/photos/455.jpg HTTP/1.1"
200 986 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like
Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/nav/tab_left_middle.gif
HTTP/1.1" 200 1020 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13
(KHTML, like Gecko) Version/3.1 Safari/525.13" "-"
dyn-530.optus.com.au - - [22/Apr/2009:18:52:51 +1200] "GET /images/photos/5332.jpg HTTP/1.1" 200
244 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)" "-"
dhcp-465.telstra.com.au - - [22/Apr/2009:18:52:51 +1200] "GET /gallery.php?section=entertainment
HTTP/1.0" 200 58636 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13
(KHTML, like Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /adclick.php?c=LME2 HTTP/1.1"
302 378 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like
Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/ad/RH4Y.jpeg HTTP/1.1"
200 1031 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like
Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/favicon.ico HTTP/1.1" 200
2824 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like
Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /adclick.php?c=GD52 HTTP/1.1"
302 379 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like
Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /stories.php?date=yesterday
HTTP/1.1" 200 4231 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13
(KHTML, like Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /latest.php HTTP/1.1" 200 991 "-"
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko)
Version/3.1 Safari/525.13" "-"
proxy-622.dsl.clear.net.nz - - [22/Apr/2009:18:52:51 +1200] "GET /latest-news.rss HTTP/1.0" 200 7199
data
Difference audences and destination
-business                                                      
-applications  
-external services
-error logs ( js error, and application error)
- . . .
sucks
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/photos/455.jpg HTTP/1.1"
200 986 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like
Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/nav/tab_left_middle.gif
HTTP/1.1" 200 1020 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13
(KHTML, like Gecko) Version/3.1 Safari/525.13" "-"
dyn-530.optus.com.au - - [22/Apr/2009:18:52:51 +1200] "GET /images/photos/5332.jpg HTTP/1.1" 200
244 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)" "-"
dhcp-465.telstra.com.au - - [22/Apr/2009:18:52:51 +1200] "GET /gallery.php?section=entertainment
HTTP/1.0" 200 58636 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13
(KHTML, like Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /adclick.php?c=LME2 HTTP/1.1"
302 378 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like
Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/ad/RH4Y.jpeg HTTP/1.1"
200 1031 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like
Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/favicon.ico HTTP/1.1" 200
2824 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like
Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /adclick.php?c=GD52 HTTP/1.1"
302 379 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like
Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /stories.php?date=yesterday
HTTP/1.1" 200 4231 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13
(KHTML, like Gecko) Version/3.1 Safari/525.13" "-"
proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /latest.php HTTP/1.1" 200 991 "-"
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko)
Version/3.1 Safari/525.13" "-"
proxy-622.dsl.clear.net.nz - - [22/Apr/2009:18:52:51 +1200] "GET /latest-news.rss HTTP/1.0" 200 7199
rocks
data
Difference audences and destination
-business                                                      
-applications  
-external services
-error logs ( js error, and application error)
- . . .
What we do
with data?
_ _ _ _ _ !ignore
track
We track data
_ _ _ _ _ !ignore
then
data
BUSINESS
VALUE
then
… still 42.
and
bussiness
value?
and
bussiness
value?
4242
hitchhiker's guide to the galaxy
Our code generates business value when it runs,
not when we write code.
@coda
Store log and error data
Query on past events
Locate the bug
Know Servers/application
status: healthy/resources/
Responding as it should?
Face the reality of my
ecosystem
Understand why and
where the app. is slow
Analyze the behaviour
when it ‘s running
watch data
be alerted
fast website
Needs
data
…
BUSINESS
VALUE
Needs
BUSINESS
VALUE
logging
debugging
monitoring
profiling
metricking
optimizing
Actions
Store log and error data
Query on past events
Locate the bug
Know Servers/application
status: healthy/resources/
Responding as it should?
Face the reality of my
ecosystem
Understand why and
where the app. is slow
Analyze the behaviour
when it ‘s running
watch data
be alerted
fast website
…
BUSINESS
VALUE
logging
debugging
monitoring
profiling
metricking
optimizing
Actions
monolog, Logstash,
Graylog
Sentry / Graylog
Nagios, Cacti …
external service
XhProf
statsd-php-client,
StatsD, Graphite
It's not about the accuracy of estimating it's
about facing the reality of uncertainty.
@jimhighsmith
metrics
http://samate.nist.gov/index.php/Metrics_and_Measures.html
http://nvlpubs.nist.gov/nistpubs/jres/104/6/j46gra.pdf
The IEEE Standard Glossary of Software Engineering Terminology
also defines quality metric as :
(1) A quantitative measure of the degree to which
an item possesses a given quality attribute.
(2) A function whose inputs are software data and whose output is a
single numerical value that can be interpreted as the degree to which
the software possesses a given quality attribute.
* @param array $data
* @return float
function calculateUglyness(array $data);Ninja territory
measuring
http://samate.nist.gov/index.php/Metrics_and_Measures.html
HOW TO MEASURE ANYTHING - FINDING THE VALUE OF “INTANGIBLES” IN BUSINESS
second edition Hubbard
experimentally obtaining
one or more quantity values
that can reasonably be
attributed to a quantity.
reasonably => uncertainty reductionNinja territory
What metrics
means?
DUNNO
Merlin knows Yes Matrix I
saw the film
metrics
Visual tool to
better understand
reality
metrics
align technical and
business vision of
IT.
produces
graphs
DECISIONS
metrics
StatsD simple
— Node.JS daemon. Listens for message over UDP
simple daemon for easy stats aggregation.
Graphite rude <key> <numeric value> <timestamp>
Graphite stores numeric time-series data.
— Real-time graphing system
— Components:
— Carbon stores the data in Graphite’s specialized database.
— The data can then be visualized through graphite
web interface developed with django.
— Whisper allows carbon to write multiple data points.
metrics
Symfony2 integration:
there’s a bundle for it ‘liuggio/StatsDClientBundle’
— Amount of visitor
— Logged vs Anonymous user
— Doctrine collector
— Amount of PHP peak
— Execution Time
— Monolog
— Easily add a new metric:
$this->get(‘stats_d_client.factory')->increment(’upload.file');
metrics
Symfony2 integration PHP Peak
metrics
this is a
‘Timer’
Concepts
— Bucket
— Values
— Flush Interval
metrics
metrics
— Counter
— Gauge
— Timer
— Set
— Sample
Understand StatsD
GAUGES are arbitrary values, which can be recorded.
metrics
$factory = $this->get('stats_d_client.factory');
$data[] = $factory->gauge('cart.item.number', 30);
$data[] = $factory->gauge('cart.item.number', 34);
$data[] = $factory->gauge('cart.item.number', 38);
$this->get('stats_d_client.service’)->send($data);
cart.item.number|38
Result is the last one (per flush time)
COUNTS increment and decrement a value.
metrics
$factory = $this->get('stats_d_client.factory');
$data[] = $factory->increment('user.visitor');
$this->get('stats_d_client.service’)->send($data);
The value stay in memory until the flush interval.
TIMERS collects numbers.
metrics
$factory = $this->get('stats_d_client.factory');
$data[] = $factory->timing(’php-peak', 500);
$this->get('stats_d_client.service’)->send($data);
Operations [mean, upper, sum, lower, count, ...]
are already calculated 
Collect from different sources
# echo "deploy.web:1|c" | nc -w 1 -u graphite.com 8125
track
everythings that
moves
can
metrics
you have more
data than you think
and you need less
data than you think
MORELESS
new metrics
— Why do you want to know?
— How much do you know now?
— What is the value to additional
information
The time you spend for metrics has a cost,
and usually is more economical
than many managers assume.
maybe because
they didn’t
measure.
bazinga
metrics
produces
DECISIONS
fast
metricsgood
good and fast
DECISIONS
BUSINESS
help the
and _ _ _
will move your
to the next level.
metrics
???
Optimizing
Performance problems?
Enlarge
your
profiler
Great caching is like great sex.
It hides all the real problems
@vivekhaldar
Wikipedia: “a Cache ( /’kæ∫/ KASH[1]) is a
component that transparently stores data
so that future requests for that data can be
served faster.”
the cache miss
happens once for the
same response.
given the same request the Cache miss happens once.
given the same request the response is not ‘processed’ twice.
A Cache Hit happens if the Cache
contains the answer.
A Cache Miss happens if the Cache
doesn’t contain the answer.
The perfect cache when
CACHE
IS A RESPONSE
MATTER
— Application caching: app/cache with opcode
— Response caching and HTTP-CACHE
— Doctrine2 Query and Result Caching
— CDN and static files
— Other
CACHE + SF2
Terravison vendor folder is about 340 MB
The app/cache/prod folder is about 3000 files
1. Annotation (Entity/Controller/...)
2. Template
a. name => file
b. twig in php
3. Assetic (definition)
4. Url matcher, Url creator
5. Translations array key=>value
6. Doctrine Entity Proxy
./app/cache
Add your class to the services with the tag kernel.cache_warmer
Note: the CacheWarmerInterface is not properly the same as the snippet.
cache warmer
namespace SymfonyComponentHttpKernelCacheWarmer;
interface CacheWarmerInterface
/**
* Warms up the cache.
* @param string $cacheDir The cache directory
*/
public function warmUp($cacheDir);
public function isOptional()
Symfony2 is a web framework built from scratch around
the http specification
— a resource could be Fresh || Stale
— http-caching only on safe method
— validation || expiration
HTTP
HTTP cache
HTTP headers
$response->setPublic() //default is private
$response->setMaxAge(600);
// Same as above but only for shared caches
$response->setSharedMaxAge(600);
$response->setETag(md5($response->getContent()));
$response->setLastModified($datetime);
if ($response->isNotModified($this->getRequest()))
...
$response->setVary(‘Accept-Encoding’);
symfony.com/doc/master/book/http_cache.html
The least
expensive
query is the
query you
never run.
DoctrineCommonCacheCache
(There’s not tagging)
doctrine cache
// Fetches an entry from the cache.
string function fetch($id);
// Tests if an entry exists in the cache.
bool function contains($id);
// Put data into the cache.
bool function save($id, $data, $lifeTime);
// Deletes a cache entry.
bool function delete($id);
MetaData Cache Annotation (OPCODE)
Query Cache DQL parsed into SQL
(OPCODE/REDIS/MEMCACHED)
Result Cache The query result
(REDIS/MEMCACHED/OPCODE)
doctrine caches
doctrine cache
Class ProductRepository
...
$query = $this->createQueryBuilder(‘p’)
->where(‘p.price > :price’)
->setParameter(‘price’, ‘19.99’)
->getQuery();
$products = $query->getResult();
$query->useResultCache(
true,
$lifetime,
__METHOD__ . serialize($query->getParameters())
);
$query->useQueryCache();
There are only two hard things in Computer Science
cache invalidation and naming things
Phil Karlton
There are only two hard things in Computer Science
cache invalidation, naming things and off-by-1
errors.
anonymous
Invalidation
Especially for http, but in general, you should not waste time to
invalidate a value, but you should invest resources to find the right
time of validity.
Cache miss storm
When a resource is no longer available (cache miss), and is required
by many clients simultaneously (storm), a congestion happens.
cache miss storm, cache stampede,
dog-piling, APC Cache slam
cache
Pre-Caching/Cacheback
Sometimes you need to have some data already available and you
don’t want that the first request wait.
Uniqueness of the cache key
Attention to the conflicts in the key definition, always put a prefix or
namespace such as language or role.
Http-Microcaching:
Save all the responses for 1||2 seconds
lot of examples on internet for Nginx
cache
and _ _ _
will move your
to the next level.
???
Performance
tips - rule #1
Mantainibility
win over
Performance
— The user should never wait
    slow operation data in a queue (Redis/*MQ)
    processed by a consumer (cli + supersivord):
— Image Manipulation
— File Creation (pdf)
— Sending email as spool
— I/O operation
— Use Session with Redis/Memcache
— Caution on what do you do in the loop && nested loop
easy …
… tips
— Must! OPCODE: APC using the apc.stat = 0
— $php composer.phar dump-autoload –optimize
— Twig.c php extension
— Assets
— Minify and combine all of your CSS and JS files
— Run all (or just some) of your CSS or JS files
through some sort of compiler,
such as LESS, SASS or CoffeeScript
— Run image optimizations on your images
http://symfony.com/doc/current/book/performance.html
https://speakerdeck.com/alexandresalome/symfony2-and-performances
the DIC of sf2.3 is lazy
A lazy loading value holder proxy is a virtual proxy that wraps and
lazily initializes a "real" instance of the proxied class.
<service id="foo" class="AcmeFoo" lazy="true" />
When do I use a lazy value holder?
-Your object takes a lot of time and memory to be initialized (with all
dependencies)
-Your object is not always used, and the instantiation overhead can be
avoided
github.com/Ocramius/ProxyManager/blob/master/docs/lazy-loading-value-holder.md
github.com/Ocramius/symfony-docs/blob/master/components/dependency_injection/lazy_services.rst
Cache Driver
# config_prod.yml
services:
cache:
class: DoctrineCommonCacheApcCache #
MemcacheCache
# config_dev.yml
services:
cache:
class: DoctrineCommonCacheArrayCache
if ($fooString = $this->get(‘cache’)->fetch(‘foo’)) {
$foo = unserialize($fooString);
} else {
// do something with $foo
$this->get(‘cache’)->save(‘foo’, serialize($foo),
$lifetime);
}
http://docs.doctrine-project.org/en/latest/reference/caching.html
DOCTRINE
Object relational mapper
(ORM) for PHP that sits on
top of a powerful database
abstraction layer (DBAL)
doctrine >=
2.4
New features:
https://speakerdeck.com/asm89/what-is-new-in-doctrine
it ill be faster ?
NO
doctrine >= 2.3
—2.4 flush multiples entities
$em->flush(array($entityA, $entityB);
—2.4 paginator
—2.4 master slave
—2.4 join to the interface
—2.3 You can override metadata
—2.3 Event listener in a separated class
/**
* @ORMManyToOne(targetEntity="Tvision...EntityStatusInterface")
**/
https://speakerdeck.com/asm89/what-is-new-in-doctrine
Optimize Doctrine
http://xkcd.com/1195/
Optimize Doctrine
https://doctrine-orm.readthedocs.org/en/latest/reference/unitofwork.html
step1:
deeply understand UOW
step2:
goto step1
$article = new Article();
$article->setHeadline('I love PHPday');
$em->persist($article); // the entity is managed
$em->flush(); // the entity is persisted
...
$article->setHeadline('I love JSday and PHPday');
$em->flush(); // the Headline is updated
on the persistence layer
$em->persist($article);
$article = $em->find('Article', 1234);
$article->setHeadline(’I love GRUSP');
$article2 = $em->find('Article', 1234);
echo $article2->getHeadline(); // I love GRUSP
if ($article === $article2) ---> true!!
Unit of work
https://doctrine-orm.readthedocs.org/en/latest/reference/unitofwork.html
Maintains a list of objects affected by a business transaction and
coordinates the writing out of changes and the resolution of concurrency
problems.
P of EAA page 184 Patterns of Enterprise Application Architecture
by Martin Fowler
UOW = keeps track
changes of Objects
TL;DR
Identity Map
The flush has a cost
— Number of managed Entities
— Tracking policy
— Type of entities
https://doctrine-orm.readthedocs.org/en/latest/reference/unitofwork.html
contains all the managed entities
On flush makes a property by property comparison for all the
entities managed.
tracking policy
Doctrine definition:
“is the process of determining what has changed in managed entities
since the last time they were synchronized with the database.”
— implicit tracking (default and simple)
— explicit tracking (suggested for lot of entities managed)
— notify tracking
/**
* @Entity
* @ChangeTrackingPolicy("DEFERRED_EXPLICIT”)
http://docs.doctrine-project.org/en/latest/reference/change-tracking-policies.html
Flush optimization #1
tracking policy
Deferred Implicit
UOW = DB
http://docs.doctrine-project.org/en/latest/reference/change-tracking-policies.html
Deferred Explicit
UOW != DB
— UOW = ’I love PUG Roma’
— DB is not updated.
Need the persist!
Flush optimization #1
// $article is already managed or loaded
// we are changing the Headline
$article->setHeadline('I love PUG Roma');
$em->flush();
echo $article->getHeadline();// is ‘I love PUG Roma’
Read only entity
/**
* @Entity
* @READONLY
*/
Class Status {
$em->getUnitOfWork->markReadOnly($entity);
Temporarily mark entities as read only
Flush optimization #2
Flush only on few
entities
$em->flush($entity)
Flush optimization #3
Reducing the
flush cost
The flush has a cost
— Number of managed Entities (flushing only some)
— Tracking policy (explicit || implicit)
— Type of entities (read-only || temp. read-only)
Recap.
reference
$post = $postRepository->find($postId);
$comment->setPost($post);
...
// $postId comes from somewhere
$comment->setPost(
$em->getReference(‘AcmeBundleEntityPost’, $postId)
);
.
lazy associations
Association are LAZY by default
// Order
/**
* @ManyToOne(targetEntity=”Cart”, cascade={“all”},
fetch=”EAGER”)
*/
private $cart
<?php
$query = $em->createQuery(“SELECT o FROM Order o”);
$query->setFetchMode(“Order”, “Cart”, “LAZY”);
$query->execute();
Change the fetch mode
associations
What’s better than LAZY ?
/*
* @ORMManyToMany(targetEntity=”Trips”,
mappedBy=”rides”,fetch=”EXTRA_LAZY”)
*/
private $trips;
$turin->getTrips()->contains($turinCaselle);
$turin->getTrips()->count();
$turin->getTrips()->slice($offset, $length);
and _ _ _
will move your
to the next level.
Symfony2
application
Optimization
Done everything?
Did you really
need it?
Rationality
Knowing when optimization is premature
defines the differences the master engineer
and the apprentice
Theo Schlossnagle
Optimization
We’ve heard
this a million
times
When you discover the real problem, you done the half.
Problem are not all equals, and most are illusions.
Pieter Hintjens
Optimization
you are doing it wrong:
— Cache everything
— Guessing / action without measurement
and _ _ _
will move your
to the next level.
Symfony2
application
Optimization
and
will move your
to the next level.
Symfony2
application
Optimization
and
will move your
to the next level.
BUSINESS
and
will move your
to the next level.
metrics
and
will move your
to the next level.
BUSINESS
and
will move your
to the next level.
BUSINESS
and
will move your
to the next level.
metrics
and
will move your
to the next level.
metricsOptimization
and
will move your
to the next level.
metrics
Symfony2
application
data
then
BUSINESS VALUE
Performance optimization could
Metrics should
Rationality must
@liuggio
please read the references
https://speakerdeck.com/asm89/what-is-new-in-doctrine
http://docs.doctrine-project.org/
http://nvlpubs.nist.gov/nistpubs/jres/104/6/j46gra.pdf
http://ilia.ws/files/phpuk_bottlenecks.pdf
http://www.slideshare.net/anton_chuvakin/log-mining-beyond-log-analysis
http://pivotallabs.com/139-metrics-metrics-everywhere/
http://www.hubbardresearch.com (HOW TO MEASURE ANYTHING - FINDING THE VALUE OF “INTANGIBLES” )
https://people.mozilla.com/~rmiller/heka-intro-2013-03/#/2
http://tools.ietf.org/html/draft-ietf-httpbis-p6-cache-18
https://developers.google.com/speed/docs/best-practices/caching
http://notmysock.org/blog/php/user-cache-timebomb.html
http://sonata-project.org/blog/2012/5/15/assetic-package-configuration
http://www.slideshare.net/jonkruger/advanced-objectorientedsolid-principles
http://slides.seld.be/?file=2011-10-20+High+Performance+Websites+with+Symfony2.html
http://stackoverflow.com/questions/8893081/how-to-cache-in-symfony-2
http://www.slideshare.net/postwait/scalable-internet-architecture
http://techportal.inviqa.com/2009/12/01/profiling-with-xhprof/
http://www.mysqlperformanceblog.com/2010/09/10/cache-miss-storm
http://www.slideshare.net/iamcal/scalable-web-architectures-common-patterns-ap...
http://blog.servergrove.com/2012/04/18/how-to-create-a-cache-warmer-in-symfony2/
http://www.slideshare.net/jwage/doctrine-intherealworldsf-live2011sanfran
http://www.slideshare.net/quipo/scalable-architectures-taming-the-twitter-firehose
https://github.com/liuggio/StatsDClientBundle
http://www.slideshare.net/quipo/monitoring-at-scale-intuitive-dashboard-design
http://www.slideshare.net/ihower/rails-performance
http://www.infoq.com/presentations/Architecture-Scale-ZeroMQ
https://speakerdeck.com/keithpitt/keith-and-marios-guide-to-fast-websites
http://www.slideshare.net/anton_chuvakin/log-mining-beyond-log-analysis
http://marco-pivetta.com/proxy-pattern-in-php/#/9
http://www.slideshare.net/guilhermeblanco/object-calisthenics-applied-to-php
http://talks.php.net/show/dojo/
https://github.com/symfony/symfony/pull/7818
https://speakerdeck.com/roidrage/metrics-monitoring-logging
http://codahale.com/codeconf-2011-04-09-metrics-metrics-everywhere.pdf
http://pivotallabs.com/139-metrics-metrics-everywhere/
http://blog.pkhamre.com/2012/07/24/understanding-statsd-and-graphite/
References

More Related Content

Similar to Caching and data analysis will move your Symfony2 application to the next level

Access Patterns for Robots and Humans in Web Archives
Access Patterns for Robots and Humans in Web ArchivesAccess Patterns for Robots and Humans in Web Archives
Access Patterns for Robots and Humans in Web ArchivesYasmin AlNoamany, PhD
 
Puppet Camp Berlin 2014 Closing Keynote: Next steps for doing more awesome th...
Puppet Camp Berlin 2014 Closing Keynote: Next steps for doing more awesome th...Puppet Camp Berlin 2014 Closing Keynote: Next steps for doing more awesome th...
Puppet Camp Berlin 2014 Closing Keynote: Next steps for doing more awesome th...Puppet
 
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014Puppet
 
LogStash - Yes, logging can be awesome
LogStash - Yes, logging can be awesomeLogStash - Yes, logging can be awesome
LogStash - Yes, logging can be awesomeJames Turnbull
 
Developers’ mDay 2019. - Nikola Krgović, Twin Star Systems – Big Data for Dev...
Developers’ mDay 2019. - Nikola Krgović, Twin Star Systems – Big Data for Dev...Developers’ mDay 2019. - Nikola Krgović, Twin Star Systems – Big Data for Dev...
Developers’ mDay 2019. - Nikola Krgović, Twin Star Systems – Big Data for Dev...mCloud
 
Real-time data analysis using ELK
Real-time data analysis using ELKReal-time data analysis using ELK
Real-time data analysis using ELKJettro Coenradie
 
The Web Becomes Graceful
The Web Becomes GracefulThe Web Becomes Graceful
The Web Becomes Gracefulcolorhook
 
2013.10 Operating * by the Numbers
2013.10 Operating * by the Numbers2013.10 Operating * by the Numbers
2013.10 Operating * by the NumbersAllison Miller
 
Firefox.NEXT
Firefox.NEXTFirefox.NEXT
Firefox.NEXTdynamis
 
Streaming Data Analytics with Amazon Redshift and Kinesis Firehose
Streaming Data Analytics with Amazon Redshift and Kinesis FirehoseStreaming Data Analytics with Amazon Redshift and Kinesis Firehose
Streaming Data Analytics with Amazon Redshift and Kinesis FirehoseAmazon Web Services
 
Алексей Колосов - Drupal для хостинга
Алексей Колосов - Drupal для хостингаАлексей Колосов - Drupal для хостинга
Алексей Колосов - Drupal для хостингаDrupalSPB
 
EF09-Installing-Alfresco-components-1-by-1.pdf
EF09-Installing-Alfresco-components-1-by-1.pdfEF09-Installing-Alfresco-components-1-by-1.pdf
EF09-Installing-Alfresco-components-1-by-1.pdfDangGonz
 
Ksdg customize-your-firefoxos
Ksdg customize-your-firefoxosKsdg customize-your-firefoxos
Ksdg customize-your-firefoxosYuren Ju
 
夜宴39期《Seven》
夜宴39期《Seven》夜宴39期《Seven》
夜宴39期《Seven》Koubei Banquet
 
Divolte Collector - meetup presentation
Divolte Collector - meetup presentationDivolte Collector - meetup presentation
Divolte Collector - meetup presentationfvanvollenhoven
 
Ef09 installing-alfresco-components-1-by-1
Ef09 installing-alfresco-components-1-by-1Ef09 installing-alfresco-components-1-by-1
Ef09 installing-alfresco-components-1-by-1Angel Borroy López
 
WebSocket Perspectives 2015 - Clouds, Streams, Microservices and WoT
WebSocket Perspectives 2015 - Clouds, Streams, Microservices and WoTWebSocket Perspectives 2015 - Clouds, Streams, Microservices and WoT
WebSocket Perspectives 2015 - Clouds, Streams, Microservices and WoTFrank Greco
 
Yang enhance-voyager-user-innovations
Yang enhance-voyager-user-innovationsYang enhance-voyager-user-innovations
Yang enhance-voyager-user-innovationsENUG
 

Similar to Caching and data analysis will move your Symfony2 application to the next level (20)

Access Patterns for Robots and Humans in Web Archives
Access Patterns for Robots and Humans in Web ArchivesAccess Patterns for Robots and Humans in Web Archives
Access Patterns for Robots and Humans in Web Archives
 
Puppet Camp Berlin 2014 Closing Keynote: Next steps for doing more awesome th...
Puppet Camp Berlin 2014 Closing Keynote: Next steps for doing more awesome th...Puppet Camp Berlin 2014 Closing Keynote: Next steps for doing more awesome th...
Puppet Camp Berlin 2014 Closing Keynote: Next steps for doing more awesome th...
 
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014
 
LogStash - Yes, logging can be awesome
LogStash - Yes, logging can be awesomeLogStash - Yes, logging can be awesome
LogStash - Yes, logging can be awesome
 
Software Livre - Parte I
Software Livre - Parte ISoftware Livre - Parte I
Software Livre - Parte I
 
Developers’ mDay 2019. - Nikola Krgović, Twin Star Systems – Big Data for Dev...
Developers’ mDay 2019. - Nikola Krgović, Twin Star Systems – Big Data for Dev...Developers’ mDay 2019. - Nikola Krgović, Twin Star Systems – Big Data for Dev...
Developers’ mDay 2019. - Nikola Krgović, Twin Star Systems – Big Data for Dev...
 
Real-time data analysis using ELK
Real-time data analysis using ELKReal-time data analysis using ELK
Real-time data analysis using ELK
 
The Web Becomes Graceful
The Web Becomes GracefulThe Web Becomes Graceful
The Web Becomes Graceful
 
2013.10 Operating * by the Numbers
2013.10 Operating * by the Numbers2013.10 Operating * by the Numbers
2013.10 Operating * by the Numbers
 
Firefox.NEXT
Firefox.NEXTFirefox.NEXT
Firefox.NEXT
 
Streaming Data Analytics with Amazon Redshift and Kinesis Firehose
Streaming Data Analytics with Amazon Redshift and Kinesis FirehoseStreaming Data Analytics with Amazon Redshift and Kinesis Firehose
Streaming Data Analytics with Amazon Redshift and Kinesis Firehose
 
Алексей Колосов - Drupal для хостинга
Алексей Колосов - Drupal для хостингаАлексей Колосов - Drupal для хостинга
Алексей Колосов - Drupal для хостинга
 
EF09-Installing-Alfresco-components-1-by-1.pdf
EF09-Installing-Alfresco-components-1-by-1.pdfEF09-Installing-Alfresco-components-1-by-1.pdf
EF09-Installing-Alfresco-components-1-by-1.pdf
 
Ksdg customize-your-firefoxos
Ksdg customize-your-firefoxosKsdg customize-your-firefoxos
Ksdg customize-your-firefoxos
 
夜宴39期《Seven》
夜宴39期《Seven》夜宴39期《Seven》
夜宴39期《Seven》
 
Divolte Collector - meetup presentation
Divolte Collector - meetup presentationDivolte Collector - meetup presentation
Divolte Collector - meetup presentation
 
Ef09 installing-alfresco-components-1-by-1
Ef09 installing-alfresco-components-1-by-1Ef09 installing-alfresco-components-1-by-1
Ef09 installing-alfresco-components-1-by-1
 
WebSocket Perspectives 2015 - Clouds, Streams, Microservices and WoT
WebSocket Perspectives 2015 - Clouds, Streams, Microservices and WoTWebSocket Perspectives 2015 - Clouds, Streams, Microservices and WoT
WebSocket Perspectives 2015 - Clouds, Streams, Microservices and WoT
 
Yang enhance-voyager-user-innovations
Yang enhance-voyager-user-innovationsYang enhance-voyager-user-innovations
Yang enhance-voyager-user-innovations
 
Armorizing applications
Armorizing applicationsArmorizing applications
Armorizing applications
 

More from Giulio De Donato

Docker italia fatti un container tutto tuo
Docker italia fatti un container tutto tuoDocker italia fatti un container tutto tuo
Docker italia fatti un container tutto tuoGiulio De Donato
 
Lets isolate a process with no container like docker
Lets isolate a process with no container like dockerLets isolate a process with no container like docker
Lets isolate a process with no container like dockerGiulio De Donato
 
More developers on DevOps with Docker orchestration
More developers on DevOps with Docker orchestrationMore developers on DevOps with Docker orchestration
More developers on DevOps with Docker orchestrationGiulio De Donato
 
really really really awesome php application with bdd behat and iterfaces
really really really awesome php application with bdd behat and iterfacesreally really really awesome php application with bdd behat and iterfaces
really really really awesome php application with bdd behat and iterfacesGiulio De Donato
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microserviceGiulio De Donato
 
Json web token api authorization
Json web token api authorizationJson web token api authorization
Json web token api authorizationGiulio De Donato
 
Think horizontally ood, ddd and bdd
Think horizontally ood, ddd and bddThink horizontally ood, ddd and bdd
Think horizontally ood, ddd and bddGiulio De Donato
 
I came i saw i go - golang it meetup codemotion rome 2014
I came i saw i go - golang it meetup codemotion rome 2014I came i saw i go - golang it meetup codemotion rome 2014
I came i saw i go - golang it meetup codemotion rome 2014Giulio De Donato
 
It's all about behaviour, also in php - phpspec
It's all about behaviour, also in php - phpspecIt's all about behaviour, also in php - phpspec
It's all about behaviour, also in php - phpspecGiulio De Donato
 
Design pattern in Symfony2 - Nanos gigantium humeris insidentes
Design pattern in Symfony2 - Nanos gigantium humeris insidentesDesign pattern in Symfony2 - Nanos gigantium humeris insidentes
Design pattern in Symfony2 - Nanos gigantium humeris insidentesGiulio De Donato
 
Rationally boost your symfony2 application with caching tips and monitoring
Rationally boost your symfony2 application with caching tips and monitoringRationally boost your symfony2 application with caching tips and monitoring
Rationally boost your symfony2 application with caching tips and monitoringGiulio De Donato
 

More from Giulio De Donato (11)

Docker italia fatti un container tutto tuo
Docker italia fatti un container tutto tuoDocker italia fatti un container tutto tuo
Docker italia fatti un container tutto tuo
 
Lets isolate a process with no container like docker
Lets isolate a process with no container like dockerLets isolate a process with no container like docker
Lets isolate a process with no container like docker
 
More developers on DevOps with Docker orchestration
More developers on DevOps with Docker orchestrationMore developers on DevOps with Docker orchestration
More developers on DevOps with Docker orchestration
 
really really really awesome php application with bdd behat and iterfaces
really really really awesome php application with bdd behat and iterfacesreally really really awesome php application with bdd behat and iterfaces
really really really awesome php application with bdd behat and iterfaces
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microservice
 
Json web token api authorization
Json web token api authorizationJson web token api authorization
Json web token api authorization
 
Think horizontally ood, ddd and bdd
Think horizontally ood, ddd and bddThink horizontally ood, ddd and bdd
Think horizontally ood, ddd and bdd
 
I came i saw i go - golang it meetup codemotion rome 2014
I came i saw i go - golang it meetup codemotion rome 2014I came i saw i go - golang it meetup codemotion rome 2014
I came i saw i go - golang it meetup codemotion rome 2014
 
It's all about behaviour, also in php - phpspec
It's all about behaviour, also in php - phpspecIt's all about behaviour, also in php - phpspec
It's all about behaviour, also in php - phpspec
 
Design pattern in Symfony2 - Nanos gigantium humeris insidentes
Design pattern in Symfony2 - Nanos gigantium humeris insidentesDesign pattern in Symfony2 - Nanos gigantium humeris insidentes
Design pattern in Symfony2 - Nanos gigantium humeris insidentes
 
Rationally boost your symfony2 application with caching tips and monitoring
Rationally boost your symfony2 application with caching tips and monitoringRationally boost your symfony2 application with caching tips and monitoring
Rationally boost your symfony2 application with caching tips and monitoring
 

Recently uploaded

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 

Caching and data analysis will move your Symfony2 application to the next level

  • 1. Zzz and bla^3 will move your to the next level. ???
  • 2. I have not invented anything please read carefully the references not yet 
  • 3. I’m @liuggio (aka Giulio De Donato) I LOVE and its dark passenger fabpot
  • 4. _ _ _ and _ _ _ will move your to the next level. ???
  • 5. _ _ _ and _ _ _ will move your to the next level. Symfony2 application
  • 6. proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/photos/455.jpg HTTP/1.1" 200 986 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/nav/tab_left_middle.gif HTTP/1.1" 200 1020 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" dyn-530.optus.com.au - - [22/Apr/2009:18:52:51 +1200] "GET /images/photos/5332.jpg HTTP/1.1" 200 244 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)" "-" <?xml version="1.0"?> <catalog> <book id="bk101"> <author>Gambardella, Matthew</author> <title>XML Developer's Guide</title> <genre>Computer</genre> <price>44.95</price> <publish_date>2000-10-01</publish_date>dhcp-465.telstra.com.au - - [22/Apr/2009:18:52:51 @charset "UTF-8";html,body,div,span,applet,object,iframe,h1,h2,h3,h4,+1200] "GET /gallery.php? section=entertainment HTTP/1.0" 200 58636 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /adclick.php?c=LME2 HTTP/1.1" 302 378 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/ad/RH4Y.jpeg HTTP/1.1" 200 1031 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/favicon.ico HTTP/1.1" 200 2824 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /adclick.php?c=GD52 HTTP/1.1" 302 379 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like In your company every minute data is generated a lot of differenttotally
  • 7. proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/photos/455.jpg HTTP/1.1" 200 986 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/nav/tab_left_middle.gif HTTP/1.1" 200 1020 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" dyn-530.optus.com.au - - [22/Apr/2009:18:52:51 +1200] "GET /images/photos/5332.jpg HTTP/1.1" 200 244 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)" "-" dhcp-465.telstra.com.au - - [22/Apr/2009:18:52:51 +1200] "GET /gallery.php?section=entertainment HTTP/1.0" 200 58636 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /adclick.php?c=LME2 HTTP/1.1" 302 378 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/ad/RH4Y.jpeg HTTP/1.1" 200 1031 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/favicon.ico HTTP/1.1" 200 2824 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /adclick.php?c=GD52 HTTP/1.1" 302 379 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /stories.php?date=yesterday HTTP/1.1" 200 4231 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /latest.php HTTP/1.1" 200 991 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-622.dsl.clear.net.nz - - [22/Apr/2009:18:52:51 +1200] "GET /latest-news.rss HTTP/1.0" 200 7199 data - Difficult to read - Difficulto to measure - Time consuming
  • 8. proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/photos/455.jpg HTTP/1.1" 200 986 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/nav/tab_left_middle.gif HTTP/1.1" 200 1020 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" dyn-530.optus.com.au - - [22/Apr/2009:18:52:51 +1200] "GET /images/photos/5332.jpg HTTP/1.1" 200 244 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)" "-" dhcp-465.telstra.com.au - - [22/Apr/2009:18:52:51 +1200] "GET /gallery.php?section=entertainment HTTP/1.0" 200 58636 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /adclick.php?c=LME2 HTTP/1.1" 302 378 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/ad/RH4Y.jpeg HTTP/1.1" 200 1031 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/favicon.ico HTTP/1.1" 200 2824 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /adclick.php?c=GD52 HTTP/1.1" 302 379 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /stories.php?date=yesterday HTTP/1.1" 200 4231 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /latest.php HTTP/1.1" 200 991 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-622.dsl.clear.net.nz - - [22/Apr/2009:18:52:51 +1200] "GET /latest-news.rss HTTP/1.0" 200 7199 data Difference audences and destination -business                                                       -applications   -external services -error logs ( js error, and application error) - . . . sucks
  • 9. proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/photos/455.jpg HTTP/1.1" 200 986 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/nav/tab_left_middle.gif HTTP/1.1" 200 1020 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" dyn-530.optus.com.au - - [22/Apr/2009:18:52:51 +1200] "GET /images/photos/5332.jpg HTTP/1.1" 200 244 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)" "-" dhcp-465.telstra.com.au - - [22/Apr/2009:18:52:51 +1200] "GET /gallery.php?section=entertainment HTTP/1.0" 200 58636 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /adclick.php?c=LME2 HTTP/1.1" 302 378 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/ad/RH4Y.jpeg HTTP/1.1" 200 1031 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /images/favicon.ico HTTP/1.1" 200 2824 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /adclick.php?c=GD52 HTTP/1.1" 302 379 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /stories.php?date=yesterday HTTP/1.1" 200 4231 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] "GET /latest.php HTTP/1.1" 200 991 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13" "-" proxy-622.dsl.clear.net.nz - - [22/Apr/2009:18:52:51 +1200] "GET /latest-news.rss HTTP/1.0" 200 7199 rocks data Difference audences and destination -business                                                       -applications   -external services -error logs ( js error, and application error) - . . .
  • 10. What we do with data? _ _ _ _ _ !ignore track
  • 11. We track data _ _ _ _ _ !ignore then
  • 14. Our code generates business value when it runs, not when we write code. @coda
  • 15. Store log and error data Query on past events Locate the bug Know Servers/application status: healthy/resources/ Responding as it should? Face the reality of my ecosystem Understand why and where the app. is slow Analyze the behaviour when it ‘s running watch data be alerted fast website Needs data … BUSINESS VALUE
  • 16. Needs BUSINESS VALUE logging debugging monitoring profiling metricking optimizing Actions Store log and error data Query on past events Locate the bug Know Servers/application status: healthy/resources/ Responding as it should? Face the reality of my ecosystem Understand why and where the app. is slow Analyze the behaviour when it ‘s running watch data be alerted fast website …
  • 17. BUSINESS VALUE logging debugging monitoring profiling metricking optimizing Actions monolog, Logstash, Graylog Sentry / Graylog Nagios, Cacti … external service XhProf statsd-php-client, StatsD, Graphite
  • 18. It's not about the accuracy of estimating it's about facing the reality of uncertainty. @jimhighsmith
  • 19. metrics http://samate.nist.gov/index.php/Metrics_and_Measures.html http://nvlpubs.nist.gov/nistpubs/jres/104/6/j46gra.pdf The IEEE Standard Glossary of Software Engineering Terminology also defines quality metric as : (1) A quantitative measure of the degree to which an item possesses a given quality attribute. (2) A function whose inputs are software data and whose output is a single numerical value that can be interpreted as the degree to which the software possesses a given quality attribute. * @param array $data * @return float function calculateUglyness(array $data);Ninja territory
  • 20. measuring http://samate.nist.gov/index.php/Metrics_and_Measures.html HOW TO MEASURE ANYTHING - FINDING THE VALUE OF “INTANGIBLES” IN BUSINESS second edition Hubbard experimentally obtaining one or more quantity values that can reasonably be attributed to a quantity. reasonably => uncertainty reductionNinja territory
  • 21. What metrics means? DUNNO Merlin knows Yes Matrix I saw the film
  • 22. metrics Visual tool to better understand reality
  • 25. StatsD simple — Node.JS daemon. Listens for message over UDP simple daemon for easy stats aggregation. Graphite rude <key> <numeric value> <timestamp> Graphite stores numeric time-series data. — Real-time graphing system — Components: — Carbon stores the data in Graphite’s specialized database. — The data can then be visualized through graphite web interface developed with django. — Whisper allows carbon to write multiple data points. metrics
  • 26. Symfony2 integration: there’s a bundle for it ‘liuggio/StatsDClientBundle’ — Amount of visitor — Logged vs Anonymous user — Doctrine collector — Amount of PHP peak — Execution Time — Monolog — Easily add a new metric: $this->get(‘stats_d_client.factory')->increment(’upload.file'); metrics
  • 27. Symfony2 integration PHP Peak metrics this is a ‘Timer’
  • 28. Concepts — Bucket — Values — Flush Interval metrics metrics — Counter — Gauge — Timer — Set — Sample Understand StatsD
  • 29. GAUGES are arbitrary values, which can be recorded. metrics $factory = $this->get('stats_d_client.factory'); $data[] = $factory->gauge('cart.item.number', 30); $data[] = $factory->gauge('cart.item.number', 34); $data[] = $factory->gauge('cart.item.number', 38); $this->get('stats_d_client.service’)->send($data); cart.item.number|38 Result is the last one (per flush time)
  • 30. COUNTS increment and decrement a value. metrics $factory = $this->get('stats_d_client.factory'); $data[] = $factory->increment('user.visitor'); $this->get('stats_d_client.service’)->send($data); The value stay in memory until the flush interval.
  • 31. TIMERS collects numbers. metrics $factory = $this->get('stats_d_client.factory'); $data[] = $factory->timing(’php-peak', 500); $this->get('stats_d_client.service’)->send($data); Operations [mean, upper, sum, lower, count, ...] are already calculated 
  • 32. Collect from different sources # echo "deploy.web:1|c" | nc -w 1 -u graphite.com 8125
  • 34. you have more data than you think and you need less data than you think MORELESS
  • 35. new metrics — Why do you want to know? — How much do you know now? — What is the value to additional information
  • 36. The time you spend for metrics has a cost, and usually is more economical than many managers assume. maybe because they didn’t measure. bazinga metrics
  • 39. and _ _ _ will move your to the next level. metrics ???
  • 41.
  • 42. Great caching is like great sex. It hides all the real problems @vivekhaldar
  • 43. Wikipedia: “a Cache ( /’kæ∫/ KASH[1]) is a component that transparently stores data so that future requests for that data can be served faster.” the cache miss happens once for the same response. given the same request the Cache miss happens once. given the same request the response is not ‘processed’ twice. A Cache Hit happens if the Cache contains the answer. A Cache Miss happens if the Cache doesn’t contain the answer. The perfect cache when
  • 45. — Application caching: app/cache with opcode — Response caching and HTTP-CACHE — Doctrine2 Query and Result Caching — CDN and static files — Other CACHE + SF2
  • 46. Terravison vendor folder is about 340 MB The app/cache/prod folder is about 3000 files 1. Annotation (Entity/Controller/...) 2. Template a. name => file b. twig in php 3. Assetic (definition) 4. Url matcher, Url creator 5. Translations array key=>value 6. Doctrine Entity Proxy ./app/cache
  • 47. Add your class to the services with the tag kernel.cache_warmer Note: the CacheWarmerInterface is not properly the same as the snippet. cache warmer namespace SymfonyComponentHttpKernelCacheWarmer; interface CacheWarmerInterface /** * Warms up the cache. * @param string $cacheDir The cache directory */ public function warmUp($cacheDir); public function isOptional()
  • 48. Symfony2 is a web framework built from scratch around the http specification — a resource could be Fresh || Stale — http-caching only on safe method — validation || expiration HTTP
  • 50. HTTP headers $response->setPublic() //default is private $response->setMaxAge(600); // Same as above but only for shared caches $response->setSharedMaxAge(600); $response->setETag(md5($response->getContent())); $response->setLastModified($datetime); if ($response->isNotModified($this->getRequest())) ... $response->setVary(‘Accept-Encoding’); symfony.com/doc/master/book/http_cache.html
  • 51. The least expensive query is the query you never run.
  • 52. DoctrineCommonCacheCache (There’s not tagging) doctrine cache // Fetches an entry from the cache. string function fetch($id); // Tests if an entry exists in the cache. bool function contains($id); // Put data into the cache. bool function save($id, $data, $lifeTime); // Deletes a cache entry. bool function delete($id);
  • 53. MetaData Cache Annotation (OPCODE) Query Cache DQL parsed into SQL (OPCODE/REDIS/MEMCACHED) Result Cache The query result (REDIS/MEMCACHED/OPCODE) doctrine caches
  • 54. doctrine cache Class ProductRepository ... $query = $this->createQueryBuilder(‘p’) ->where(‘p.price > :price’) ->setParameter(‘price’, ‘19.99’) ->getQuery(); $products = $query->getResult(); $query->useResultCache( true, $lifetime, __METHOD__ . serialize($query->getParameters()) ); $query->useQueryCache();
  • 55. There are only two hard things in Computer Science cache invalidation and naming things Phil Karlton There are only two hard things in Computer Science cache invalidation, naming things and off-by-1 errors. anonymous
  • 56. Invalidation Especially for http, but in general, you should not waste time to invalidate a value, but you should invest resources to find the right time of validity. Cache miss storm When a resource is no longer available (cache miss), and is required by many clients simultaneously (storm), a congestion happens. cache miss storm, cache stampede, dog-piling, APC Cache slam cache
  • 57. Pre-Caching/Cacheback Sometimes you need to have some data already available and you don’t want that the first request wait. Uniqueness of the cache key Attention to the conflicts in the key definition, always put a prefix or namespace such as language or role. Http-Microcaching: Save all the responses for 1||2 seconds lot of examples on internet for Nginx cache
  • 58. and _ _ _ will move your to the next level. ???
  • 59.
  • 60. Performance tips - rule #1 Mantainibility win over Performance
  • 61. — The user should never wait     slow operation data in a queue (Redis/*MQ)     processed by a consumer (cli + supersivord): — Image Manipulation — File Creation (pdf) — Sending email as spool — I/O operation — Use Session with Redis/Memcache — Caution on what do you do in the loop && nested loop easy …
  • 62. … tips — Must! OPCODE: APC using the apc.stat = 0 — $php composer.phar dump-autoload –optimize — Twig.c php extension — Assets — Minify and combine all of your CSS and JS files — Run all (or just some) of your CSS or JS files through some sort of compiler, such as LESS, SASS or CoffeeScript — Run image optimizations on your images http://symfony.com/doc/current/book/performance.html https://speakerdeck.com/alexandresalome/symfony2-and-performances
  • 63. the DIC of sf2.3 is lazy A lazy loading value holder proxy is a virtual proxy that wraps and lazily initializes a "real" instance of the proxied class. <service id="foo" class="AcmeFoo" lazy="true" /> When do I use a lazy value holder? -Your object takes a lot of time and memory to be initialized (with all dependencies) -Your object is not always used, and the instantiation overhead can be avoided github.com/Ocramius/ProxyManager/blob/master/docs/lazy-loading-value-holder.md github.com/Ocramius/symfony-docs/blob/master/components/dependency_injection/lazy_services.rst
  • 64. Cache Driver # config_prod.yml services: cache: class: DoctrineCommonCacheApcCache # MemcacheCache # config_dev.yml services: cache: class: DoctrineCommonCacheArrayCache if ($fooString = $this->get(‘cache’)->fetch(‘foo’)) { $foo = unserialize($fooString); } else { // do something with $foo $this->get(‘cache’)->save(‘foo’, serialize($foo), $lifetime); } http://docs.doctrine-project.org/en/latest/reference/caching.html
  • 65. DOCTRINE Object relational mapper (ORM) for PHP that sits on top of a powerful database abstraction layer (DBAL)
  • 67. doctrine >= 2.3 —2.4 flush multiples entities $em->flush(array($entityA, $entityB); —2.4 paginator —2.4 master slave —2.4 join to the interface —2.3 You can override metadata —2.3 Event listener in a separated class /** * @ORMManyToOne(targetEntity="Tvision...EntityStatusInterface") **/ https://speakerdeck.com/asm89/what-is-new-in-doctrine
  • 70. $article = new Article(); $article->setHeadline('I love PHPday'); $em->persist($article); // the entity is managed $em->flush(); // the entity is persisted ... $article->setHeadline('I love JSday and PHPday'); $em->flush(); // the Headline is updated on the persistence layer $em->persist($article);
  • 71. $article = $em->find('Article', 1234); $article->setHeadline(’I love GRUSP'); $article2 = $em->find('Article', 1234); echo $article2->getHeadline(); // I love GRUSP if ($article === $article2) ---> true!!
  • 72. Unit of work https://doctrine-orm.readthedocs.org/en/latest/reference/unitofwork.html Maintains a list of objects affected by a business transaction and coordinates the writing out of changes and the resolution of concurrency problems. P of EAA page 184 Patterns of Enterprise Application Architecture by Martin Fowler UOW = keeps track changes of Objects TL;DR
  • 73. Identity Map The flush has a cost — Number of managed Entities — Tracking policy — Type of entities https://doctrine-orm.readthedocs.org/en/latest/reference/unitofwork.html contains all the managed entities On flush makes a property by property comparison for all the entities managed.
  • 74. tracking policy Doctrine definition: “is the process of determining what has changed in managed entities since the last time they were synchronized with the database.” — implicit tracking (default and simple) — explicit tracking (suggested for lot of entities managed) — notify tracking /** * @Entity * @ChangeTrackingPolicy("DEFERRED_EXPLICIT”) http://docs.doctrine-project.org/en/latest/reference/change-tracking-policies.html Flush optimization #1
  • 75. tracking policy Deferred Implicit UOW = DB http://docs.doctrine-project.org/en/latest/reference/change-tracking-policies.html Deferred Explicit UOW != DB — UOW = ’I love PUG Roma’ — DB is not updated. Need the persist! Flush optimization #1 // $article is already managed or loaded // we are changing the Headline $article->setHeadline('I love PUG Roma'); $em->flush(); echo $article->getHeadline();// is ‘I love PUG Roma’
  • 76. Read only entity /** * @Entity * @READONLY */ Class Status { $em->getUnitOfWork->markReadOnly($entity); Temporarily mark entities as read only Flush optimization #2
  • 77. Flush only on few entities $em->flush($entity) Flush optimization #3
  • 78. Reducing the flush cost The flush has a cost — Number of managed Entities (flushing only some) — Tracking policy (explicit || implicit) — Type of entities (read-only || temp. read-only) Recap.
  • 79. reference $post = $postRepository->find($postId); $comment->setPost($post); ... // $postId comes from somewhere $comment->setPost( $em->getReference(‘AcmeBundleEntityPost’, $postId) ); .
  • 80. lazy associations Association are LAZY by default // Order /** * @ManyToOne(targetEntity=”Cart”, cascade={“all”}, fetch=”EAGER”) */ private $cart <?php $query = $em->createQuery(“SELECT o FROM Order o”); $query->setFetchMode(“Order”, “Cart”, “LAZY”); $query->execute(); Change the fetch mode
  • 81. associations What’s better than LAZY ? /* * @ORMManyToMany(targetEntity=”Trips”, mappedBy=”rides”,fetch=”EXTRA_LAZY”) */ private $trips; $turin->getTrips()->contains($turinCaselle); $turin->getTrips()->count(); $turin->getTrips()->slice($offset, $length);
  • 82. and _ _ _ will move your to the next level. Symfony2 application Optimization
  • 86. Knowing when optimization is premature defines the differences the master engineer and the apprentice Theo Schlossnagle Optimization We’ve heard this a million times
  • 87. When you discover the real problem, you done the half. Problem are not all equals, and most are illusions. Pieter Hintjens
  • 88. Optimization you are doing it wrong: — Cache everything — Guessing / action without measurement
  • 89. and _ _ _ will move your to the next level. Symfony2 application Optimization
  • 90. and will move your to the next level. Symfony2 application Optimization
  • 91. and will move your to the next level. BUSINESS
  • 92. and will move your to the next level. metrics
  • 93. and will move your to the next level. BUSINESS
  • 94. and will move your to the next level. BUSINESS
  • 95. and will move your to the next level. metrics
  • 96. and will move your to the next level. metricsOptimization
  • 97. and will move your to the next level. metrics Symfony2 application
  • 99. Performance optimization could Metrics should Rationality must
  • 101. https://speakerdeck.com/asm89/what-is-new-in-doctrine http://docs.doctrine-project.org/ http://nvlpubs.nist.gov/nistpubs/jres/104/6/j46gra.pdf http://ilia.ws/files/phpuk_bottlenecks.pdf http://www.slideshare.net/anton_chuvakin/log-mining-beyond-log-analysis http://pivotallabs.com/139-metrics-metrics-everywhere/ http://www.hubbardresearch.com (HOW TO MEASURE ANYTHING - FINDING THE VALUE OF “INTANGIBLES” ) https://people.mozilla.com/~rmiller/heka-intro-2013-03/#/2 http://tools.ietf.org/html/draft-ietf-httpbis-p6-cache-18 https://developers.google.com/speed/docs/best-practices/caching http://notmysock.org/blog/php/user-cache-timebomb.html http://sonata-project.org/blog/2012/5/15/assetic-package-configuration http://www.slideshare.net/jonkruger/advanced-objectorientedsolid-principles http://slides.seld.be/?file=2011-10-20+High+Performance+Websites+with+Symfony2.html http://stackoverflow.com/questions/8893081/how-to-cache-in-symfony-2 http://www.slideshare.net/postwait/scalable-internet-architecture http://techportal.inviqa.com/2009/12/01/profiling-with-xhprof/ http://www.mysqlperformanceblog.com/2010/09/10/cache-miss-storm http://www.slideshare.net/iamcal/scalable-web-architectures-common-patterns-ap... http://blog.servergrove.com/2012/04/18/how-to-create-a-cache-warmer-in-symfony2/ http://www.slideshare.net/jwage/doctrine-intherealworldsf-live2011sanfran http://www.slideshare.net/quipo/scalable-architectures-taming-the-twitter-firehose https://github.com/liuggio/StatsDClientBundle http://www.slideshare.net/quipo/monitoring-at-scale-intuitive-dashboard-design http://www.slideshare.net/ihower/rails-performance http://www.infoq.com/presentations/Architecture-Scale-ZeroMQ https://speakerdeck.com/keithpitt/keith-and-marios-guide-to-fast-websites http://www.slideshare.net/anton_chuvakin/log-mining-beyond-log-analysis http://marco-pivetta.com/proxy-pattern-in-php/#/9 http://www.slideshare.net/guilhermeblanco/object-calisthenics-applied-to-php http://talks.php.net/show/dojo/ https://github.com/symfony/symfony/pull/7818 https://speakerdeck.com/roidrage/metrics-monitoring-logging http://codahale.com/codeconf-2011-04-09-metrics-metrics-everywhere.pdf http://pivotallabs.com/139-metrics-metrics-everywhere/ http://blog.pkhamre.com/2012/07/24/understanding-statsd-and-graphite/ References

Editor's Notes

  1. OK the real title is zzz and blblabla will move your something to the next level
  2. This is a not invented here talk, The topics I ‘ d like to discuss are all well known, I have not invented anything please go there to read the references such as the talk of Jordi etc. I’m here to share my knowledge SEE THE REFERENCES
  3. I love the Symfony2 framework, G ave us: a breath of FRESHNESS to the whole php world , GREAT DOCUMENTATION/ NOT FRAMEWORK but BESTPRACTICES , great community / METHODOLOGIES gave as a real dark passenger, dark passenger means that there ’ s a little genious/geek that is on your shoulder when you develop B ut this dark passengere LOOK AT YOU not at the code at YOU M y dark passenger speaks FRANCE You ’ ave not Follow^ng coding standards, dependency injection. When I met this small dark passenger he grows up, I feel better my libraries are more usable. I realized that bigger is your dark passenger and the more you are a cool developer. S o at terravision we do love sf2 and it ’ s fabpot passenger.
  4. OK the real title is zzz and blblabla will move your something to the next level
  5. OK the real title is zzz and blblabla will move your something to the next level
  6. We are developer our ecosystem create a lot of data.    [ok hey liuggio what problem do you have with data?] -------- data is difficult to measure, difficult to read, data is time consuming. ------- data is boring,-- data sucks * (sometimes) Logging ---------- If you think that logging is a file with a lot of unreadable information. Logging will have a Matrix effect with data. You don’t’need logging only when something bad happen How many of you use logging, How many of you thinks that logging is a file with too much iformation in it… Logging is a black hole in the developers career,
  7. [ok hey liuggio what problem do you have with data?] data is difficult to measure, difficult to read, data is time consuming. ------- data is boring,-- data sucks * (sometimes)
  8. what is data? different information from ----- Note riunione (5/15/13 08:26) ----- data gathers
  9. what is data? different information from ----- Note riunione (5/15/13 08:26) ----- data gathers
  10. I do we do, we used to ignore the most of data that we receive. But sometimes we track it, maybe passively but we keep track of some events for example logging
  11. What do you do? 1. I ignore them 2. I ignore them but I have a clear coscience (because there ’ s a file for it) 3. I ignore them mmm but I ’ ll use regex when an halling customer will call (if you have a problem that you want to solve with the regex, you have 2 problem) I f you try to solve a problem with a regular expression, you have 2 problems. 4. I ignore the log, regex and the customer. S ometimes you need to investigate, A lways you need to be alerted when .. Y ou want to see graphes In the daylife is very important have PULL information like a big lcd monitor over there
  12. Why should we use all that data? What is business value: all the things that produces money W e are coder, we love write code, but our code produce business, W e use unit testing in order to have maintainability of the code, this could be a business value we use function testing, because we want to add new features easily this could be a business value A nd we want that if angry customer will call you we have already the answer Y ou want a fast user experience Y ou want to know what is happening in your application --------- code is not a trophy functionality measure it in order to know face the reality measure on production
  13. If you don’t understand this slide you are not stupid maybe because you never seen the ‘ hitchhiker&apos;s guide to the galaxy ’ movie. Hitchhikers
  14. We use phpunit in order to easily add new feature and have code manintainability not because is cool ----- Note riunione (5/16/13 17:55) ----- each company has it&apos;s own business value.
  15. All of this are some business value that you could achieve tracking data. Business Value is everything that produces € ( For example Unit testing produce business value (we do use unit testing in order to have maintainability of the code (easy to add a new feature) that is a business value.) Each company has its own definition of business Value, but we could define some needs that could increment your Business Value. (could because if you don ’ t care it ’ s ok) Store log and error data (investigate) Complex query on past events Easily Locate the bugs Know Servers status: healthy/resources Know Application status: Responding as it should? Know what is happening in my ecosystem Understand why and where the app. is slow Analyze the behaviour when it ‘ s running I want to watch data I want to be alerted Fast website I want to know how if after a certain event “ how much ” something else changed Interpolate data from different sources               (after the deploy, how many t-shirt were bought?) We added to many information here Investigate means that we need to collect and create relations among different logs and make queries Be alerted means that we want on different context an action Visualize means meseaure and draw from the data Noi creiamo cose  e dobbiamo interessarci del business value, il nostro codice produce business value add new features easily business value  -&gt; all the things that produces €€ code is not a trophy functionality T here ’ s a name for everything … measure it in order to know face the reality measure on production ----- Note riunione (5/14/13 00:11) ----- satisfy ----- Note riunione (5/16/13 17:55) ----- this is business value from the developer side and data
  16. In order to do this we need to add different actions ----- Note riunione (5/15/13 08:50) ----- perform actions
  17. In order to do this we need to add different actions ----- Note riunione (5/16/13 11:20) ----- in here there&apos;s the talk title: from metrics and optimizing you obtain a business value
  18. I’d like to talk with you about Metrics Measure: WE WANT TO FACE THE REALITY The terms metric and measure have some overlap. We use measure for more concrete or objective attributes and metric for more abstract, higher-level, or somewhat subjective attributes. For instance, lines of code (LOC) is a measure: it is objective and concrete The robustness is a metrics M easurment are the basis for the metrics Measures help us approximate less tangible metrics.
  19. Metrics is a link of two worlds technical and business vision of IT.    [yes ok but what is?] ------ definition of metrics … sucks is so general and everybody has their own, ----- Metrics -- definition       metrics gives you qualitatively information (and measure quantity information) ----- Note riunione (5/15/13 09:15) ----- line of code examples measure, metrics
  20. A quantitatively expressed reduction of uncertainty based on one or more observations. Think a measure as a quantitative number (image you could measure anything) This “ uncertainty reduction ” point of view is what is critical to busi- ness reduction can be worth millions. HOW TO MEASURE ANYTHING Hubbard measurement process of experimentally obtaining one or more quantity values that can reasonably be attributed to a quantity
  21. When you don’t know something you could ask to them. What metrics is
  22. Metrics number visual ops it’s a ninja territory?
  23. Why metrics is so important? Is a join of two worlds
  24. Metrics in order to produce Graphs → Decision decision because you could Collects and aggregates from different sources sources of metrics: webservers, application, cache server, averything! Better decision using numbers  -- @coda
  25. How to do metrics? StatsD We want a great tool in order to add easily new metrics. From every envoirnment, every language every where.
  26. Calculate the amout of php ram during it’s peak time Ready for the WTF effect? This is a “timer”
  27. Each stat is in its own &quot; bucket ” the KEY, They are not predefined anywhere. Buckets can be named anything that will translate to Graphite (periods make folders, etc) After the flush interval timeout (defined by config.flushInterval, default 10 seconds), stats are aggregated and sent to an upstream backend service.
  28. A gauge simply indicates an arbitrary value at a point in time and is the most simple type in StatsD. It just takes any number and ships it to the backend.
  29. Counters are simple. It adds a value to a bucket and stays in memory until the flush interval.
  30. Timers collects numbers. They does not necessarily need to contain a value of time. You can collect bytes read, number of objects in some storage, or anything that is a number. Useful for: mean/upper/sum/lower/count Operation
  31. Timers collects numbers. They does not necessarily need to contain a value of time. You can collect bytes read, number of objects in some storage, or anything that is a number. Useful for: mean/upper/sum/lower/count Operation
  32. Here is a golden rule that you find in all talks about metrics I prefer metrics CAN … Because too much not usefull information could go to CONFUSION. == with Metrics you track everythings that moves  [on internet this is like  a cool definition] BUT
  33. Se teniamo sempre alto il livello di razionalità questo ci farà dire:
  34. È molto
  35. Se teniamo sempre alto il livello di razionalità questo ci farà dire:
  36. Better decision using numbers  -- @coda Good and Fast decisions help the business
  37. Better decision using numbers  -- @coda Good and Fast decisions help the business
  38. OK the real title is zzz and blblabla will move your something to the next level
  39. Another topic that has a lot of usages is the cache What do you think if I say cache?
  40. Another topic that has a lot of usages is the cache What do you think if I say cache?
  41. Another topic that has a lot of usages is the cache What do you think if I say cache?
  42. ----- Note riunione (5/11/13 21:43) ----- proxy
  43. This is a great idea, We are web developer So we need to follow the web protocol Why I didn’t think about it before?
  44. ----- Note riunione (5/14/13 00:11) ----- scrivere nei commenti fig!!
  45. Another topic that has a lot of usages is the cache What do you think if I say cache?
  46. OK the real title is zzz and blblabla will move your something to the next level
  47. Y ou could do by yourself This code is problematic, and adds a lot of complexity that makes your unit tests&apos; code even worse. https://github.com/Ocramius/ProxyManager/blob/master/docs/lazy-loading-value-holder.md https://github.com/Ocramius/symfony-docs/blob/931091d8e3aa0b9d4f1393d313388d5ee1a5d47d/components/dependency_injection/lazy_services.rst
  48. flush multiples entities      $em-&gt;flush(array($entityA, $entityB); paginator      master-slave     Flush to Master Read from Slave join to interface (Target Entity Resolver: /**    @ORM\\ManyToOne(targetEntity=&quot;Tvision\\Bundle\\OrderBundle\\Entity\\StatusInterface&quot;) **/
  49. flush multiples entities      $em-&gt;flush(array($entityA, $entityB); paginator      master-slave     Flush to Master Read from Slave join to interface (Target Entity Resolver: /**    @ORM\\ManyToOne(targetEntity=&quot;Tvision\\Bundle\\OrderBundle\\Entity\\StatusInterface&quot;) **/
  50. ----- Note riunione (5/14/13 00:11) ----- levare flush
  51. The deferred implicit policy is the default change tracking policy and the most convenient one.property-by-property comparison at commit time and also detects changes to entities or new entities that are referenced by other managed entities ( “ persistence by reachability ” ) Explicit only considers entities that have been explicitly marked for change detection through a call to EntityManager#persist(entity) or through a save cascade.
  52. Starting from the daylife in order to undestand UOW ----- Note riunione (5/16/13 11:41) ----- there&apos;s a line that could&apos;nt be there
  53. T he unit of work class in doctrine ha 3206 lines, is complex UOW start with with init of EM or after a flush. The size of a Unit of Work mainly refers to the number of managed entities Is an Entity managed by UOW when is persisted or when is fetched Identity Map: In this case the Article is accessed from the entity manager twice, but modified in between. How costly a flush operation is, mainly depends on two factors: The size of the EntityManager ’ s current UnitOfWork. The configured change tracking policies You can get the size of a UnitOfWork as follows: &lt;?php $uowSize = $em-&gt;getUnitOfWork()-&gt;size();
  54. T he unit of work class in doctrine ha 3206 lines, is complex UOW start with with init of EM or after a flush. The size of a Unit of Work mainly refers to the number of managed entities Is an Entity managed by UOW when is persisted or when is fetched Identity Map: In this case the Article is accessed from the entity manager twice, but modified in between. How costly a flush operation is, mainly depends on two factors: The size of the EntityManager ’ s current UnitOfWork. The configured change tracking policies You can get the size of a UnitOfWork as follows: &lt;?php $uowSize = $em-&gt;getUnitOfWork()-&gt;size();
  55. T he unit of work class in doctrine ha 3206 lines, is complex UOW start with with init of EM or after a flush. The size of a Unit of Work mainly refers to the number of managed entities Is an Entity managed by UOW when is persisted or when is fetched Identity Map: In this case the Article is accessed from the entity manager twice, but modified in between. How costly a flush operation is, mainly depends on two factors: The size of the EntityManager ’ s current UnitOfWork. The configured change tracking policies You can get the size of a UnitOfWork as follows: &lt;?php $uowSize = $em-&gt;getUnitOfWork()-&gt;size();
  56. The deferred implicit policy is the default change tracking policy and the most convenient one.property-by-property comparison at commit time and also detects changes to entities or new entities that are referenced by other managed entities ( “ persistence by reachability ” ) Explicit only considers entities that have been explicitly marked for change detection through a call to EntityManager#persist(entity) or through a save cascade.
  57. Deferred Implicit P ro : persist($entity) is not necessary Cons : bad performance with large UOW Deferred Explicit Pro : flush operation cheaper Cons : DB != UOW spread persists into the code Unit of work now has $entity.title=liuggio loves symfony2 Database has flushed without persist $entity.title=liuggio loves symfony2 Pro : $entityManager-&gt;persist($entity) is not necessary Cons : Slowness, Doctrine has to check property-by-property for all the object in the unit of work Explicit Doctrine2 tracking policy 23 April 2013 doctrine2 1 php 9 Which tracking policy are you using? With doctrine you can change the tracking policy for each entity, the tracking policy is the way in which Doctrine understands if a entity property must be ‘ saved ’ in the database. Doctrine definition: “ Change tracking is the process of determining what has changed in managed entities since the last time they were synchronized with the database. ” There are 3 tracking policies: Implicit, Explicit, Nofity. Implicit tracking (the default one) The implicit is the default one and the slowest, you don ’ t need to explicit call ‘ persist ’ eg. // $entity is not a new object, and has $entity-&gt;Title = &apos;liuggio loves tvision.github.io&apos; $entity-&gt;setTitle(&apos;liuggio loves symfony2&apos;); $entityManager-&gt;flush(); echo $entity-&gt;getTitle(); // output &apos;liuggio loves symfony2&apos; Unit of work now has $entity.title=liuggio loves symfony2 Database has flushed without persist $entity.title=liuggio loves symfony2 Pro : $entityManager-&gt;persist($entity) is not necessary Cons : Slowness, Doctrine has to check property-by-property for all the object in the unit of work The explicit tracking (the suggested one) You have to explicit flag which object you want to persist, than Doctrine will check property-by-property in order to find with property has changed. Pro : Faster than implicit, must if you have a lot of entities. Cons : the object in the unit of work could be different from that one in the db, not easy to debug. The example
  58. Temporarily mark entities as read only. If you have a very large UnitOfWork but know that a large set of entities has not changed, just mark them as read only with $entityManager-&gt;getUnitOfWork()-&gt;markReadOnly($entity).
  59. T he unit of work class in doctrine ha 3206 lines, is complex UOW start with with init of EM or after a flush. The size of a Unit of Work mainly refers to the number of managed entities Is an Entity managed by UOW when is persisted or when is fetched Identity Map: In this case the Article is accessed from the entity manager twice, but modified in between. How costly a flush operation is, mainly depends on two factors: The size of the EntityManager ’ s current UnitOfWork. The configured change tracking policies You can get the size of a UnitOfWork as follows: &lt;?php $uowSize = $em-&gt;getUnitOfWork()-&gt;size();
  60. OK the real title is zzz and blblabla will move your something to the next level
  61. I’d like to talk to you about metrics I do love metrics Mr smisth sentence:
  62. È molto
  63. OK the real title is zzz and blblabla will move your something to the next level
  64. OK the real title is zzz and blblabla will move your something to the next level
  65. OK the real title is zzz and blblabla will move your something to the next level
  66. OK the real title is zzz and blblabla will move your something to the next level
  67. OK the real title is zzz and blblabla will move your something to the next level
  68. OK the real title is zzz and blblabla will move your something to the next level
  69. OK the real title is zzz and blblabla will move your something to the next level
  70. OK the real title is zzz and blblabla will move your something to the next level
  71. OK the real title is zzz and blblabla will move your something to the next level