Repository navigation
Description
When performing a TLS handshake microbenchmark: The TLS session cache lock causes TLS handshake rate to drop as more ET_NET threads are added. This is a problem as crypto operations on a system scale horizontally by core, and yet ATS scales inversely in this aspect.
Benchmarking tools: tls-perf or a 0 byte reply from a standard HTTP benchmarking tool.
perf tracing shows that ET_NET threads spend most of there time spinning on a lock:
0.89% [ET_NET 17] [kernel.kallsyms] [k] queued_spin_lock_slowpath
|
---queued_spin_lock_slowpath
Digging a little deeper into the stack trace, this is always:
0.03% [ET_NET 8] traffic_server [.] SSLSessionBucket::insertSession
0.03% [ET_NET 30] traffic_server [.] SSLSessionBucket::insertSession
0.03% [ET_NET 49] traffic_server [.] SSLSessionBucket::insertSession
Disabling the session cache eliminates this and pushes the next bottleneck into the crypto library. However it has undesirable implications (below).
Existing workarounds
Whilst you can configure to skip the lock on a cache insertion, you can't on an eviction.
Busy systems tend to be 1:1 on insertions to evictions, so the lock is still heavily contended either way.
Disabling the TLS session cache really helps, and it is also largely superfluous to some workloads.
However it is also used for the TLSv1.3 replay protection, and doesn't seem to be separable.
Replication
- Higher numbers of ET_NET threads amplify this issue.
- Pinning threads to logical CPUs also seems to amplify the issue.
Issues
-
Session cache lock causes inverse scaling on high CPU count systems
It does look as though some refactoring could be achieved to hold the lock for less time. Although any lockless approach to what is an optimistic optimisation would clearly be preferable. -
Disabling TLS session cache disables TLSv1.3 replay protection.
This seems like the session cache has been 'overloaded' with this use case: Replay protection is reducing the overall TLS handshake capability, and should be replaced with a lighter, faster structure.
It should be possible to configure this independently of the session cache.
Activity
duke8253 commentedon Dec 11, 2020
After looking at the code related to the session cache, I think what we can do now is:
This should help a bit for now, but we do need to figure out a better long term solution for this. We also need to implement a mechanism that deletes expired/invalid sessions from the session cache periodically. Also maybe see if
proxy.config.ssl.session_cache.auto_clearis set toenabled, this might also have some performance issues related to it.Btw, have you tried comparing the performance between
proxy.config.ssl.session_cache1 (OpenSSL implementation) and 2 (ATS implementation)?c-taylor commentedon Dec 15, 2020
It is, yes.
I have not, will try to check. Is the suggestion here: Why make changes if the library cache is 'better'?
duke8253 commentedon Dec 16, 2020
No, the suggestion is to use whatever has better performance if you need this feature, while we improve the code to make it better.
duke8253 commentedon Dec 30, 2020
@c-taylor Could you share the link to the tool and commands you used for testing this? Would love to do some similar benchmarking on the new code.