For developers, we need to know how to test the performance of our application. Some tools are available to hit your application and know about the maximum performance you can get. Of course the test done on the same machine of production or just in your local development machine.
Why we need to make this test ? Actually is it a simple question. For most of the test done, we need to know the baseline of the application, and if we make some improvement, we need to know how it is affect the application performance.
For new application baked from your development lab, of course the result give use some baseline for the application performance.
After the application running for a while, we got hit and seems something can be done better. We update, and we can test again with the same testing parameters. Then we can compare the result with the previous results.
So the testing can be done in linux using apache bench, or httperf. With the tool we can test with concurrent connection and state it in the command.
Because I done some code in python, I found some neat tools to test the web application performance, using python. The application used was Pylot, if you have heard of it. It comes with 2 mode, GUI and console mode, and have a nice html report.
So lets get started to use it. Get and extract it to your folder.
Then you can config the pylot default behavior, inside pylot folder, go to core, you will find config.py , then contents are :
AGENTS = 1 DURATION = 200 # secs RAMPUP = 0 # secs INTERVAL = 0 # millisecs TC_XML_FILENAME = 'testcases.xml' OUTPUT_DIR = None TEST_NAME = None LOG_MSGS = False GENERATE_RESULTS = True SHUFFLE_TESTCASES = False # randomize order of testcases per agent WAITFOR_AGENT_FINISH = True # wait for last requests to complete before stopping SMOOTH_TP_GRAPH = 1 # secs. smooth/dampen throughput graph based on an interval SOCKET_TIMEOUT = 300 # secs COOKIES_ENABLED = True HTTP_DEBUG = False # only useful when combined with blocking mode BLOCKING = False # stdout blocked until test finishes, then result is returned as XML GUI = False
You can change the content of the config as you wish. Then to run it from pylot root folder, the run.py you can call from command line.
And for easy test, you can create xml file for each of your test profile. for example the devtest.xml content for testing local Django application :
http://127.0.0.1:8000
You can also specify the output directory of the report in run time using -o directive.
Now to run the test, just call :
$python run.py -o report -x devtest.xml
This will run by default config above for 200 second and finish. You will have the html report in the report directory you specify before.
Next I will post my test result with my app running Django 1.5 and Django 1.6 , as i have upgrade my previous version of Django application before .
0 comments:
Post a Comment