PHP Framework Seçimi ve Performans Sorunu
PHP konusunda junior seviyesinin üzerine çıkmış iki kişi bir araya geldiğinde büyük bir tartışma konusudur frameworkler ve performansları.
Frameworkler kod yazarken okurken ve düzeltirken can kurtarsa da performans olarak değerlendirildiği zaman sonuç biraz hüsran oluyor ben sizler için 2 gözde framewok Codeigniter ve Zend i ayrıca bunlara ek olarak Core php yi kıyasladım. Bunun içinhttp://avnetlabs.com/php/php-framework-comparison-benchmarks adresindenden aynı işleri yapan kodları indirip lokalize ettim ve sonra bunları Apache Benchmark Tool ile test ettim.
5 concurrency ve 1000 request göndererek kendi bilgisayarımda bu testi gerçekleştirdim.
Zend için test sonuçları :
mustafa@mustafa-laptop:~/public_html/test/zend/application$ ab -n 1000 -c 5 http://localhost/test/zend/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: Apache/2.2.14
Server Hostname: localhost
Server Port: 80
Document Path: /test/zend/
Document Length: 1375 bytes
Concurrency Level: 5
Time taken for tests: 17.165 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 1588000 bytes
HTML transferred: 1375000 bytes
Requests per second: 58.26 [#/sec] (mean)
Time per request: 85.827 [ms] (mean)
Time per request: 17.165 [ms] (mean, across all concurrent requests)
Transfer rate: 90.34 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 2
Processing: 39 86 24.3 82 191
Waiting: 39 85 24.2 82 191
Total: 39 86 24.3 82 191
Percentage of the requests served within a certain time (ms)
50% 82
66% 94
75% 101
80% 106
90% 119
95% 131
98% 143
99% 149
100% 191 (longest request)
Codeigniter için test sonuçları :
mustafa@mustafa-laptop:~/public_html/test/zend/application$ ab -n 1000 -c 5 http://localhost/test/codeigniter/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: Apache/2.2.14
Server Hostname: localhost
Server Port: 80
Document Path: /test/codeigniter/
Document Length: 1400 bytes
Concurrency Level: 5
Time taken for tests: 7.937 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 1613000 bytes
HTML transferred: 1400000 bytes
Requests per second: 125.99 [#/sec] (mean)
Time per request: 39.684 [ms] (mean)
Time per request: 7.937 [ms] (mean, across all concurrent requests)
Transfer rate: 198.47 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.7 0 22
Processing: 18 40 13.4 38 86
Waiting: 18 39 13.3 38 86
Total: 18 40 13.4 38 86
Percentage of the requests served within a certain time (ms)
50% 38
66% 46
75% 49
80% 52
90% 58
95% 63
98% 70
99% 72
100% 86 (longest request)
Evet şekilde de görüldüğü gibi bu kodlar için ki bu basit işlem yapan kodlar sadece veritabanına bağlanarak 4 adet satır çekip ekrana basıyor, görmüş olduk ki Codeigniter Zendframework e göre 2 kat civarında daha hızlı gibi duruyor.Fakat bu demek değildirki Codeigniter Zend den daha iyi bir framework.Zend in zengin kütiphanesi, esnekliği ve çok biçimli obje yönelimli yapısı ile Codeigniter ın ki kıyaslanamaz bile.
Burada temel sorun şu performans mı hızlı ve anlaşılabilir kod geliştirme mi ?
Mesela aynı işi core php yazarak yaptığımızda:
mustafa@mustafa-laptop:~/public_html/test/zend/application$ ab -n 1000 -c 5 http://localhost/test/php/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: Apache/2.2.14
Server Hostname: localhost
Server Port: 80
Document Path: /test/php/
Document Length: 157 bytes
Concurrency Level: 5
Time taken for tests: 0.359 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 369000 bytes
HTML transferred: 157000 bytes
Requests per second: 2784.41 [#/sec] (mean)
Time per request: 1.796 [ms] (mean)
Time per request: 0.359 [ms] (mean, across all concurrent requests)
Transfer rate: 1003.37 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 2
Processing: 1 2 0.6 1 6
Waiting: 0 1 0.6 1 6
Total: 1 2 0.7 2 7
WARNING: The median and mean for the processing time are not within a normal deviation
These results are probably not that reliable.
Percentage of the requests served within a certain time (ms)
50% 2
66% 2
75% 2
80% 2
90% 3
95% 3
98% 4
99% 4
100% 7 (longest request)
mustafa@mustafa-laptop:~/public_html/test/zend/application$
gibi inanılmaz bir sonuç ortayha çıkıyor. Framework seçerken kriterimiz performans mı yoksa hızlı geliştirme mi? Mesela paranız var ve bir proje geliştireceksiniz.Para sizin için sorun değil ise Zend framework kullanıp sunucu sayısını çoklayabilir böylece hızlı ve okunaklı kod yazılmasını sağlayabilirsiniz.Zend framework ün o süper lifecycle ından doğan problemleri sunucu sayısını çoğaltarak aşabilirsiniz.
Diğer türlü evet sunucu sayınız az olur fakat core php yazıldığını düşünürsek herkesin kafasına göre kod yazdığı bir ortamda bir önceki yazılımcının işinin başka bir yazılımcı tarafından devam ettirilmesi çok zor olacaktır.Geliştirme süreçleri uzayacak, kodda bug çıkma ihtimali inanılmaz artacaktır.
Şu da yapılabilir. Frameworklerin biraz hantallaşmış yapılarından kurtulmak ve kodun aynı zamanda kodun anlaşılabilir olması için nasıl bir yol izlenmeli?
Bunun içinde kendi MVC yapınızı yazıp onu kullanmanız bir alternatif olarak değerlendirilebilir.Ama kabul edelim ki tek başınıza geliştirdiğiniz ve belli bir süre ayırdığnız kendi framework ünüz hiçbir zaman mevcut frameworklerden daha iyi olmayacak . Karar sizin, bence framework olmadan geliştirilen kod ciddi anlamda sıkıntı :)

RSS
E-Bülten