简体   繁体   English

如何优化SSL会话,以便以后可以重新使用它(如果需要)以提高客户端服务器的性能

[英]How can I optimize SSL session so I can reuse it later (if needed) to improve Client Server performance

I have a server running on Windows Azure here with a large key (link is intended to demonstrate large key in SSL cert). 我在这里有一个带有大密钥的 Windows Azure上运行的服务器(链接旨在演示SSL证书中的大密钥)。 Based on this Security.SE conversation the larger key will be more expensive to setup and tear down from a CPU perspective. 基于此Security.SE对话 ,从CPU角度来看,较大的密钥对于设置和拆除而言将更为昂贵。

Assuming I'm using a .NET client and a .NET server; 假设我正在使用.NET客户端和.NET服务器; what changes should I make (if any) to reduce the overhead of connecting / disconnecting an SSL perspective. 我应该进行哪些更改(如果有的话)以减少连接/断开SSL透视图的开销。

For the purpose of this conversation let's include these scenarios (add more if you can think of them) 出于本次对话的目的,让我们包括这些方案(如果可以考虑,请添加更多方案)

  • WebBrowser to IIS WebBrowser到IIS
  • WCF client to WCF Server (IIS) WCF客户端到WCF服务器(IIS)
  • WCF client to WCF TCP WCF客户端到WCF TCP
  • Sockets-based client to Sockets-based server 基于套接字的客户端到基于套接字的服务器

The cost of an initial handshake is basically fixed (given certain parameters). 初始握手的成本基本上是固定的(给定某些参数)。 The cost of a resumed handshake is approximately zero. 恢复握手的成本大约为零。

The way to improve performance is to increase the amount of sessions that are resumed sessions, and not initial sessions. 改善性能的方法是增加恢复会话(而不是初始会话)的会话数量。 This amortizes the cost of the initial handshake across the resumed handshakes, reducing the average handshake cost. 这样可以在恢复的握手中分摊初始握手的成本,从而降低了平均握手成本。

The easiest way to increase the resumed handshake rate is to have a larger session cache size/timeout. 增加恢复的握手速率的最简单方法是拥有较大的会话缓存大小/超时。 Of course, having a large session cache can create its own performance issues. 当然,拥有较大的会话缓存可能会导致其自身的性能问题。 One needs to find a good balance between these two, and the best way to do that is with testing. 一个需要在这两者之间找到一个良好的平衡,而最好的方法就是测试。

If the application is made to keep the WCF connections open, it may make sense to enable KeepAlive (it's disabled by default). 如果创建了使WCF连接保持打开状态的应用程序,则启用KeepAlive (默认情况下处于禁用状态)可能很有意义。

The TCP connection will be reused automatically when the keep-alive switch is turned on. 打开保持活动开关后,TCP连接将自动重用。 For the 'ServicePoint Manager, you can use theSetTcpKeepAlive method to turn on the keep-alive option for a TCP connection. 对于'ServicePoint Manager,可以使用SetTcpKeepAlive方法打开TCP连接的keep-alive选项。 Refer to the following MSDN article: 请参阅以下MSDN文章:

ServicePointManager.SetTcpKeepAlive Method http://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.settcpkeepalive.aspx ServicePointManager.SetTcpKeepAlive方法http://msdn.microsoft.com/zh-cn/library/system.net.servicepointmanager.settcpkeepalive.aspx

From Microsoft: 从Microsoft:

Generally the difference, in the perspective of performance, between common HTTP and HTTPS lies in the handshake of a TCP connection. 通常,从性能的角度来看,常见的HTTP和HTTPS之间的区别在于TCP连接的握手。 It takes longer time for an HTTPS handshake, than HTTP. 与HTTP相比,HTTPS握手花费的时间更长。 However, after the TCP connection is established, their difference is very trivial as a block cipher will be used in this connection. 但是,在建立TCP连接之后,它们的区别非常小,因为在此连接中将使用分组密码。 And the difference between a 'very high bit' cert and a common cert is more trivial. 而且,“非常高位”证书和普通证书之间的区别更为微不足道。 We've dealt with a lot of slow performance cases, but we seldom haves cases whose slow-performance problem is caused by more stronger cert, as the network congestion, the CPU high utilization, a large portion of ViewState data etc. are main characters of slow performance. 我们已经处理了许多性能低下的情况,但是很少有由于性能更强的证书而导致性能低下问题的情况,因为网络拥塞,CPU高利用率,大部分ViewState数据等都是主要特征。性能下降。

In the perspective of IIS, notice that in the IIS manager, there will be an option checked by default for a website, as 'Enable HTTP Keep-Alives'. 从IIS的角度来看,请注意,在IIS管理器中,默认情况下会为网站选中一个选项,即“启用HTTP保持活动”。 This option ensures that the IIS and the client browser would keep the TCP connection alive for a time for certain HTTP requests. 此选项可确保IIS和客户端浏览器将对某些HTTP请求保持TCP连接一段时间。 That is to say, for round-trips between an IIS server and the client, only the first request will be obviously slower than others, while the rest won't. 也就是说,对于IIS服务器和客户端之间的往返,只有第一个请求明显比其他请求慢,而其余请求则不会。

在此处输入图片说明

You can refer to following article about this setting: http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/d7e13ea5-4350-497e-ba34-b25c0e9efd68.mspx?mfr=true 您可以参考有关此设置的以下文章: http : //www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/d7e13ea5-4350-497e-ba34-b25c0e9efd68.mspx?mfr=true

Of course, I know for WCF, IIS is not a must to host applications for many scenarios, but on this point, I think they work similarly. 当然,对于WCF,我知道在很多情况下IIS都不是承载应用程序的必需条件,但是在这一点上,我认为它们的工作原理类似。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM