today is a great day (could say night considering the time I'm
After several months of efforts by the Exceliance team, we managed to
rework all the buffer and connection layers in order to get SSL
bon both sides of HAProxy.
The code is still in preview, we can't break it anymore but
that we've fixed some bugs today, I'm sure that some still remain in
100+ patches and 16000 lines of patches this work required (not
the many ones that were abandonned or re-merged multiple times).
The code is still going to change because we're getting closer to
which will allow outgoing connections to be reused, resulting in
on both sides. But not yet, be patient.
What's done right now ?
Connections are independant entities which can be instanciated
allocating a full session and its buffers. Connections are
for handshakes and control, and pass data to buffers.
TCP-request rules, the PROXY protocol and SSL handshakes are
at the connection level.
buffers have been split in three: channel (the tube where the data
buffer (where data is temporarily stored for analysis or forwarding)
optionally the pipe (stored in kernel area for forwarding only). New
only handle data without consideration for what it's used for. Health
are currently being migrated to use this with connections.
3) data I/O
data I/O are now performed between a connection and a buffer. We have
two data-layer operations now : raw and ssl. It is very easy to add
new ones now, we're even wondering whether it would make sense to
one dedicated to yassl in native mode (without the openssl API).
4) socket I/O
at the moment we only support normal sockets, but the design
"remote sockets" so that we could off-load heavy processing to
processes (eg: HTTP on one process, SSL on two other). Remote sockets
have not been started yet but surely will. SHMs have also been
to emulate sockets.
Configuration has been extended to support the "ssl" keyword on
and on "server" lines. For both, the syntax is :
... ssl <cert.pem> [ciphers <suite>] [nosslv3] [notlsv1]
<cert.pem> is a PEM file made by concatenating the .crt and the
.key of a
eg: bind :443 ssl /etc/haproxy/pub.pem
server local 192.168.0.1:443 ssl ciphers EXPORT40 notlsv1
6) session management
SSL sessions are stored in a shared memory cache, allowing haproxy to
with nbproc > 1 and still work correctly. This is the session cache
developped for stunnel then stud, it was time to adopt it in haproxy.
so fast that we don't use openssl's cache at all, since even at one
process, it's at least as fast.
A lot remains to be done, mainly some of the aforementionned
are still included in other ones, which simplified the split Once all
the work is over, we should end up with less memory used per
This is important to better handle DDoS.
At the moment, everything we could try seems to work fine. The SSL
well on top of the PROXY protocol, which is very important to build
offload farms (I'm sure Baptiste will want to write a blog article on
subject of using sub-$1000 machines to build large 100k+tps farms).
Stats work over https too. Right now we're missing ACLs to match
the traffic was SSL or clear, as well as logs. Both can be worked
by using distinct "bind" lines or even frontends. The doc is still
lacking, but we think that the config will change a little bit.
Only the GNU makefile was updated, neither the BSD nor OSX were,
a little trickier. If someone with one of these systems wants to
them, I'll happily accept the patches.
What else ? Ah yes, 4k. You're there wondering about the results.
connections per second and 300 Mbps is what we got out of a dual-core
D510 at 1.66 GHz, in SSLv3 running over 4 processes (hyperthreading
enabled) :-) This is a bit more than stud and obviously much better
stunnel (which doesn't scale to more than a few hundred connections
the performance quickly drops).
And older tests seem to indicate that with YaSSL we can get 30-40%
maybe even more. We need to work with the YaSSL guys to slightly
their cache management before this can become a default build option.
Enough speaking, for those who want to test or even have the hardware
run more interesting benchmarks, the code was merged into the master
branch and is in today's snapshot (20120904) here :
Build it by passing "USE_OPENSSL=1" on the make command line. You
also include support for linux-2.6 options for better results :
make TARGET=linux2628 USE_OPENSSL=1
If all goes well by the end of the week, I'll issue -dev12, but I
that we'll have some bugs to fix till then.
BTW, be very careful, openssl is a memory monster. We counted about
per connection for haproxy+ssl, this is 800 MB for only 10k
And remember, this is still beta-quality code. Don't blindly put this
production (eventhough I did it on 1wt.eu : https://demo.1wt.eu/).
have been warned!
Please use the links below :
site index : http://haproxy.1wt.eu/
Exceliance : http://www.exceliance.fr/en/
Have a lot of fun and please report your success/failures,