LiteSpeed vs. Nginx + Passenger: Ruby Rack Upload Benchmark Configs and Details

Virtual Machine Specs:
Memory: 1.5 GB
CPU: i7-3517U 1.9 GHz
HDD: 100 GB

Software Versions:
LSWS 4.2.2 (with Ruby LSAPI 4.1)
Nginx 1.2.6 (with Passenger 3.0.19)
Ruby 1.9.3p374 (with Rails 3.2.11 and Rack 1.4.3)

Configurations:
nginx.conf (Nginx configuration file)
=========================================================================
worker_processes 1;

events {
worker_connections 1024;
}

http {
passenger_root /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.19;
passenger_ruby /usr/local/bin/ruby;

include mime.types;
default_type application/octet-stream;

sendfile on;
keepalive_timeout 65;

server {
listen 8000;
server_name somename alias another.alias;
root /home/user/lsws/rack_hello/public;
passenger_enabled on;
}
}

httpd_config.xml (LSWS configuration file)
=========================================================================
<?xml version=”1.0″ encoding=”UTF-8″?>
<httpServerConfig>
<serverName>$HOSTNAME</serverName>
<user>user</user>
<group>users</group>
<priority>0</priority>
<chrootPath>/</chrootPath>
<enableChroot>0</enableChroot>
<enableLVE>0</enableLVE>
<inMemBufSize>120M</inMemBufSize>
<swappingDir>/tmp/lshttpd/swap</swappingDir>
<autoRestart>1</autoRestart>
<autoFix503>1</autoFix503>
<gracefulRestartTimeout></gracefulRestartTimeout>
<loadApacheConf>0</loadApacheConf>
<mime>$SERVER_ROOT/conf/mime.properties</mime>
<showVersionNumber>0</showVersionNumber>
<autoUpdateInterval>86400</autoUpdateInterval>
<autoUpdateDownloadPkg>1</autoUpdateDownloadPkg>
<adminEmails>root@localhost</adminEmails>
<adminRoot>$SERVER_ROOT/admin/</adminRoot>
<logging>
<log>
<fileName>$SERVER_ROOT/logs/error.log</fileName>
<logLevel>DEBUG</logLevel>
<debugLevel>10</debugLevel>
<rollingSize>10M</rollingSize>
<enableStderrLog>1</enableStderrLog>
</log>
<accessLog>
<fileName>$SERVER_ROOT/logs/access.log</fileName>
<rollingSize>10M</rollingSize>
<keepDays>30</keepDays>
<compressArchive>0</compressArchive>
</accessLog>
</logging>
<indexFiles>index.html, index.php</indexFiles>
<htAccess>
<allowOverride>0</allowOverride>
<accessFileName>.htaccess</accessFileName>
</htAccess>
<expires>
<enableExpires>1</enableExpires>
<expiresByType>image/*=A604800, text/css=A604800, application/x-javascript=A604800, application/javascript=A604800</expiresByType>
</expires>
<tuning>
<maxConnections>2000</maxConnections>
<maxSSLConnections>200</maxSSLConnections>
<connTimeout>300</connTimeout>
<maxKeepAliveReq>1000</maxKeepAliveReq>
<smartKeepAlive>0</smartKeepAlive>
<keepAliveTimeout>5</keepAliveTimeout>
<sndBufSize>0</sndBufSize>
<rcvBufSize>0</rcvBufSize>
<eventDispatcher>best</eventDispatcher>
<maxCachedFileSize>4096</maxCachedFileSize>
<totalInMemCacheSize>20M</totalInMemCacheSize>
<maxMMapFileSize>256K</maxMMapFileSize>
<totalMMapCacheSize>40M</totalMMapCacheSize>
<useSendfile>1</useSendfile>
<useAIO>1</useAIO>
<AIOBlockSize>4</AIOBlockSize>
<SSLCryptoDevice>null</SSLCryptoDevice>
<maxReqURLLen>8192</maxReqURLLen>
<maxReqHeaderSize>16380</maxReqHeaderSize>
<maxReqBodySize>500M</maxReqBodySize>
<maxDynRespHeaderSize>8K</maxDynRespHeaderSize>
<maxDynRespSize>500M</maxDynRespSize>
<enableGzipCompress>1</enableGzipCompress>
<enableDynGzipCompress>1</enableDynGzipCompress>
<gzipCompressLevel>1</gzipCompressLevel>
<compressibleTypes>text/*,application/x-javascript,application/javascript,application/xml</compressibleTypes>
<gzipAutoUpdateStatic>1</gzipAutoUpdateStatic>
<gzipStaticCompressLevel>6</gzipStaticCompressLevel>
<gzipMaxFileSize>1M</gzipMaxFileSize>
<gzipMinFileSize>300</gzipMinFileSize>
</tuning>
<security>
<fileAccessControl>
<followSymbolLink>1</followSymbolLink>
<checkSymbolLink>0</checkSymbolLink>
<requiredPermissionMask>000</requiredPermissionMask>
<restrictedPermissionMask>000</restrictedPermissionMask>
</fileAccessControl>
<perClientConnLimit>
<staticReqPerSec>0</staticReqPerSec>
<dynReqPerSec>0</dynReqPerSec>
<outBandwidth>0</outBandwidth>
<inBandwidth>0</inBandwidth>
<softLimit>10000</softLimit>
<hardLimit>10000</hardLimit>
<gracePeriod>15</gracePeriod>
<banPeriod>300</banPeriod>
</perClientConnLimit>
<CGIRLimit>
<maxCGIInstances>20</maxCGIInstances>
<minUID>11</minUID>
<minGID>10</minGID>
<priority>0</priority>
<CPUSoftLimit>300</CPUSoftLimit>
<CPUHardLimit>600</CPUHardLimit>
<memSoftLimit>450M</memSoftLimit>
<memHardLimit>500M</memHardLimit>
<procSoftLimit>400</procSoftLimit>
<procHardLimit>450</procHardLimit>
</CGIRLimit>
<censorshipControl>
<enableCensorship>0</enableCensorship>
<logLevel>0</logLevel>
<defaultAction>deny,log,status:403</defaultAction>
<scanPOST>1</scanPOST>
</censorshipControl>
<accessDenyDir>
<dir>/</dir>
<dir>/etc/*</dir>
<dir>/dev/*</dir>
<dir>$SERVER_ROOT/conf/*</dir>
<dir>$SERVER_ROOT/admin/conf/*</dir>
</accessDenyDir>
<accessControl>
<allow>ALL</allow>
<deny></deny>
</accessControl>
</security>
<railsDefaults>
<rubyBin>/usr/local/bin/ruby</rubyBin>
<railsEnv>1</railsEnv>
<maxConns>5</maxConns>
<env>LSAPI_MAX_REQS=1000</env>
<env>LSAPI_MAX_IDLE=60</env>
<initTimeout>180</initTimeout>
<retryTimeout>0</retryTimeout>
<pcKeepAliveTimeout>60</pcKeepAliveTimeout>
<respBuffer>0</respBuffer>
<backlog>50</backlog>
<runOnStartUp>0</runOnStartUp>
<extMaxIdleTime></extMaxIdleTime>
<priority>3</priority>
<memSoftLimit>550M</memSoftLimit>
<memHardLimit>600M</memHardLimit>
<procSoftLimit>500</procSoftLimit>
<procHardLimit>600</procHardLimit>
</railsDefaults>
<virtualHostList>
<virtualHost>
<name>testRack</name>
<vhRoot>$SERVER_ROOT/rack_hello</vhRoot>
<configFile>$SERVER_ROOT/conf/testRack.conf</configFile>
<note></note>
<allowSymbolLink>0</allowSymbolLink>
<enableScript>1</enableScript>
<restrained>0</restrained>
<maxKeepAliveReq></maxKeepAliveReq>
<smartKeepAlive></smartKeepAlive>
<setUIDMode>0</setUIDMode>
<staticReqPerSec></staticReqPerSec>
<dynReqPerSec></dynReqPerSec>
<outBandwidth></outBandwidth>
<inBandwidth></inBandwidth>
</virtualHost>
</virtualHostList>
<listenerList>
<listener>
<name>Default</name>
<address>*:8088</address>
<secure>0</secure>
<vhostMapList>
<vhostMap>
<vhost>testRack</vhost>
<domain>*</domain>
</vhostMap>
</vhostMapList>
</listener>
</listenerList>
</httpServerConfig>

testRack.config (Vhost configuration)
=========================================================================
<?xml version=”1.0″ encoding=”UTF-8″?>
<virtualHostConfig>
<docRoot>$VH_ROOT</docRoot>
<adminEmails></adminEmails>
<enableGzip></enableGzip>
<contextList>
<context>
<type>rails</type>
<uri>/</uri>
<location>$VH_ROOT/</location>
<note></note>
<railsEnv>1</railsEnv>
<maxConns></maxConns>
<enableExpires></enableExpires>
<expiresDefault></expiresDefault>
<expiresByType></expiresByType>
<extraHeaders></extraHeaders>
<indexFiles></indexFiles>
<autoIndex></autoIndex>
<allowOverride></allowOverride>
<realm></realm>
<authName></authName>
<required></required>
<accessControl>
<allow></allow>
<deny></deny>
</accessControl>
<authorizer></authorizer>
<addDefaultCharset>off</addDefaultCharset>
<defaultCharsetCustomized></defaultCharsetCustomized>
<rewrite>
<enable></enable>
<inherit></inherit>
<base></base>
<rules></rules>
</rewrite>
</context>
</contextList>
</virtualHostConfig>

config.ru
=========================================================================
def readInput(env)
s = env[“rack.input”].read.to_s
ss = ‘Read ‘ + s.length.to_s + ‘ bytes.\n’
ss
end

app = proc { |env|
[
200,
{‘Content-Type’ => ‘text/plain’},
[readInput(env) ]
]
}

run app

.Case 2KB
nginx + Passenger:
user@linux-x2pw:~>/usr/sbin/ab2 -n 10000 -p /home/user/test/test2k.bin http://127.0.0.1:8000/
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 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests

Server Software: nginx/1.2.6
Server Hostname: 127.0.0.1
Server Port: 8000

Document Path: /
Document Length: 18 bytes

Concurrency Level: 1
Time taken for tests: 8.120 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 2040000 bytes
Total POSTed: 23510000
HTML transferred: 180000 bytes
Requests per second: 1231.57 [#/sec] (mean)
Time per request: 0.812 [ms] (mean)
Time per request: 0.812 [ms] (mean, across all concurrent requests)
Transfer rate: 245.35 [Kbytes/sec] received
2827.55 kb/s sent
3072.90 kb/s total

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 0 1 0.5 1 17
Waiting: 0 1 0.5 1 17
Total: 1 1 0.5 1 17

Percentage of the requests served within a certain time (ms)
50% 1
66% 1
75% 1
80% 1
90% 1
95% 1
98% 2
99% 3
100% 17 (longest request)
LiteSpeed:
user@linux-x2pw:~>/usr/sbin/ab2 -n 10000 -p /home/user/test/test2k.bin http://127.0.0.1:8088/
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 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: LiteSpeed
Server Hostname: 127.0.0.1
Server Port: 8088

Document Path: /
Document Length: 18 bytes

Concurrency Level: 1
Time taken for tests: 2.784 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 1580000 bytes
Total POSTed: 23510000
HTML transferred: 180000 bytes
Requests per second: 3591.94 [#/sec] (mean)
Time per request: 0.278 [ms] (mean)
Time per request: 0.278 [ms] (mean, across all concurrent requests)
Transfer rate: 554.22 [Kbytes/sec] received
8246.73 kb/s sent
8800.95 kb/s total

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 0 0 0.2 0 4
Waiting: 0 0 0.2 0 4
Total: 0 0 0.2 0 4

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

.Case 20KB
nginx + Passenger:
user@linux-x2pw:~>/usr/sbin/ab2 -n 10000 -p /home/user/test/test20k.bin http://127.0.0.1:8000/
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 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: nginx/1.2.6
Server Hostname: 127.0.0.1
Server Port: 8000

Document Path: /
Document Length: 19 bytes

Concurrency Level: 1
Time taken for tests: 9.922 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 2050000 bytes
Total POSTed: 223320000
HTML transferred: 190000 bytes
Requests per second: 1007.88 [#/sec] (mean)
Time per request: 0.992 [ms] (mean)
Time per request: 0.992 [ms] (mean, across all concurrent requests)
Transfer rate: 201.77 [Kbytes/sec] received
21980.54 kb/s sent
22182.31 kb/s total

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 1 1 0.5 1 23
Waiting: 0 1 0.5 1 23
Total: 1 1 0.5 1 23

Percentage of the requests served within a certain time (ms)
50% 1
66% 1
75% 1
80% 1
90% 1
95% 2
98% 3
99% 3
100% 23 (longest request)
LiteSpeed:
user@linux-x2pw:~>/usr/sbin/ab2 -n 10000 -p /home/user/test/test20k.bin http://127.0.0.1:8088/
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 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: LiteSpeed
Server Hostname: 127.0.0.1
Server Port: 8088

Document Path: /
Document Length: 19 bytes

Concurrency Level: 1
Time taken for tests: 3.098 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 1590000 bytes
Total POSTed: 223320000
HTML transferred: 190000 bytes
Requests per second: 3227.83 [#/sec] (mean)
Time per request: 0.310 [ms] (mean)
Time per request: 0.310 [ms] (mean, across all concurrent requests)
Transfer rate: 501.20 [Kbytes/sec] received
70394.36 kb/s sent
70895.55 kb/s total

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 0 0 0.2 0 4
Waiting: 0 0 0.2 0 4
Total: 0 0 0.2 0 4

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

.Case 200KB
nginx + Passenger:
user@linux-x2pw:~>/usr/sbin/ab2 -n 10000 -p /home/user/test/test200k.bin http://127.0.0.1:8000/
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 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: nginx/1.2.6
Server Hostname: 127.0.0.1
Server Port: 8000

Document Path: /
Document Length: 20 bytes

Concurrency Level: 1
Time taken for tests: 22.196 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 2060000 bytes
Total POSTed: 2069810000
HTML transferred: 200000 bytes
Requests per second: 450.53 [#/sec] (mean)
Time per request: 2.220 [ms] (mean)
Time per request: 2.220 [ms] (mean, across all concurrent requests)
Transfer rate: 90.63 [Kbytes/sec] received
91065.57 kb/s sent
91156.20 kb/s total

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 2
Processing: 2 2 1.2 2 65
Waiting: 0 2 1.2 2 64
Total: 2 2 1.2 2 65

Percentage of the requests served within a certain time (ms)
50% 2
66% 2
75% 2
80% 2
90% 3
95% 4
98% 4
99% 4
100% 65 (longest request)
LiteSpeed:
user@linux-x2pw:~>/usr/sbin/ab2 -n 10000 -p /home/user/test/test200k.bin http://127.0.0.1:8088/
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 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: LiteSpeed
Server Hostname: 127.0.0.1
Server Port: 8088

Document Path: /
Document Length: 20 bytes

Concurrency Level: 1
Time taken for tests: 7.705 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 1600000 bytes
Total POSTed: 2069810000
HTML transferred: 200000 bytes
Requests per second: 1297.89 [#/sec] (mean)
Time per request: 0.770 [ms] (mean)
Time per request: 0.770 [ms] (mean, across all concurrent requests)
Transfer rate: 202.80 [Kbytes/sec] received
262342.94 kb/s sent
262545.73 kb/s total

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 0 1 0.4 1 13
Waiting: 0 1 0.4 1 13
Total: 0 1 0.4 1 13

Percentage of the requests served within a certain time (ms)
50% 1
66% 1
75% 1
80% 1
90% 1
95% 2
98% 2
99% 3
100% 13 (longest request)

.Case 1MB
nginx + Passenger:
user@linux-x2pw:~>/usr/sbin/ab2 -n 1000 -p /home/user/test/test1m.bin http://127.0.0.1:8000/
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 127.0.0.1 (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: nginx/1.2.6
Server Hostname: 127.0.0.1
Server Port: 8000

Document Path: /
Document Length: 21 bytes

Concurrency Level: 1
Time taken for tests: 7.299 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 207000 bytes
Total POSTed: 1048678000
HTML transferred: 21000 bytes
Requests per second: 137.00 [#/sec] (mean)
Time per request: 7.299 [ms] (mean)
Time per request: 7.299 [ms] (mean, across all concurrent requests)
Transfer rate: 27.69 [Kbytes/sec] received
140298.51 kb/s sent
140326.21 kb/s total

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 6 7 2.8 7 87
Waiting: 4 6 2.7 6 86
Total: 6 7 2.8 7 87

Percentage of the requests served within a certain time (ms)
50% 7
66% 7
75% 7
80% 8
90% 8
95% 9
98% 11
99% 12
100% 87 (longest request)
LiteSpeed:
user@linux-x2pw:~>/usr/sbin/ab2 -n 1000 -p /home/user/test/test1m.bin http://127.0.0.1:8088/
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 127.0.0.1 (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: LiteSpeed
Server Hostname: 127.0.0.1
Server Port: 8088

Document Path: /
Document Length: 21 bytes

Concurrency Level: 1
Time taken for tests: 3.380 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 161000 bytes
Total POSTed: 1048678000
HTML transferred: 21000 bytes
Requests per second: 295.89 [#/sec] (mean)
Time per request: 3.380 [ms] (mean)
Time per request: 3.380 [ms] (mean, across all concurrent requests)
Transfer rate: 46.52 [Kbytes/sec] received
303022.12 kb/s sent
303068.64 kb/s total

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 2 3 1.4 3 22
Waiting: 0 2 1.0 2 15
Total: 2 3 1.4 3 22

Percentage of the requests served within a certain time (ms)
50% 3
66% 3
75% 4
80% 4
90% 4
95% 5
98% 8
99% 10
100% 22 (longest request)