Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma
-
Upload
hueseyin-mert -
Category
Engineering
-
view
1.230 -
download
2
description
Transcript of Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma
![Page 1: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/1.jpg)
Symfony2 + Doctrine
PostgreSQL
Symfony2 ve Doctrine ile PostgreSQL'i
kullanarak Performanslı Mimari oluşturma
1
![Page 2: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/2.jpg)
çok sevdiğimiz diller
2
![Page 3: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/3.jpg)
çok sevdiğimiz veribanları
3
![Page 4: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/4.jpg)
çok sevdiğimiz ortamlar
4
![Page 5: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/5.jpg)
yapan kraldır
5@okulbilisim
![Page 6: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/6.jpg)
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
![Page 7: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/7.jpg)
facebook gibi hızlı geliyor
Performans?
7
![Page 8: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/8.jpg)
her şeyi cachelemek, arkada yapıp getirmek iyidir
8
![Page 9: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/9.jpg)
keşler
LB cache
Nginx FastCGI
app/cache and APC
Response caching & HTTP-CACHE
Doctrine2 Query & Result Caching
CDN
9
![Page 10: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/10.jpg)
http://analytics.blogspot.com.tr/2012/04/global-site-speed-overview-how-fast-are.html
10
![Page 11: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/11.jpg)
load test
Performans analizi nasıl
yapılır?
11
![Page 12: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/12.jpg)
https://twitter.com/yuxel/status/279319192757493760
12
@GoyGoyTR
![Page 13: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/13.jpg)
Load Test
http://jmeter.apache.org/
13
![Page 14: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/14.jpg)
Araçlar
● htop
● siege
● hping3
● dstat
● wacth -n .5 ‘netstat -ant|grep ESTAB|wc -l’
● iostat
● çok bilgi
14
![Page 15: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/15.jpg)
apache?
nginx + fpm
15
![Page 16: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/16.jpg)
nginx + fpm
16
http://highscalability.com/blog/2014/4/30/10-tips-for-optimizing-nginx-and-php-fpm-for-high-traffic-si.html
http://lukasz.cepowski.com/devlog/43,high-performance-web-server-with-nginx-and-php-fpm
http://blog.martinfjordvald.com/2010/09/12000-requests-per-second-with-nginx-php-and-memcached/
1. SSD
2. TCP -> UNIX domain sockets.
3. worker_processes
4. worker_connections.
5. upstream
6. access_log off;
7. GZip.
8. fast_cgi_cache
9. client timeouts.
10. output buffers.
11. /etc/sysctl.conf
![Page 17: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/17.jpg)
gc_disable
17
https://github.com/composer/composer/commit/ac676f47f7bbc619678a29deae097b6b0710b799
http://blog.ircmaxell.com/2014/12/what-about-garbage.html
![Page 18: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/18.jpg)
Symfony2 Performans
18
![Page 19: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/19.jpg)
19
Symfony zaten hızlı
Daha hızlı olması için yapabileceğiniz çok az şey var.
![Page 20: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/20.jpg)
Byte Code Cache
Apc
Xcache
ionCube
Zend Opcache
20
![Page 21: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/21.jpg)
Composer Class Map
composer dump-autoload --optimize
21
![Page 22: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/22.jpg)
Dump Router
php app/console --env=prod router:dump...RewriteCond %{REQUEST_URI} ^/city$RewriteRule .* $0/ [QSA,L,R=301]RewriteCond %{REQUEST_URI} ^/city/$RewriteRule .* app.php [QSA,L,E=_ROUTING_route:city,E=_ROUTING_default__controller:TestBundle\\Controller\\CityController\:\:indexAction]...
22
![Page 23: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/23.jpg)
Doctrine
23
![Page 24: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/24.jpg)
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
![Page 25: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/25.jpg)
doctrine:orm:
metadata_cache_driver: memcachequery_cache_driver: memcacheresult_cache_driver: memcache
25
![Page 26: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/26.jpg)
Memcache
APC
Redis
Xcache
File
Custom Cache Service
26
![Page 27: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/27.jpg)
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
![Page 28: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/28.jpg)
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
![Page 29: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/29.jpg)
Result Cache
Sadece ihtiyaç halinde
$query = $em->createQuery('...');$query->useResultCache(true);
// setResultCacheLifetime(3600);// setResultCacheId('my_custom_id');// useResultCache(true, 3600, 'my_custom_id');
29
![Page 30: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/30.jpg)
30
Cache Slam!
![Page 31: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/31.jpg)
Fetch Modes
31
![Page 32: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/32.jpg)
Lazy vs Extra LazyDoctrine 2.0 Doctrine 2.1
32
![Page 33: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/33.jpg)
getSinlgeScalarResult
$ref = $em->createQuery( "SELECT PARTIAL s.title " . "FROM BlogBundle:Post s " . "WHERE s.id = ?1" )->setParameter(1, $id)->getSingleScalerResult()
33
![Page 34: Symfony2 ve Doctrine ile PostgreSQL'i Kullanarak Performanslı Mimari Oluşturma](https://reader034.fdocument.pub/reader034/viewer/2022050802/559cce231a28abaf1f8b47a7/html5/thumbnails/34.jpg)
getPartialReference
$ref = $em->createQuery( "SELECT PARTIAL s.{keywords,title} " . "FROM BlogBundle:Post s " . "WHERE s.id = ?1" )->setParameter(1, $id)->getResult();
$ref = $em->getPartialReference("BlogBundle:Post", $id)
34