Performance evaluation of HTTPS library

Ashish amvyas82 at gmail.com
Wed Oct 13 14:27:29 CEST 2010


On Oct 13, 3:19 pm, Antoine Pitrou <solip... at pitrou.net> wrote:
> On Wed, 13 Oct 2010 02:12:21 -0700 (PDT)
>
> Ashish <amvya... at gmail.com> wrote:
>
> > > > Is the client machine at 100% CPU when you do that?
>
> > > With HTTP, I see client CPU at appx. 97%. However with HTTPS, it stays
> > > at 53-55%.
>
> And is the server at 100% CPU then?
> If the client is not at 100% CPU, it shouldn't be the bottleneck,
> unless you have something wrong in the client implementation.
>
> > >             sock = socket.create_connection((self.host, self.port),
> > > self.timeout)
> > >             sock2 = ssl.wrap_socket(sock, self.key_file,
> > > self.cert_file)
> > >             self.sock = CBSocket(sock2)
>
> What is CBSocket? What happens if you just write:
>     self.sock = sock2
>

Server's java process is taking 15% cpu.

Well, CBSocket is socket implementation that calls my callback on
data.
Both my classes AsyncHTTPSConnection and AsyncHTTPConnection use it
and use it the same way ( self.sock = CBSocket(sock2) ).
The implemetation of AsyncHTTPConnection differs from
AsyncHTTPSConnection only in connect method: sock2 =
ssl.wrap_socket(sock, self.key_file, self.cert_file)

class CBSocket(asynchat.async_chat):
    """ This is a class that calls the callback when it has data and
it read it."""
    def __init__(self, socket):
        asynchat.async_chat.__init__(self, socket)

        self._in_buffer = io.BytesIO()
        self._closed = False
        self._cb = None

    def handle_read(self):
        try:
            read = self.socket.recv(65536)
        except:
            read = 0
            raise
        if not read and not self._closed:
            self.handle_close()
            self.close()
            self._closed = True
            return

        self._in_buffer.write(read)

    def sendall(self, data):
        self.send(data)

    def makefile(self, mode, buffsize= 8192):
        self._in_buffer.seek(0)
        return self._in_buffer

    def set_cb(self, cb):
        self._cb = cb
        if self._closed:
           self._cb()
        else:
           pass


    def handle_close(self):
        if self._cb:
            self._cb()
            self._closed = True
            self.close()
        del self._in_buffer

> > > > Also, there's a feature request to reduce overhead of SSL
> > > > connections, but it needs implementing:http://bugs.python.org/issue8106
>
> > > Well good to know this. Do we have any date when this will be
> > > available? I feel like contributing to this but kind of over occupied
> > > with several activities right now.
>
> Probably not in Python 3.2 anyway. But given your client isn't at 100%
> CPU when you launch your HTTPS test, it might not make a lot of
> difference.
>
> Regards
>
> Antoine.




More information about the Python-list mailing list