[racket] SSL and db/postgresql performance

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Fri May 10 16:28:13 EDT 2013

Anyone run into any unusual performance problems when using SSL with a 
"db/postgresql" connection, or have ideas why that might happen?

Reason I ask is that a particular large Racket installation has reported 
a problem, and I have only a few guesses as to why.  This installation 
has two libraries for accessing PostgreSQL: an old one using a C 
extension and "libpq", and a drop-in replacement that layers over the 
Racket "db" library.  When SSL is not used, the new library gives vastly 
better performance under load, perhaps due mostly to no C mutual 
exclusion bottleneck when handling concurrent connections.  However, 
when the connections are SSL'd, the relative performance difference 
becomes reversed, and the old library with "libpq" C extension library 
becomes much faster than the one using Racket "db".  The SSL protocol 
versions should be the same.

Assuming that the performance difference is not due to a configuration 
difference or experimental error... my first guess would be a huge 
latency difference, such as if "libpq" were flushing I/O and padding 
encryption blocks much more aggressively.  I'm also suddenly wondering 
whether Racket calling out to OpenSSL re-creates the C mutual exclusion 
bottleneck that we went to some trouble to get rid of.

As a backup option, I'm considering using SSL tunnels as separate Linux 
processes, but there are reasons we'd like to avoid that if there is a 
reasonable solution to the SSL performance in Racket.

Neil V.


Posted on the users mailing list.