Issue #571 open

Make CP static file performance comparable to Apache

Robert Brewer
created an issue

I can dream, can't I?

Comments (7)

  1. Robert Brewer reporter

    Here's a benchmark run against Apache 2.0.47 (1000 requests, 14 byte static file (sitting in !DocumentRoot), !ThreadsPerChild 250, !MaxRequestsPerChild 0):

    threads | Completed | Failed |  req/sec | msec/req |  KB/sec |
         10 |      1000 |      0 |  1296.84 |    0.771 |  430.55 |
         20 |      1000 |      0 |  1232.79 |    0.811 |  410.52 |
         30 |      1000 |      0 |  1174.78 |    0.851 |  395.90 |
         40 |      1000 |      0 |  1203.09 |    0.831 |  403.03 |
         50 |      1000 |      0 |  1134.73 |    0.881 |  383.54 |
    Average |    1000.0 |    0.0 | 1208.446 |    0.829 | 404.708 |
    

    Here's a run of the full CP stack (1000 requests, 14 bytes via staticdir, 10 server threads):

    threads | Completed | Failed | req/sec | msec/req | KB/sec |
         10 |      1000 |      0 |  308.20 |    3.245 |  62.87 |
         20 |      1000 |      0 |  301.68 |    3.315 |  61.54 |
         30 |      1000 |      0 |  302.59 |    3.305 |  61.73 |
         40 |      1000 |      0 |  295.43 |    3.385 |  60.27 |
         50 |      1000 |      0 |  298.97 |    3.345 |  60.99 |
    Average |    1000.0 |    0.0 | 301.374 |    3.319 |  61.48 |
    

    And here's a run with the CP3 WSGI server, using a bare-bones static-file WSGI app (see below):

    threads | Completed | Failed | req/sec | msec/req | KB/sec |
         10 |      3000 |      0 | 1222.73 |    0.818 | 195.64 |
         20 |      3000 |      0 | 1198.27 |    0.835 | 191.72 |
         30 |      3000 |      0 | 1198.27 |    0.835 | 191.72 |
         40 |      3000 |      0 | 1184.07 |    0.845 | 189.45 |
         50 |      3000 |      0 | 1152.19 |    0.868 | 184.35 |
    
        def simple_app(environ, start_response):
            """Simplest possible application object"""
            f = open(r'D:\htdocs\summary.txt')
            body = f.read()
            f.close()
            status = '200 OK'
            response_headers = [('Content-type','text/plain'),
                                ('Content-Length', str(len(body)))]
            start_response(status, response_headers)
            return [body]
    

    So we can come close. Using sendfile/TransmitFile might help.

  2. moe

    Being a threaded server (and written in python!) CP will never play in the same ballpark as lighty or nginx for static file serving. IMHO micro-optimizations in this area would only be a waste of our precious, scarce developer ressources :)

    Let's focus on CP's core competencies and improve those. Nobody in their right mind will use CP for static file serving in a production setup anyways.

  3. Anonymous

    personally, I find Moe's argument to be circular:

    • don't bother to optimize the static file performance because it's not important.
    • It's not important because no-one will use it in production anyways.
    • No-one will use it in production because it's not not close enough to lighty in performance.

    I'll keep dreaming with you

  4. Log in to comment