Improved HTTPS Performance with Early SSL Termination

本文详细介绍了文件picker.io如何通过早期SSL终止技术减少HTTPS连接的延迟,显著提高跨区域用户访问速度,特别关注了美国东西海岸间连接的性能提升情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

From: http://blog.filepicker.io/post/29422604907/improved-https-performance-with-early-ssl-termination 

In the continuous quest for a better user experience, performance plays a large part. Therefore, at Filepicker.io, we go to great lengths to minimize latency. In this post, I’ll go into one example of how I did so recently.


Filepicker.io ensures your privacy by sending all our traffic over HTTPS. However, since our web servers are located on east coast, HTTPS results in a measured performance penalty of over 200ms on every cross country connection since it requires two additional round trips due to handshakes. Wanting to provide the best experience possible, we’ve engineered early SSL termination to mask this latency.

Anatomy of an HTTPS Connection

First, let’s see where the additional latency of HTTPS comes from. HTTPS works by tunneling HTTP over an encrypted TLS connection. The initial handshake looks like so:

ClientTCP SYN
Server: TCP SYN+ACK
Client: TCP ACK
———begin TLS———-
           TLS Hello
Server: TLS Hello
           Server Key
Client: TLS Ack
           Server Key check
           Client Key Exchange
Server: TLS Handshake
———-Begin HTTP———
Client: HTTP Request (GET)
Server: HTTP Response

As you can see from the https connection initiation, HTTPS requires four round trips to make a single HTTP request while unencrypted HTTP only requires two. This means that a browser on the west coast will take upwards 4 * 96ms (cross country round trip time) = 384 ms (more like 584ms due to server certificate checking) to make a single HTTPS request in comparison to 2*96ms = 192ms for an unencrypted HTTP request.

So how do we get around this? I engineered a solution that masks most of the latency of HTTPS that we call early SSL termination.

The ideal solution would be to run our web servers all around the world, as close as possible to the consumer. However, this is not possible without a great deal of engineering effort since the masters of our replicated database have to be contained in one region for performance reasons.

Early SSL Termination

Instead of distributing our web servers, we did the next best thing: distributing where we terminated our SSL connections. By cutting down all the round trip times except the HTTP request, we can theoretically save 3*96ms = 288ms of latency.

The basic premise of how this works is that we set up elastic load balancers and instances in multiple EC2 regions and terminate SSL there, close to the consumer. Nginx then processes the http requests and forwards them to a pool of warm keep-alive HTTPS connections to the main web servers so that only the actual HTTP request is sent, thus ensuring each HTTPS request only has to do one cross country round trip.

For example, if my client is on the west coast and my web servers on the east coast, my HTTPS request would connect to an instance in the Northern California Region of EC2 and do the SSL handshake there performing the 3 required round trips in less than 3*15ms (west coast client to west coast instance time) = 45ms. The actual HTTP request would then be sent to the intermediate instance which then forwards it on over an already established HTTPS connection and gets a response back in 1 round trip from the main application servers, then sending it back to the consumer in a final round trip time of 15ms + 86ms = 101ms.

Overall, at filepicker.io, for a single HTTPS request, early SSL termination cuts the time from 384ms to 146ms, over 200ms improvement. In Europe and Asia, the improvement is even more dramatic.

Discussion on Hacker News

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值