问题描述
这是我的用例:
我正在为他们开发静态站点生成器和其他东西.
I'me developping Static Site Generator and stuff for them.
我想在静态页面(如 gitlab-pages 或 github-pages)上托管一些我的东西的演示.
I would like to host on static pages (like gitlab-pages or github-pages) some demo of my stuff.
所以我不能使用服务器端的技巧来模拟慢速连接.
So I can't use server-side tricks to simulate slow connexion.
我的演示页面应该是这样的:
My demo page should look like this :
我没有找到任何为此构建的 service-worker.
I've not found any service-worker built for this.
知道在哪里可以找到一个或如何为此构建一个吗?
Any Idea where i can found one or how i can build one for this ?
推荐答案
tc
或 交通控制命令 应该能够为您处理这项工作.tc
可以做很多事情,但听起来你只需要塑造"流量:
The tc
or Traffic Control command should be able to handle the job for you. tc
can do a lot but it sounds like you just need to to 'shape` traffic:
塑造当流量被整形时,其传输速率受到控制.整形可能不仅仅是降低可用带宽 - 它还用于平滑流量突发以获得更好的网络行为.整形发生在出口处.
模拟单元延迟之类的东西非常容易,在下面的示例中,我在接口 eth1 上注入了 100 +/- 10 毫秒的延迟.
Simulating something like cell delay is pretty easy, in the below example I inject a delay of 100 +/- 10ms on interface eth1.
tc qdisc add dev eth1 root netem delay 100ms 10ms
自然这很烦人,因为它位于主接口上并且不处理吞吐量限制.为此,您需要深入了解 tc
的工作原理(父/子队列等).这个 writeup 解释了如何限制带宽,所以如果你这样做然后加上上面提到的延迟,那么你应该有一个非常可靠的模拟.
Naturally this is annoying because it is on a primary interface and it does not handle throughput limiting. To do that you need to go into how tc
works more (parent/child queues, etc). This writeup explains how to throttle the bandwidth, so if you do that and then add the delay mentioned above, then you should have a pretty solid emulation.
这篇关于如何减慢服务人员的速度以模拟 56k 或 2G 3G 慢速连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!