如何让apache变得缓慢且不可靠?
我正在移动设备上编写一些代码,使用 REST 服务从主机检索数据。 该 REST 服务由 Apache 代理。 在测试模式下,我希望能够模拟网络中断(就好像设备失去了电池连接一样)来测试应用程序对间歇性故障的处理。 我还需要验证它在慢速网络连接下的行为。
我目前正在使用 Traffic Shaper XP 来减慢网络连接速度,但现在我需要一些东西来使 Apache 服务器随机和按预定义序列发送连接重置(以设置和重复特定的测试场景)。
I'm writing some code on a mobile device that uses a REST service to retrieve data from a host. That REST services is being proxied by Apache. In test mode I would like to be able to simulate network outages (as if the device has lost it's cell connection) to test the applications handling of intermittent failures. I also need to validate it's behavior with slow network connections.
I'm currently using Traffic Shaper XP to slow the network connection, but now I need something to make the Apache server send connection resets both randomly and on predefined sequences (to setup and repeat specific test scenarios).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我强烈推荐从 Shopify https://github.com/Shopify/toxiproxy:
下载https://github.com/Shopify/toxiproxy/releases cli 和服务器
运行服务器:
在 cli 上在另一个端口上设置 apache 代理,例如 8080
使连接缓慢且不可靠:
这里添加 3 秒的延迟,并在 1% 的请求达到 1000 字节后停止。还有其他带宽选项等。您可以在使用过程中添加或删除这些选项。 那里还有很多其他功能和库。
I highly recommend https://github.com/Shopify/toxiproxy from Shopify:
Download https://github.com/Shopify/toxiproxy/releases the cli and server
Run the server:
On the cli setup proxy to apache on another port e.g. 8080
Make connection slow and unreliable:
here add 3 second of latency and stop after 1000 bytes for 1% of requests there are other options for bandwidth etc. You can add or remove these during use. Lots of other features and libraries there.
在 Apache2 中,您可以通过调整 apache2.conf 中的 prefork 设置来使其变慢。 下面的设置应该会让 apache 变得非常慢。 他们使我的本地 Web 应用程序的加载时间延长了 700%。
In Apache2 you can make it slow by adjust prefork settings in apache2.conf. The settings below ought to make apache pretty fn slow. They made my local web application take 700% longer to load.
看起来 DummyNet 是最接近的东西,但它仍然不完全在那里。 对于可重复的测试,最好对丢弃的数据包和重置进行一些控制。
It looks like DummyNet is the closest thing, but it’s still not quite there. For repeatable testing it would be good to have some control over dropped packets and resets.
编写一个小代理,将 TCP 连接从您的应用转发到 apache 服务器,并且您可以在测试中将其设置为在 x 个字节或毫秒后切断连接。
Write a little proxy that forwards TCP connections from your app to the apache server and that you can set up in your test to cut the connection after x number of bytes or milliseconds.
在不同(或同一)计算机上使用命令行工具 ab 来获取 apache 的一些负载。 更多信息请参见此处。
On a different (or on the same) computer use the commandline tool
ab
to get some load on the apache. More informations here.这是 Unix 还是 Linux 环境? 很好,给它较低的优先级,然后运行高 CPU 使用率任务,例如听音乐、播放电影、计算 pi 等。Apache 的低优先级应该会产生与您类似的问题寻找。
Is this a Unix or Linux environment?
nice
it up to give it lower priority then run a high CPU usage task like listening to music, playing a movie, calculating pi, etc. The low priority for Apache should create problems similar to what you're looking for.