Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter requests per second very slow.
#1

[eluser]Unknown[/eluser]
Hello all,

Can anyone help explain why using a fresh install and having the welcome controller simply echo 'hello' is way slower than just having a regular ol' php file echo 'hello' by a insane number? yes, the framework adds complexity, etc. but these numbers are scary. my apache benchmarks are below. one is simply test.php doing the following:

Code:
<?php echo 'hello'; ?>

the other is a fresh install of codeigniter in the welcome controller as follows:

Code:
public function index()
{  
  echo 'hello';
}

here are my benchmarks, they are all on a amazon ec2 micro for the test -

first using the flat php file:

Code:
ab -c 10 -t 60 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 5000 requests
Completed 10000 requests
Completed 15000 requests
Completed 20000 requests
Completed 25000 requests
Completed 30000 requests
Finished 34957 requests


Server Software:        Apache/2.2.23
Server Hostname:        localhost
Server Port:            80

Document Path:          /test.php
Document Length:        5 bytes

Concurrency Level:      10
Time taken for tests:   60.168 seconds
Complete requests:      34957
Failed requests:        0
Write errors:           0
Total transferred:      7655583 bytes
HTML transferred:       174785 bytes
Requests per second:    580.99 [#/sec] (mean)
Time per request:       17.212 [ms] (mean)
Time per request:       1.721 [ms] (mean, across all concurrent requests)
Transfer rate:          124.25 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    6  21.0      2     135
Processing:     0   11  59.8      2    2030
Waiting:        0    8  48.6      2    1920
Total:          0   17  62.7      4    2032

Percentage of the requests served within a certain time (ms)
  50%      4
  66%      4
  75%      4
  80%      4
  90%      5
  95%    112
  98%    112
  99%    117
100%   2032 (longest request)

next using codeigniter:

Code:
ab -c 10 -t 60 http://localhost/test/
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)
Finished 1330 requests


Server Software:        Apache/2.2.23
Server Hostname:        localhost
Server Port:            80

Document Path:          /test/
Document Length:        5 bytes

Concurrency Level:      10
Time taken for tests:   60.126 seconds
Complete requests:      1330
Failed requests:        0
Write errors:           0
Total transferred:      291270 bytes
HTML transferred:       6650 bytes
Requests per second:    22.12 [#/sec] (mean)
Time per request:       452.074 [ms] (mean)
Time per request:       45.207 [ms] (mean, across all concurrent requests)
Transfer rate:          4.73 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1  13.8      0     236
Processing:    98  443 703.6    135    4320
Waiting:        0  417 688.0    123    4320
Total:         98  444 704.6    135    4320

Percentage of the requests served within a certain time (ms)
  50%    135
  66%    141
  75%    157
  80%    463
  90%   1320
  95%   2275
  98%   2761
  99%   3355
100%   4320 (longest request)
#2

[eluser]pickupman[/eluser]
Yes, running thousands of lines of code more, will be slower. Starting coding a complete application using plain PHP, and then code similar function in CI. You will find that gap will shrink. You are kind of comparing apples and oranges. CI is still one of the faster mature frameworks. Sure there are faster ones, but doesn't have the community behind them to keep them going.

Also, keep in mind what these stats truly mean rather than the actual number. Taking your slow CI number of 22.12 request per second.
22.12 x 60 = 1,327.20 request / min
1,327.20 x 60 = 796,212.00 request / hour
796,212.00 x 24 = 19, 109, 088.00 request / day

If you consider these number 22.12 request per second doesn't look to bad. If you are getting almost 800k hits per hour, you will likely be scaling your project to a bigger server.
#3

[eluser]WanWizard[/eluser]
This test is completely ridiculous.

You are comparing the execution of a single line with loading a framework. The framework can never win. If you want to benchmark, take a fully functional page, that includes URI parsing, database access, page generation, etc.

What you also should take into account is that there are other cost factors then only bare metal. Consider the cost of a very powerful server ($100 per month?) compared to a developer that has to maintain non-structured, non-OOP code ($100 per hour?).

You'll see that the little overhead the framework introduces will become insignificant for any reasonable sized application that has a multiple year lifecycle.
#4

[eluser]CroNiX[/eluser]
In addition to what WanWizard and others said, which I completely agree with, anything in OOP PHP will be slower than straight up Procedural PHP every time. OOP itself has overhead.

Frameworks have even more overhead. If you want to compare Framework speed, it should be against other Frameworks. Like create the exact same application in Kohana, FuelPHP, Laravel, CakePHP, etc., and then compare that to the CI benchmarks.




Theme © iAndrew 2016 - Forum software by © MyBB