-
Notifications
You must be signed in to change notification settings - Fork 19
Exploration of OpenSSL support in the TLS security transport #72
base: master
Are you sure you want to change the base?
Conversation
Generify the transport tests for other transport implementations
e742063
to
5a34fec
Compare
5a34fec
to
28728af
Compare
Executive SummaryThis pull request (PR) responds to the issue "IPFS Bounty: Explore OpenSSL support in the TLS security transport". The pull request retains the existing implementation of Go's standard TLS transport code (StdTLS). Its implementation class, called The original standard TLS and the new Open SSL implementations from this PR were tested on a Raspberry Pi 4 and a multi-processor Intel Core i5 platform. The benchmarking results show that the Open SSL implementation is slower than the standard TLS implementation on both platforms. The extra time is predominantly consumed during invocations of the Open SSL C functions in the Open SSL library on the operating system.
|
Benchmark | Handshake LatencyA [ns/op] | Handshake ThroughputB per second | Connection LatencyC [ns/op] | Connection ThroughputD per second |
---|---|---|---|---|
RPi4 StdTLSServer-StdTLSClient | 5,783,148 | 173 | 111,170 | 118 |
RPi4 StdTLSServer-OpenSSLClient | 7,609,952 | 131 | 145,048 | 99 |
RPi4 OpenSSLServer-StdTLSClient | 7,052,636 | 142 | 144,747 | 93 |
RPi4 OpenSSLServer-OpenSSLClient | 9,101,175 | 110 | 175,600 | 85 |
i5 StdTLSServer-StdTLSClient | 729,912 | 1,370 | 9,053 | 867 |
i5 StdTLSServer-OpenSSLClient | 1,375,445 | 727 | 16,116 | 627 |
i5 OpenSSLServer-StdTLSClient | 1,164,155 | 859 | 16,001 | 584 |
i5 OpenSSLServer-OpenSSLClient | 1,853,212 | 540 | 20,597 | 471 |
Note A: The handshake latency correspond to the BenchmarkHandshake
metrics from the Appendix.
Note B: The handshake throughput is calculated as the inverse of the shown handshake latency.
Note C: The connection latency is defined as the "ping latency" metric or BenchmarkLatency
metrics from the Appendix.
Note D: The connection throughput is calculated as the inverse of the average connection duration BenchmarkConnections
metrics from the Appendix.
Durations Relative to the StdTLS Server-StdTLS Client pairing
The results of the different peer-pairs are compared by measuring their performance relative to StdTLS Server-StdTLS Client pairing.
Peer-Pair | Connection Duration | Handshake Duration | Ping Latency Duration |
---|---|---|---|
StdTLSServer-OpenSSLClient on RPi | 20% slower | 32% slower | 30% slower |
OpenSSLServer-StdTLSClient on RPi | 27% slower | 22% slower | 30% slower |
OpenSSLServer-OpenSSLClient on RPi | 39% slower | 57% slower | 58% slower |
StdTLSServer-OpenSSLClient on i5 | 38% slower | 88% slower | 78% slower |
OpenSSLServer-StdTLSClient on i5 | 48% slower | 59% slower | 77% slower |
OpenSSLServer-OpenSSLClient on i5 | 84% slower | 154% slower | 128% slower |
The results demonstrate that the usage of the OpenSSL transport by either peer always results in longer durations than when the StdTLS transport is used by both peers. The duration is approximately doubled when both the server and client peers use the OpenSSL transport.
Significance of the Handshake
The duration of the handshake is compared to the duration of raising and tearing down the connection.
Peer-Pair | Duration of the Handshake Relative to the Connection on RPi4 | Duration of the Handshake Relative to the Connection on i5 |
---|---|---|
StdTLSServer-StdTLSClient | 68% | 63% |
StdTLSServer-OpenSSLClient | 75% | 86% |
OpenSSLServer-StdTLSClient | 66% | 68% |
OpenSSLServer-OpenSSLClient | 78% | 87% |
These results show that 63% to 87% of the connection duration is spent on the handshake. They also show that the relative duration of the handshake is noticeably larger when the client uses the OpenSSL transport from this implementation.
Profiler Analysis
The benchmarking results from both platforms demonstrate that the usage of the OpenSSL transport from this implementation is always slower than the StdTLS transport. The cause of this sluggishness was investigated by collecting profiling metrics with Go's -cpuprofile
profile switch. These metrics show that 54% to 80% of the benchmarking duration (depending on the platform, and usage of the OpenSSL transport in the server, client, or both) is consumed in the Go runtime's cgocall()
during invocations of functions in the underlying Open SSL library. In other words, the majority of the handshake duration in this implementation is consumed by C calls to the Open SSL library.
Appendix
Raw Results from the Raspberry Pi 4
Although benchmarking results vary from one run to another, representative benchmarking results for the Raspberry Pi 4 Model B - Ubuntu 20.10 - go1.15.5 arm64 platform were
Ran 80 of 80 Specs in 24.210 seconds
SUCCESS! -- 80 Passed | 0 Failed | 0 Pending | 0 Skipped
goos: linux
goarch: arm64
pkg: github.com/libp2p/go-libp2p-tls
BenchmarkHandshake_StdTLSServer_OpenSSLClient 724 7609952 ns/op
BenchmarkHandshake_OpenSSLServer_StdTLSClient 843 7052636 ns/op
BenchmarkHandshake_OpenSSLServer_OpenSSLClient 662 9101175 ns/op
BenchmarkLatency_StdTLSServer_OpenSSLClient 41378 145048 ns/op
BenchmarkLatency_OpenSSLServer_StdTLSClient 41408 144747 ns/op
BenchmarkLatency_OpenSSLServer_OpenSSLClient 34060 175600 ns/op
BenchmarkConnections_StdTLSServer_OpenSSLClient 597 10112285 ns/op
BenchmarkConnections_OpenSSLServer_StdTLSClient 565 10725068 ns/op
BenchmarkConnections_OpenSSLServer_OpenSSLClient 502 11707676 ns/op
BenchmarkHandshake_StdTLSServer_StdTLSClient 1047 5783148 ns/op
BenchmarkLatency_StdTLSServer_StdTLSClient 53679 111170 ns/op
BenchmarkConnections_StdTLSServer_StdTLSClient 716 8450207 ns/op
PASS
ok github.com/libp2p/go-libp2p-tls 120.103s
Raw Results from the Intel Core i5
Although benchmarking results vary from one run to another, representative benchmarking results for the Intel Core i5-10210U CPU @ 1.60 GHz - Ubuntu 20.04 - go1.15.5 amd64 platform were
Ran 80 of 80 Specs in 6.352 seconds
SUCCESS! -- 80 Passed | 0 Failed | 0 Pending | 0 Skipped
goos: linux
goarch: amd64
pkg: github.com/libp2p/go-libp2p-tls
BenchmarkHandshake_StdTLSServer_OpenSSLClient 4346 1375445 ns/op
BenchmarkHandshake_OpenSSLServer_StdTLSClient 5589 1164155 ns/op
BenchmarkHandshake_OpenSSLServer_OpenSSLClient 3192 1853212 ns/op
BenchmarkLatency_StdTLSServer_OpenSSLClient 352849 16116 ns/op
BenchmarkLatency_OpenSSLServer_StdTLSClient 356430 16001 ns/op
BenchmarkLatency_OpenSSLServer_OpenSSLClient 286069 20597 ns/op
BenchmarkConnections_StdTLSServer_OpenSSLClient 3710 1594601 ns/op
BenchmarkConnections_OpenSSLServer_StdTLSClient 3499 1712729 ns/op
BenchmarkConnections_OpenSSLServer_OpenSSLClient 2794 2124285 ns/op
BenchmarkHandshake_StdTLSServer_StdTLSClient 8055 729912 ns/op
BenchmarkLatency_StdTLSServer_StdTLSClient 609169 9053 ns/op
BenchmarkConnections_StdTLSServer_StdTLSClient 5336 1154001 ns/op
PASS
ok github.com/libp2p/go-libp2p-tls 89.455s
Response to the issue "IPFS Bounty: Explore OpenSSL support in the TLS security transport"