6. Ajanda
● Performans nedir?
● Performans analizi nasıl yapılır?
● Nginx ve FPM performans
● Symfony2 performans
● Doctrine performans
● Web Sayfasındaki performans
● Organik DDoS (Normal insan saldırısı)
6
24. Doctrine
The Doctrine Project is the home to several
PHP libraries primarily focused on database
storage and object mapping. The core projects
are a Object Relational Mapper (ORM) and
the Database Abstraction Layer (DBAL) it is
built upon.
http://www.doctrine-project.org/
24
27. Metadata Cache
Her istek sırasında Annotation, YAML, XML gibi
farklı bir çok yerden class metadata
oluşturulmasının önüne geçer
27
28. Query Cache
DQL sorgusunun SQL karşılığının bir değişim
olmadığı sürece tekrar tekrar
oluşturulmasından kaynaklı performans kaybını
gidermek için
28
29. Result Cache
Sadece ihtiyaç halinde
$query = $em->createQuery('...');
$query->useResultCache(true);
// setResultCacheLifetime(3600);
// setResultCacheId('my_custom_id');
// useResultCache(true, 3600, 'my_custom_id');
29
autoload class dosyalarının filecheck ile path kontrollerinin önün geçer
Object relational mapper (ORM) for PHP that sits on top of a powerful database abstraction layer (DBAL). One of its key features is the option to write database queries in a proprietary object oriented SQL dialect called Doctrine Query Language (DQL), inspired by Hibernates HQL. This provides developers with a powerful alternative to SQL that maintains flexibility without requiring unnecessary code duplication.
Something to be careful of when using the cache drivers is “cache slams”. Imagine you have a heavily trafficked website with some code that checks for the existence of a cache record and if it does not exist it generates the information and saves it to the cache. Now, if 100 requests were issued all at the same time and each one sees the cache does not exist and they all try to insert the same cache entry it could lock up APC, Xcache, etc. and cause problems. Ways exist to work around this, like pre-populating your cache and not letting your users’ requests populate the cache.
In many cases associations between entities can get pretty large. Even in a simple scenario like a blog. where posts can be commented, you always have to assume that a post draws hundreds of comments. In Doctrine 2.0 if you accessed an association it would always get loaded completely into memory. This can lead to pretty serious performance problems, if your associations contain several hundreds or thousands of entities.
With Doctrine 2.1 a feature called Extra Lazy is introduced for associations. Associations are marked as Lazy by default, which means the whole collection object for an association is populated the first time its accessed. If you mark an association as extra lazy the following methods on collections can be called without triggering a full load of the collection:
Collection#contains($entity)
Collection#containsKey($key) (available with Doctrine 2.5)
Collection#count()
Collection#get($key) (available with Doctrine 2.4)
Collection#slice($offset, $length = null)
Another interesting use-case: updating an object without loading it (as an alternative to a DQL bulk UPDATE):
$user = $em->getPartialReference('User', $userId);$user->setName('newname');$em->flush();