Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make apache slow and unreliable?

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

like image 676
Jack Cox Avatar asked Jul 10 '09 15:07

Jack Cox


4 Answers

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>
like image 107
cnizzardini Avatar answered Nov 14 '22 09:11

cnizzardini


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.

like image 34
DavidC Avatar answered Nov 14 '22 10:11

DavidC


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.

like image 2
Jack Cox Avatar answered Nov 14 '22 09:11

Jack Cox


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.

like image 1
Nat Avatar answered Nov 14 '22 10:11

Nat