Ralfk
Posts: 7
Joined: Tue May 15, 2012 8:23 pm

R-Pi as a Webserver - Performance

Thu May 17, 2012 2:03 pm

Hi there,

after some testing an optimising I want to share my results with you:
(all results for the Pi without a cache) The page I tested is written in php and makes some database querry(sellect's 150 entries).
I use lighttpd, with php5-fcgi and apc running an Arch-linux using "arm224_start.elf" to maximize Ram(which is entirely not needed for this test, since it uses only ~35mb)
with default clock settings:

Code: Select all

[ralf@rasp-pi ~]$  ab -n 100 -c 5 http://localhost/files
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).....done


Server Software:        lighttpd/1.4.30
Server Hostname:        localhost
Server Port:            80

Document Path:          /files
Document Length:        129408 bytes

Concurrency Level:      5
Time taken for tests:   107.348 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      12955800 bytes
HTML transferred:       12940800 bytes
Requests per second:    0.93 [#/sec] (mean)
Time per request:       5367.385 [ms] (mean)
Time per request:       1073.477 [ms] (mean, across all concurrent requests)
Transfer rate:          117.86 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.8      0       8
Processing:  2426 5310 2308.9   3899   12768
Waiting:      840 2327 2114.9   1090   10499
Total:       2427 5311 2308.8   3900   12769
WARNING: The median and mean for the initial connection 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%   3900
  66%   4274
  75%   7530
  80%   7606
  90%   8435
  95%  10593
  98%  11161
  99%  12769
 100%  12769 (longest request)

with overclocking to 950MHz for the CPU and 450MHz for RAM:

Code: Select all

ab -n 100 -c 5 http://localhost/files
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).....done


Server Software:        lighttpd/1.4.30
Server Hostname:        localhost
Server Port:            80

Document Path:          /files
Document Length:        111887 bytes

Concurrency Level:      5
Time taken for tests:   76.347 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      11203700 bytes
HTML transferred:       11188700 bytes
Requests per second:    1.31 [#/sec] (mean)
Time per request:       3817.344 [ms] (mean)
Time per request:       763.469 [ms] (mean, across all concurrent requests)
Transfer rate:          143.31 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.7      0       7
Processing:  1396 3767 1791.4   2787   10749
Waiting:      461 1680 1594.0    715    7680
Total:       1397 3767 1791.4   2788   10749
WARNING: The median and mean for the initial connection 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%   2788
  66%   3801
  75%   5078
  80%   5140
  90%   6176
  95%   7100
  98%   9538
  99%  10749
 100%  10749 (longest request)

compared to the V-server(8€ per month - running the same script with the same data) which I wanted to replace with the Pi (has some cache on, but that's for sure not solely responsible for that huge difference) :

Code: Select all

ab -n 100 -c 5 http://localhost/files
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).....done


Server Software:        lighttpd/1.4.28
Server Hostname:        localhost
Server Port:            80

Document Path:          /files
Document Length:        111527 bytes

Concurrency Level:      5
Time taken for tests:   1.270 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      11165200 bytes
HTML transferred:       11152700 bytes
Requests per second:    78.75 [#/sec] (mean)
Time per request:       63.496 [ms] (mean)
Time per request:       12.699 [ms] (mean, across all concurrent requests)
Transfer rate:          8586.03 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:     8   63 196.6     14     998
Waiting:        1   53 196.7      2     990
Total:          8   63 196.6     14     998

Percentage of the requests served within a certain time (ms)
  50%     14
  66%     18
  75%     22
  80%     25
  90%     52
  95%    810
  98%    987
  99%    998
 100%    998 (longest request)
If someone wants me to make some other test or has any question, just ask.
see you,
Ralf

User avatar
nick.mccloud
Posts: 804
Joined: Sat Feb 04, 2012 4:18 pm

Re: R-Pi as a Webserver - Performance

Thu May 17, 2012 2:56 pm

Can you tell us what the database is, what the query is, cpu & memory of the VPS and can you run the load test from another machine? Please!

Ralfk
Posts: 7
Joined: Tue May 15, 2012 8:23 pm

Re: R-Pi as a Webserver - Performance

Thu May 17, 2012 4:57 pm

Hi,

sure, the VPS:
CPU: Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz (8 cores) (but it is an VPS so I don't have the CPU for myself)
Memory: 1GB
OS: Debian squeeze
Database: mysql 5.1.49 using MySIAM

Pi:
Database: mysql 5.5.24 using MySIAM


SQL-Querry:
SELECT time, name, sum(count) As count2 FROM `downloads` WHERE `time` > somenumber AND aktiv = '1' GROUP by `name` ORDER by `time` DESC

and the test run on my laptop via local LAN: (I had to go back to 900MHz, 950MHz was unstable)

Code: Select all

 ab -n 100 -c 5 http://raspb-pi/files
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 raspb-pi (be patient).....done


Server Software:        lighttpd/1.4.30
Server Hostname:        raspb-pi
Server Port:            80

Document Path:          /files
Document Length:        129408 bytes

Concurrency Level:      5
Time taken for tests:   92.566 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      12955800 bytes
HTML transferred:       12940800 bytes
Requests per second:    1.08 [#/sec] (mean)
Time per request:       4628.318 [ms] (mean)
Time per request:       925.664 [ms] (mean, across all concurrent requests)
Transfer rate:          136.68 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1    1   0.1      1       1
Processing:  2848 4588 2114.2   3209   11347
Waiting:      783 2147 2031.2    874    9351
Total:       2849 4589 2114.2   3210   11347

Percentage of the requests served within a certain time (ms)
  50%   3210
  66%   5152
  75%   6364
  80%   6404
  90%   7969
  95%   9854
  98%  11099
  99%  11347
 100%  11347 (longest request)
(the test for my vps from my machine wouldn't say anything)

see you,
Ralf

User avatar
nick.mccloud
Posts: 804
Joined: Sat Feb 04, 2012 4:18 pm

Re: R-Pi as a Webserver - Performance

Thu May 17, 2012 5:45 pm

Cool - obviously the VPS has considerable more horsepower then the Pi, but all things considered, the Pi is running a fairly chunky database and it's running a not inconsiderable query so averaging out at 0.1 second isn't too shabby!

xtramural
Posts: 108
Joined: Thu Dec 29, 2011 11:16 pm
Location: Scotland

Re: R-Pi as a Webserver - Performance

Thu May 17, 2012 6:26 pm

nick.mccloud wrote:Cool - obviously the VPS has considerable more horsepower then the Pi, but all things considered, the Pi is running a fairly chunky database and it's running a not inconsiderable query so averaging out at 0.1 second isn't too shabby!
Surely, it's an average closer to 1 second per query!

Jancis
Posts: 25
Joined: Thu Jan 26, 2012 3:54 pm

Re: R-Pi as a Webserver - Performance

Thu May 17, 2012 7:53 pm

i expected it to be slower, but not that slow. can we arrange some example db dump and test script to share? I'd like to try that on my machine too.

btw, how did you install php-fcgi?

User avatar
psergiu
Posts: 223
Joined: Mon Nov 07, 2011 8:36 am
Location: TX, U.S.A. (was: RO, E.U.)
Contact: Website

Re: R-Pi as a Webserver - Performance

Fri May 18, 2012 9:39 am

also - what are the my.ini DB cache settings on the VPS server and on the Pi ?

User avatar
nick.mccloud
Posts: 804
Joined: Sat Feb 04, 2012 4:18 pm

Re: R-Pi as a Webserver - Performance

Fri May 18, 2012 11:13 am

xtramural wrote:
nick.mccloud wrote:Cool - obviously the VPS has considerable more horsepower then the Pi, but all things considered, the Pi is running a fairly chunky database and it's running a not inconsiderable query so averaging out at 0.1 second isn't too shabby!
Surely, it's an average closer to 1 second per query!
You are of correct. Did I mention my brain hurts? :oops:

I'll give the Pi a whirl with something less dramatic, I've plenty of web server stuff but I'd move it to SQLite first as I suspect mySQL may be a bit OTT for a Pi.

Jancis
Posts: 25
Joined: Thu Jan 26, 2012 3:54 pm

Re: R-Pi as a Webserver - Performance

Sat May 19, 2012 8:17 pm

i got speed up - i am using external drive for system, only /boot partition is on sd. that's why i'd like to compare same script with yours. i am even able to run drupal on it.

Ralfk
Posts: 7
Joined: Tue May 15, 2012 8:23 pm

Re: R-Pi as a Webserver - Performance

Mon May 21, 2012 12:30 pm

sure we can do that, do you have something in mind already?
I don't think an external drive makes a big difference for a webserver since it should not read/write very much to the disk. I noticed that the performance of the pi scales almost linear with the clock of the cpu!

SQLlite is a good idea, I'll try that when i find the time to do so ;-)

User avatar
SN
Posts: 1014
Joined: Mon Feb 13, 2012 8:06 pm
Location: Romiley, UK
Contact: Website

Re: R-Pi as a Webserver - Performance

Fri May 25, 2012 11:00 am

I have lighttpd installed on my raspi and will stick PHP on too so I can run some geoip stuff I have on my other webspace

A simple apt-get install php5 sorts the install - is there anything else I need to do integrate PHP CGI into lighttpd ?
Steve N – binatone mk4->intellivision->zx81->spectrum->cbm64->cpc6128->520stfm->pc->raspi ?

Return to “Off topic discussion”