Created
November 18, 2012 16:09
-
-
Save hermansc/4106022 to your computer and use it in GitHub Desktop.
Gunicorn config & ab-test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### /etc/gunicorn.d/ukeweb.gunicorn | |
CONFIG = { | |
'mode': 'wsgi', | |
'environment': { | |
'PYTHONPATH': '/var/www/uka.no/staging/ukeweb/', | |
}, | |
'user': 'uka-web', | |
'group': 'uka-web', | |
'args': ( | |
'--bind=0.0.0.0:5060', | |
'--workers=10', | |
'htdocs.gunicorn:application' | |
), | |
} | |
------------------------------------------------------------------------------ | |
### /var/www/uka.no/staging/ukeweb/htdocs/gunicorn.py | |
import os | |
activation_file = "/var/www/uka.no/www/ukeweb-prod/virtualenv/bin/activate_this.py" | |
execfile(activation_file, dict(__file__=activation_file)) | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ukeweb.settings") | |
from django.core.handlers.wsgi import WSGIHandler | |
application = WSGIHandler() | |
------------------------------------------------------------------------------ | |
### /etc/apache2/site-available/staging.uka.no | |
<VirtualHost staging.uka.no:443> | |
# Server config and logs | |
ServerAdmin [email protected] | |
ServerName staging.uka.no | |
CustomLog /var/log/apache2/access-staging.uka.no.log combined | |
ErrorLog /var/log/apache2/error-staging.uka.no.log | |
DocumentRoot /var/www/uka.no/staging/ukeweb/htdocs | |
# SSL settings | |
SSLEngine On | |
SSLCertificateFile /etc/apache2/ssl/www.uka.no.crt | |
SSLCertificateKeyFile /etc/apache2/ssl/www.uka.no.key | |
SSLCertificateChainFile /etc/apache2/ssl/gd_intermediate.crt | |
# Redirects | |
RewriteEngine On | |
RewriteRule ^(/stats/) /var/www/uka.no/stats/ | |
RewriteRule ^/questionnaire/(.*) https://staging.uka.no/skjema/$1 [R,L] | |
RewriteRule ^/program/gruppesalg(.*) https://staging.uka.no/gruppesalg$1 [R,L] | |
RewriteRule ^/adminmedia/(.*) /var/lib/python-support/python2.5/django/contrib/admin/media/$1 [QSA,L] | |
RewriteRule ^/(media.*) /var/www/uka.no/staging/ukeweb/$1 [QSA,L] | |
# Proxy (other) traffic to gunicorn | |
SetEnv force-proxy-request-1.0 1 | |
ProxyPreserveHost On | |
RewriteRule ^(.*) http://localhost:5060$1 [P] | |
# If url is not favicon.ico, robots.txt or sitemap.xml, use fcgi.script to handle request | |
#RewriteCond %{SCRIPT_FILENAME} !/(favicon.ico|robots.txt|sitemap.xml)$ | |
#RewriteRule ^(.*)$ /staging-ukeweb.fcgi/$1 [QSA,L] | |
# Use itkacl /web/uka/alle for access to innsida and related sites | |
<LocationMatch "^/(login|innsida|media/innsida|admin)"> | |
AuthType Kerberos | |
KrbAuthRealms SAMFUNDET.NO | |
Krb5Keytab /etc/apache2/krb5/www.uka.no.keytab | |
KrbMethodK5Passwd on | |
AuthName "UKA-13 - Cash is king" | |
Require itkacl /web/uka/alle | |
</LocationMatch> | |
# Allow all requests to ical download, due to restrictions from google calendar. | |
<Location /innsida/vaktsys/ical> | |
Allow from all | |
Satisfy any | |
</Location> | |
# Static file settings | |
<Location /> | |
AddOutputFilterByType DEFLATE text/html application/javascript | |
</Location> | |
<Location /media> | |
Options -Indexes | |
ExpiresActive On | |
ExpiresDefault "now plus 2 days" | |
FileETag none | |
AddOutputFilterByType DEFLATE text/css application/x-javascript | |
</Location> | |
<Location /media/files/Info/presse> | |
Options +Indexes | |
</Location> | |
<LocationMatch "^/media/(cache|upload/files)"> | |
Options -Indexes | |
ExpiresActive On | |
ExpiresDefault "now plus 5 years" | |
FileETag none | |
</LocationMatch> | |
<Location /stats> | |
Options -Indexes | |
</Location> | |
</VirtualHost> | |
<VirtualHost staging.uka.no:80> | |
ServerAdmin [email protected] | |
ServerName staging.uka.no | |
CustomLog /var/log/apache2/access-staging.uka.no.log combined | |
ErrorLog /var/log/apache2/error-staging.uka.no.log | |
DocumentRoot /var/www/uka.no/staging/ukeweb/htdocs | |
<Location /innsida/vaktsys/ical> | |
Allow from all | |
Satisfy any | |
</Location> | |
RewriteEngine On | |
# Pass på en noen sider alltid blir kjørt over https | |
# Sjekk om vi faktisk er på SSL eller om vi er bak en ssl terminert | |
# varnish | |
RewriteCond %{HTTPS} !=on | |
RewriteRule ^/(admin|applications|innsida|media/innsida|gruppesalg|questionnaire|skjema|program/billetter)(.*) https://%{SERVER_NAME}/$1$2 [R,L] | |
RewriteRule ^/adminmedia/(.*) /var/lib/python-support/python2.5/django/contrib/admin/media/$1 [QSA,L] | |
RewriteRule ^/(media.*) /var/www/uka.no/staging/ukeweb/$1 [QSA,L] | |
# Proxy (other) traffic to gunicorn | |
SetEnv force-proxy-request-1.0 1 | |
ProxyPreserveHost On | |
RewriteRule ^(.*) http://localhost:5060$1 [P] | |
#RewriteCond %{SCRIPT_FILENAME} !/(favicon.ico|robots.txt|sitemap.xml)$ | |
#RewriteRule ^(.*)$ /staging-ukeweb.fcgi/$1 [QSA,L] | |
<Location /> | |
AddOutputFilterByType DEFLATE text/html application/javascript | |
</Location> | |
<Location /media> | |
Options -Indexes | |
ExpiresActive On | |
ExpiresDefault "now plus 2 days" | |
FileETag none | |
AddOutputFilterByType DEFLATE text/css application/x-javascript | |
</Location> | |
<LocationMatch "^/media/(cache|upload/files)"> | |
Options -Indexes | |
ExpiresActive On | |
ExpiresDefault "now plus 5 years" | |
FileETag none | |
</LocationMatch> | |
</VirtualHost> | |
------------------------------------------------------------------------------ | |
### ab -n 100 -c 10 https://staging.uka.no | |
Server Software: gunicorn/0.14.5 | |
Server Hostname: staging.uka.no | |
Server Port: 443 | |
SSL/TLS Protocol: TLSv1/SSLv3,DHE-RSA-AES256-SHA,2048,256 | |
Document Path: / | |
Document Length: 4349 bytes | |
Concurrency Level: 10 | |
Time taken for tests: 1.068 seconds | |
Complete requests: 100 | |
Failed requests: 0 | |
Write errors: 0 | |
Total transferred: 451200 bytes | |
HTML transferred: 434900 bytes | |
Requests per second: 93.60 [#/sec] (mean) | |
Time per request: 106.843 [ms] (mean) | |
Time per request: 10.684 [ms] (mean, across all concurrent requests) | |
Transfer rate: 412.40 [Kbytes/sec] received | |
Connection Times (ms) | |
min mean[+/-sd] median max | |
Connect: 19 47 12.7 46 86 | |
Processing: 34 54 15.3 51 91 | |
Waiting: 32 48 11.7 45 88 | |
Total: 67 101 20.0 96 163 | |
Percentage of the requests served within a certain time (ms) | |
50% 96 | |
66% 108 | |
75% 116 | |
80% 117 | |
90% 129 | |
95% 146 | |
98% 157 | |
99% 163 | |
100% 163 (longest request) | |
------------------------------------------------------------------------------ | |
### ab -n 100 -c 10 https://www.uka.no | |
Server Software: Apache/2.2.16 | |
Server Hostname: www.uka.no | |
Server Port: 443 | |
SSL/TLS Protocol: TLSv1/SSLv3,DHE-RSA-AES256-SHA,2048,256 | |
Document Path: / | |
Document Length: 4303 bytes | |
Concurrency Level: 10 | |
Time taken for tests: 0.943 seconds | |
Complete requests: 100 | |
Failed requests: 0 | |
Write errors: 0 | |
Total transferred: 467900 bytes | |
HTML transferred: 430300 bytes | |
Requests per second: 106.07 [#/sec] (mean) | |
Time per request: 94.274 [ms] (mean) | |
Time per request: 9.427 [ms] (mean, across all concurrent requests) | |
Transfer rate: 484.69 [Kbytes/sec] received | |
Connection Times (ms) | |
min mean[+/-sd] median max | |
Connect: 24 54 13.8 55 87 | |
Processing: 15 37 16.3 30 75 | |
Waiting: 4 27 10.0 25 56 | |
Total: 56 90 19.0 86 158 | |
Percentage of the requests served within a certain time (ms) | |
50% 86 | |
66% 93 | |
75% 98 | |
80% 104 | |
90% 118 | |
95% 128 | |
98% 152 | |
99% 158 | |
100% 158 (longest request) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment