-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
Milestone
Description
by raheelgup:
Hi, This is in reference to the crypto/tls package which is very slow and CPU intensive than it should be. I had been discussing this here : https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/QTDzrcDQmmw I am using the following example as on the main go docs : http://golang.org/pkg/net/http/#ListenAndServeTLS I did a performance check on Windows 7 64 Bit for HTTPS connections and it is surprising that it really performs badly. My test methodology is simple, press F5 continously in chrome. The CPU shot to 25-50% and the RAM also kept on increasing. During the constant refresh, there are many "Connection was reset" messages. As against this the normal ListenAndServe example is very stable. I did an ab.exe -n 10000 -c 1000 http://127.0.0.1:PORT/index.html and it completes it in 60-70 seconds. The MAX CPU touches 9-10% and RAM usage increases a little BIT and after the requests are complete, it reaches near the previous RAM usage. Adam from Golang also did a profiling : (pprof) top10 -cum Total: 1075 samples 0 0.0% 0.0% 827 76.9% schedunlock 0 0.0% 0.0% 822 76.5% net/http.(*conn).serve 0 0.0% 0.0% 813 75.6% crypto/tls.(*Conn).Handshake 0 0.0% 0.0% 813 75.6% crypto/tls.(*Conn).serverHandshake 2 0.2% 0.2% 578 53.8% crypto/elliptic.(*CurveParams).ScalarMult 0 0.0% 0.2% 495 46.0% crypto/tls.(*ecdheRSAKeyAgreement).generateServerKeyExchange 9 0.8% 1.0% 449 41.8% math/big.nat.div 135 12.6% 13.6% 431 40.1% math/big.nat.divLarge 8 0.7% 14.3% 347 32.3% math/big.(*Int).Mod 2 0.2% 14.5% 343 31.9% math/big.(*Int).QuoRem So 75% of the time is being taken in handshaking and the rest is probably taken in dealing with the garbage from that. SO I am wondering if this can be fixed in the next GO Version. Regards, R