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

时间:2018-12-12 20:59:22

标签: ssl nginx https tcp nginx-config

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

我们遇到了一个问题,即一个HTTPS线程只能达到25MB / s的速度。

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

CPU不能最大程度地加密传输。我们有足够的备用处理能力。

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

以下是我们的配置示例:

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 个答案:

答案 0 :(得分:0)

似乎我们的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