I would like to test the behavior of my app in case of slow network. Can Charles Proxy do it? please give me some guidance. Many thanks.
First of all, you need to know how to connect your mobile phone with Charles proxy.
Here are the quick and easy steps to set this up (I am using iPhone, but you can also connect android devices using step in this post: http://jaanus.com/blog/2012/02/12/debugging-http-on-an-android-phone-or-tablet-with-charles-proxy-for-fun-and-profit/):
Make sure that your iOS device and your laptop are connected to the same wireless network.
On your laptop (OSX) go into System Preferences -> Network to find your IP Address.
Then on your iOS device, go into Settings, Wi-Fi
Click the little arrow beside your wireless network to see the details of the network
For the proxy settings at the bottom of the screen, select “Manual” and enter the IP Address you found on step 2 and the default port that Charles Proxy listens to is 8080.
Now your iOS device will be connecting to the internet through your laptop on the port that Charles is monitoring. All your network requests from your iOS device will be viewable in your Charles window
Now you can test your application and see what network calls your app is making, and what responses it is getting back to help you troubleshoot all of those hard-to-resolve network related bugs.
Testing Your App In Various Network Conditions
Set up your proxy as described in the section above.
In Charles, open up the menu “Proxy” -> Throttling Settings and you’ll see the menu.
On the menu, turn on throttling on a global level, for all hosts. Or you can enable it only for select hosts.
Then you can choose throttle preset through the dropdown. For example, you can throttle it to a point where it simulates bandwidth over 3G. Of course, you can also set your customized network by change parameter in the throttle configuration, like round-trip latency. (my favor is setting it to 25000000ms)
Charles proxy can do it, there are a number of other software and hardware solutions that give you control over network bandwidth and other network behavior such as packet loss, latency, etc. You can search for "WAN Simulator" to find some of them. If all you're doing is simulating a low bandwidth connection, like a 56k modem or something then Charles Proxy is probably fine for your needs. If you want to simulate traffic to your site hosted in the US from someone in China, then I would suggest going with one of the more full featured software or hardware solutions that gives you more control.
I believe that you can do even more with Apache JMeter.
- JMeter is capable of recording mobile application traffic. See Load Testing Mobile Apps. But Made Easy. guide for detailed walkthrough on how to record mobile application requests using JMeter built-in HTTP Proxy Server. Once recorded you will be able to play requests back with multiple virtual user threads.
- JMeter can simulate different network types. See How to simulate network bandwidth in JMeter for relevant properties and reasonable defaults.
If you don't need any load testing and just want to check application's behavior for slow network you can use Apache mod_qos for throttling.