ipython/nbviewer — pull request #43 by Carreau (2013-03-05 19:47:00+00:00)
Title: Nbviewer2 speed (10 fold increase) 

On top of #41 and #42.

The **custom cache had an issue**, meaning that it **was not used** most of the time.
So I change for **Flask-Cache**.
This plus using **tornado as a WSGI**, and some reorganisation, made the *database* to store url acces time the bottleneck, which I did *deactivate*.

All in all, in the good day, one dyno should now be able to respond to **~30 req/sec max**. (before it was more around 4). Minimum is still around 1.5 r/s if it has to fetch the ipynb, and grind it through nbconvert.

It is not perfect and would need some work for some modifications I plan to add, but should be a good improvement.

Apache Bench attached.

```
ab -c50 -n150 http://gistpynb.herokuapp.com/urls/raw.github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/master/Chapter1_Introduction/Chapter1_Introduction.ipynb
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 gistpynb.herokuapp.com (be patient).....done

Server Software: TornadoServer/2.4
Server Hostname: gistpynb.herokuapp.com
Server Port: 80

Document Path: /urls/raw.github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/master/Chapter1_Introduction/Chapter1_Introduction.ipynb
Document Length: 299271 bytes

Concurrency Level: 50
Time taken for tests: 5.402 seconds
Complete requests: 150
Failed requests: 0
Write errors: 0
Total transferred: 44910000 bytes
HTML transferred: 44890650 bytes
Requests per second: 27.77 [#/sec] (mean)
Time per request: 1800.818 [ms] (mean)
Time per request: 36.016 [ms] (mean, across all concurrent requests)
Transfer rate: 8118.06 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 82 238 360.3 85 1085
Processing: 738 1324 492.6 1205 4104
Waiting: 103 330 192.4 281 767
Total: 821 1562 740.8 1288 4219

Percentage of the requests served within a certain time (ms)
50% 1288
66% 1498
75% 1761
80% 1942
90% 2694
95% 3181
98% 3879
99% 4189
100% 4219 (longest request)
```