[Twisted-web] HTTPS server performance

Mircea Amarascu mircea.amarascu at gmail.com
Thu May 25 00:20:30 CDT 2006

I need a basic HTTPS server, without any web applications support,
so I've decided to use the listenTCP and listenSSL methods, together
with a twisted.web.http.HTTPFactory, a twisted.web.http.HTTPChannel protocol
and a twisted.web.http.Request handler.

I added a ServerContextFactory for SSL (like in echoserv_ssl.py example):

class ServerContextFactory:

    def getContext(self):
        """Create an SSL context.

        Similar to twisted's echoserv_ssl example, except the private key
        and certificate are in separate files."""
        print "Creating SSL context..."
        ctx = SSL.Context(SSL.SSLv23_METHOD)
        return ctx

if __name__ == "__main__":
    from twisted.internet import reactor
    reactor.listenTCP(8000, MyHttpFactory())
    reactor.listenSSL(8043, MyHttpFactory(), ServerContextFactory())

I'm testing this configuration with ApacheBench (ab), and I get some 800
requests/sec for HTTP, and only about 30 requests/sec for HTTPS. I now that
the ratio for HTTPS is about 60% of HTTP, so I was wondering if I'm
doing something wrong, or what is causing this problem.

Thank you.

More information about the Twisted-web mailing list