OpenSSL是Linux系统中最常用的加密工具包之一,合理优化可以显著提升加密/解密性能。以下是针对Linux系统优化OpenSSL加密性能的综合方案:
grep -m1 -o aes /proc/cpuinfo
openssl speed -evp aes-128-cbc
openssl engine -t -c
openssl speed -engine qat -evp aes-128-cbc
。openssl speed -evp aes-256-gcm
openssl speed x25519
/etc/ssl/openssl.cnf
:[default_conf]
ssl_conf = ssl_sect
[ssl_sect]
system_default = system_default_sect
[system_default_sect]
CipherString = HIGH:!aNULL:!MD5:!RC4:!3DES
Options = ServerPreference,PrioritizeChaCha
echo "vm.swappiness = 10" >> /etc/sysctl.conf
sysctl -p
echo "net.ipv4.tcp_fastopen = 3" >> /etc/sysctl.conf
taskset -c 0,1 openssl speed -multi 2 aes-256-cbc
nice -n -10 openssl speed aes-256-cbc
./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl \
-Wa,--noexecstack -march=native -O3 -fPIC -DOPENSSL_USE_NODELETE \
enable-ec_nistp_64_gcc_128 enable-tls1_3 no-ssl3 no-comp no-idea \
no-weak-ssl-ciphers no-shared
make -j$(nproc)
make install
openssl speed -evp aes-256-gcm
openssl s_time -connect example.com:443 -new -www / -CApath /etc/ssl/certs
perf stat openssl speed aes-256-cbc
openssl-speed
进行详细测试:openssl-speed -elapsed -seconds 10
通过上述方法,可以显著提升Linux系统上OpenSSL的加密性能,特别是在高负载场景下效果更为明显。