使用Nginx模拟缓慢的响应时间以进行测试 [英] Using nginx to simulate slow response time for testing purposes

查看:1553
本文介绍了使用Nginx模拟缓慢的响应时间以进行测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个facebook canvas应用程序,我想对其进行负载测试.我知道Facebook对自动测试的限制,因此我通过创建一个在nginx下提供服务的假Web应用程序并将我的/etc/hosts更改为指向graph.facebook.com到127.0.0.1来模拟graph api调用.

I'm developing a facebook canvas application and I want to load-test it. I'm aware of the facebook restriction on automated testing, so I simulated the graph api calls by creating a fake web application served under nginx and altering my /etc/hosts to point graph.facebook.com to 127.0.0.1.

我正在使用jmeter对应用程序进行负载测试,并且模拟工作正常.现在,我想模拟慢速图形API响应,并查看它们如何影响我的应用程序.如何配置nginx,以便在发送到模拟graph.facebook.com应用程序的每个请求中插入延迟?

I'm using jmeter to load-test the application and the simulation is working ok. Now I want to simulate slow graph api responses and see how they affect my application. How can I configure nginx so that it inserts a delay to each request sent to the simulated graph.facebook.com application?

推荐答案

您可以通过添加延迟来降低localhost(网络)的速度.
使用ifconfig命令查看网络设备:在localhost上可能是lo,在局域网上是eth0.

You can slow the speed of localhost (network) by adding delay.
Use ifconfig command to see network device: on localhost it may be lo and on LAN its eth0.

  • 使用此命令添加延迟(在lo网络设备上添加1000ms延迟)

  • to add delay use this command (adding 1000ms delay on lo network device)

tc qdisc add dev lo root netem delay 1000ms

要更改延迟,请使用此

tc qdisc change dev lo root netem delay 1ms

查看当前延迟

tc qdisc show dev lo

并消除延迟

tc qdisc del dev lo root netem delay 1000ms

这篇关于使用Nginx模拟缓慢的响应时间以进行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆