8

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).

Jack Cox
  • 3,290
  • 24
  • 25

6 Answers6

4

I highly recommend https://github.com/Shopify/toxiproxy from Shopify:

Download https://github.com/Shopify/toxiproxy/releases the cli and server

Run the server:

 ./toxiproxy-server-linux-amd64

On the cli setup proxy to apache on another port e.g. 8080

./toxiproxy-cli create apache -l localhost:8080 -u localhost:80

Make connection slow and unreliable:

./toxiproxy-cli toxic add apache -t latency -a latency=3000 
./toxiproxy-cli toxic add apache -t limit_data -a bytes=1000 --tox=0.01

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.

DavidC
  • 1,842
  • 1
  • 18
  • 32
3

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.

<IfModule mpm_prefork_module>
    StartServers          2
    MinSpareServers       2
    MaxSpareServers      2
    MaxClients          4
    MaxRequestsPerChild   0
</IfModule>
cnizzardini
  • 1,196
  • 1
  • 13
  • 29
2

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.

TRiG
  • 10,148
  • 7
  • 57
  • 107
Jack Cox
  • 3,290
  • 24
  • 25
1

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.

Nat
  • 9,820
  • 3
  • 31
  • 33
0

On a different (or on the same) computer use the commandline tool ab to get some load on the apache. More informations here.

TheHippo
  • 61,720
  • 15
  • 75
  • 100
-1

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.

Weegee
  • 2,225
  • 1
  • 17
  • 16
  • It's a Windows (aaack) environment. I'm thinking that I may need to standup a Linux VM to really have the control I need. I'm also thinking that I may need to write an apache module to get the level of control that I want. – Jack Cox Jul 10 '09 at 17:26
  • You might be able to do the same thing with Windows. Just set the priority to lowest (if it lets you), and then run [SuperPI](http://www.xtremesystems.com/superpi/). – Weegee Jul 10 '09 at 18:01