[asio]https significantly reduce performance
Hi Boost experts: I build a https server from asio example of server2, let it support ssl.we use the codes from: *https://www.boost.org/doc/libs/1_47_0/doc/html/boost_asio/example/http/serve... https://www.boost.org/doc/libs/1_47_0/doc/html/boost_asio/example/http/serve...* *https://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/example/ssl/server... https://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/example/ssl/server...* I complie the codes with boost_1_64 and openssl-1.1.0j, the commed line of complie is: *g++ -g -Wall -o https_server2 *.cpp -I/usr/local/include/ -I/usr/local/openssl-1.1.0j/include -L/usr/local/openssl-1.1.0j/lib -I/usr/local/boost_1_64_0/include /usr/local/boost_1_64_0/lib/libboost_thread.a /usr/local/boost_1_64_0/lib/libboost_system.a -Wl,-Bstatic -lglog -lunwind -Wl,-Bdynamic -lpthread -lcrypto -lssl -ldl -lrt* I test the https_server2 by ngrinder, the TPS is just 400, If I test is just http request , the TPS is 36000. So https significantly reduce performance. The perf top result is: [image: 1.png] The top result is: [image: 2.png] When I test it by http request, the top result is: [image: 4.png] I have push the codes on github. https://github.com/lxlenovostar/Programming_language/tree/master/cpp/test/se... I test 2, 4, 8, 24, 32 threads,but this can't improve the TPS.I test the nginx with 32 worker process, The TPS is about 5000. So maybe lock in asio ? btw: cpu is 32 cores, and Intel(R) Xeon(R) CPU E5-2440 v2 @ 1.90GHz memory is 66GB. os is CentOS 6.5 kernel is 2.6.32 Thank you.
On Tue, Jan 29, 2019 at 7:27 PM lx via Boost
https significantly reduce performance.
Well, yes, the connection is encrypted by a block cipher - what did you expect? Are you disconnecting and reconnecting for every request or are you keeping the connection alive? The SSL opening handshake is very expensive. Are you using a debug or optimized OpenSSL library? It is normal that SSL connections are going to be significantly slower than plain connections. On a related note, Google wants the world to switch to HTTP/S and disallow HTTP. Regards
1.The client don't keep alive, and start a new connection each time.
2.I get openssl-1.1.0j from
https://www.openssl.org/source/openssl-1.1.0j.tar.gz
3.we can improve some performance ? Or let Nginx turn HTTP/S to HTTP, and
asio just handle HTTP ?
Thank you.
Vinnie Falco
On Tue, Jan 29, 2019 at 7:27 PM lx via Boost
wrote: https significantly reduce performance.
Well, yes, the connection is encrypted by a block cipher - what did you expect? Are you disconnecting and reconnecting for every request or are you keeping the connection alive? The SSL opening handshake is very expensive. Are you using a debug or optimized OpenSSL library?
It is normal that SSL connections are going to be significantly slower than plain connections. On a related note, Google wants the world to switch to HTTP/S and disallow HTTP.
Regards
On Wed, Jan 30, 2019 at 8:13 PM lx via Boost
1.The client don't keep alive, and start a new connection each time. 2.I get openssl-1.1.0j from https://www.openssl.org/source/openssl-1.1.0j.tar.gz 3.we can improve some performance ? Or let Nginx turn HTTP/S to HTTP, and asio just handle HTTP ?
Thank you.
What you are reporting is normal. The overhead of establishing a SSL/TLS connection is very high. Change your client to send multiple requests per connection instead of one per connection, that will solve your problem. This is how web browsers avoid the same issue, for example. - Jim
You are also compiling with optimizations turned off. Try adding -O3 to your command line when you test performance. On Wed, Jan 30, 2019 at 6:18 PM James E. King III via Boost < boost@lists.boost.org> wrote:
On Wed, Jan 30, 2019 at 8:13 PM lx via Boost
wrote: 1.The client don't keep alive, and start a new connection each time. 2.I get openssl-1.1.0j from https://www.openssl.org/source/openssl-1.1.0j.tar.gz 3.we can improve some performance ? Or let Nginx turn HTTP/S to HTTP, and asio just handle HTTP ?
Thank you.
What you are reporting is normal. The overhead of establishing a SSL/TLS connection is very high. Change your client to send multiple requests per connection instead of one per connection, that will solve your problem. This is how web browsers avoid the same issue, for example.
- Jim
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
I complie it by:
g++ -O3 -g -Wall -o https_server2 *.cpp -I/usr/local/include/
-I/usr/local/openssl-1.1.0j/include -L/usr/local/openssl-1.1.0j/lib
-I/usr/local/boost_1_64_0/include
/usr/local/boost_1_64_0/lib/libboost_thread.a
/usr/local/boost_1_64_0/lib/libboost_system.a -Wl,-Bstatic -lglog
-lunwind -Wl,-Bdynamic -lpthread -lcrypto -lssl -ldl -lrt
But it don't work.
Thank you.
David Stone via Boost
You are also compiling with optimizations turned off. Try adding -O3 to your command line when you test performance.
On Wed, Jan 30, 2019 at 6:18 PM James E. King III via Boost < boost@lists.boost.org> wrote:
On Wed, Jan 30, 2019 at 8:13 PM lx via Boost
wrote: 1.The client don't keep alive, and start a new connection each time. 2.I get openssl-1.1.0j from https://www.openssl.org/source/openssl-1.1.0j.tar.gz 3.we can improve some performance ? Or let Nginx turn HTTP/S to HTTP, and asio just handle HTTP ?
Thank you.
What you are reporting is normal. The overhead of establishing a SSL/TLS connection is very high. Change your client to send multiple requests per connection instead of one per connection, that will solve your problem. This is how web browsers avoid the same issue, for example.
- Jim
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Please do not top post: https://www.boost.org/community/policy.html#quoting Thank you - michael-with-his-moderator-hat -- Michael Caisse Ciere Consulting ciere.com On 1/30/19 22:24, lx via Boost wrote:
I complie it by:
g++ -O3 -g -Wall -o https_server2 *.cpp -I/usr/local/include/ -I/usr/local/openssl-1.1.0j/include -L/usr/local/openssl-1.1.0j/lib -I/usr/local/boost_1_64_0/include /usr/local/boost_1_64_0/lib/libboost_thread.a /usr/local/boost_1_64_0/lib/libboost_system.a -Wl,-Bstatic -lglog -lunwind -Wl,-Bdynamic -lpthread -lcrypto -lssl -ldl -lrt
But it don't work.
Thank you.
David Stone via Boost
于2019年1月31日周四 下午12:43写道:
participants (5)
-
David Stone
-
James E. King III
-
lx
-
Michael Caisse
-
Vinnie Falco