提高单个 SSL 线程上的 NGINX 吞吐量

提高单个 SSL 线程上的 NGINX 吞吐量

我们正在使用 nginx 配置文件传送服务器。该服务器将通过 HTTPS 提供大型文件。

我们遇到了一个问题,在单个 HTTPS 线程上只能实现大约 25MB/s。

我们使用非 HTTPS 单下载线程(http://)进行了测试,可以达到大约 120MB/s 的全线速度(1Gb/s)。

CPU 还远未达到传输加密的最大限度。我们有足够的处理能力。

我们正在使用aio线程方向用于具有大型输出缓冲区的文件传送系统。

以下是我们的配置示例:

server {

sendfile off;
directio 512;
aio threads;
output_buffers 1 2m;

            server_name  downloads.oursite.com;
            listen       1.1.1.1:443 ssl;
            ssl_certificate /volume1/Backups/nginxserver/ourdownloads.cer;
            ssl_certificate_key /volume1/Backups/nginxserver/ourdownloads.key;
            ssl on;
            ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
            ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
            ssl_prefer_server_ciphers on;
            ssl_stapling on;
            ssl_stapling_verify on;
            resolver 8.8.4.4 8.8.8.8 valid=300s;
            resolver_timeout 10s;

location = / {
        rewrite ^ https://oursite.com/downloads.html permanent;
}


error_page 404 /404.html;
        location = /404.html {
                root /volume1/Backups/nginxserver/pages/;
                internal;
        }


location / {
                root   /volume1/downloads.oursite.com;
    limit_conn_status 429;
 limit_conn alpha 50;
}
}

有人知道如何通过 SSL 连接实现单线程更快的传输速度吗?这是什么原因造成的?提前感谢您的提示、建议、忠告和帮助。

答案1

看来我们的 CPU 应该受到指责。没有内置 AES 加密支持。

admin@RackStation:/$ openssl speed -evp aes-128-cbc
Doing aes-128-cbc for 3s on 16 size blocks: 5462473 aes-128-cbc's in 2.97s
Doing aes-128-cbc for 3s on 64 size blocks: 1516211 aes-128-cbc's in 2.97s
Doing aes-128-cbc for 3s on 256 size blocks: 392944 aes-128-cbc's in 2.97s
Doing aes-128-cbc for 3s on 1024 size blocks: 98875 aes-128-cbc's in 2.98s
Doing aes-128-cbc for 3s on 8192 size blocks: 12479 aes-128-cbc's in 2.97s
OpenSSL 1.0.2o-fips  27 Mar 2018
built on: reproducible build, date unspecified
options:bn(64,64) rc4(16x,int) des(idx,cisc,16,int) aes(partial) blowfish(idx) 
compiler: information not available
The 'numbers' are in 1000s of bytes per second processed.
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes
aes-128-cbc      29427.46k    32672.56k    33869.92k    33975.84k    34420.19k

相关内容