geopython/pycsw — pull request #211 by ahinz (2014-01-05 01:41:41+00:00)
Title: Share a singleton engine to share between requests

Each WSGI worker thread can get engines via:
`Repository.create_engine(db_url)`

Using apache benchmark and the sample data from
https://github.com/GeoNode/gisdata/tree/master/gisdata/metadata I saw a
reduced execution time of 18%.

Here's the raw data:

```
$ ab -n 120 -c 15 -H "Accept-Encoding: gzip,deflate" "http://127.0.0.1:8080/?service=CSW&version=2.0.2&&mode=opensearch&servi
ce=CSW&version=2.0.2&request=GetRecords&typenames=csw:Record&resulttype=results&elementsetname=brief"
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).....done

Server Software: gunicorn/18.0
Server Hostname: 127.0.0.1
Server Port: 8080

Document Path: /?service=CSW&version=2.0.2&&mode=opensearch&service=CSW&version=2.0.2&request=GetRecords&typenames=csw:Record&resulttype=resu
lts&elementsetname=brief
Document Length: 15387 bytes

Concurrency Level: 15
Time taken for tests: 10.038 seconds
Complete requests: 120
Failed requests: 0
Write errors: 0
Total transferred: 1866480 bytes
HTML transferred: 1846440 bytes
Requests per second: 11.95 [#/sec] (mean)
Time per request: 1254.740 [ms] (mean)
Time per request: 83.649 [ms] (mean, across all concurrent requests)
Transfer rate: 181.58 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 1
Processing: 89 1182 234.9 1254 1298
Waiting: 88 1182 234.9 1254 1298
Total: 90 1183 234.8 1254 1298

Percentage of the requests served within a certain time (ms)
50% 1254
66% 1256
75% 1260
80% 1262
90% 1265
95% 1270
98% 1273
99% 1298
100% 1298 (longest request)

######

$ ab -n 120 -c 15 -H "Accept-Encoding: gzip,deflate" "http://127.0.0.1:8080/?service=CSW&version=2.0.2&&mode=opensearch&servi
ce=CSW&version=2.0.2&request=GetRecords&typenames=csw:Record&resulttype=results&elementsetname=brief"
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).....done

Server Software: gunicorn/18.0
Server Hostname: 127.0.0.1
Server Port: 8080

Document Path: /?service=CSW&version=2.0.2&&mode=opensearch&service=CSW&version=2.0.2&request=GetRecords&typenames=csw:Record&resulttype=resu
lts&elementsetname=brief
Document Length: 15387 bytes

Concurrency Level: 15
Time taken for tests: 8.176 seconds
Complete requests: 120
Failed requests: 0
Write errors: 0
Total transferred: 1866480 bytes
HTML transferred: 1846440 bytes
Requests per second: 14.68 [#/sec] (mean)
Time per request: 1021.957 [ms] (mean)
Time per request: 68.130 [ms] (mean, across all concurrent requests)
Transfer rate: 222.95 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 0
Processing: 212 952 151.0 983 1121
Waiting: 212 951 151.0 983 1121
Total: 213 952 150.9 983 1122

Percentage of the requests served within a certain time (ms)
50% 983
66% 988
75% 994
80% 999
90% 1048
95% 1060
98% 1090
99% 1113
100% 1122 (longest request)
```