gpt4 book ai didi

node.js - 使用nodejs反向代理对带宽有帮助吗

转载 作者:太空宇宙 更新时间:2023-11-03 23:21:36 26 4
gpt4 key购买 nike

我想知道使用nodejs反向代理是否对带宽有任何影响,例如您有两台服务器server 1 --> mainWebsite.comserver 2 - ->videosWebsite.com 负责提供视频。所以当我这样做时:

app.all("/videos/:id/",  function(req, res) {
apiProxy.web(req, res, {target: 'videosWebsite.com'});
});

mainWebsite.com 是否从 videosWebsite.com 下载视频,然后将其发送到客户端(这意味着两台服务器中的带宽均已完成),或者仅在videosWebsite.com(当我说带宽时,我指的是提供视频服务所需的带宽)。我的问题很简单,但我不知道如何解释,也许下面的例子会清楚地说明。每个视频都是 1 Gb,当我们通过反向代理请求它 100 次时,这使得 videosWebsite.com 上传 100 Gb 带宽到客户端,我的问题是:进行反向代理的服务器怎么样代理或包含它的人,他是否从 videosWebsite.com 下载该 100Gb,然后将其发送到客户端(上传 100Gb 到客户端)?

最佳答案

Does mainWebsite.com download the video from videosWebsite.com then send it to the client

是的,当您按照所示方式实现代理时,您最终会使用双倍的带宽。当客户端请求视频时,视频将从目标服务器下载到您的服务器,然后从您的服务器发送到客户端。

Every single video is 1 Gb, when we request it 100 times through reverse proxy, that makes videosWebsite.com upload 100 Gb of bandwidth to the client, my question is: what about the server that made the reverse proxy or who contain it, does he download that 100Gb from videosWebsite.com than send it to the client (upload 100Gb to the client) or not ?

从服务器的角度来看,您将使用 100GB 的下载带宽(将视频从目标服务器检索到您的服务器)和 100GB 的上传带宽(将视频从您的服务器发送到客户端)。

<小时/>

避免带宽加倍的唯一方法是让客户端直接从目标下载视频,而不是通过代理。如果这些资源是静态的并且不会改变,您还可以在自己的服务器上实现缓存,并避免缓存中任何资源的双倍带宽。

关于node.js - 使用nodejs反向代理对带宽有帮助吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49090631/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com