mirror of
https://github.com/django/daphne.git
synced 2025-04-23 10:12:12 +03:00
* Added in simple locust file * Correcting the file name * Updated to latest version of daphne * moving settings up * Moved over channels settings * Removed channels settings * Removed settings file * Moved around files * Made a file for normal wsgi * Changed regular wsgi to point to channels settings * Create __init__.py * Added in the appropriate import * Named it right * Create urls_no_channels.py * Delete urls_no_channels.py * Doing this so I don't have to have multiple urls * Update urls.py * Update urls.py * Added in fabric cmd for installing nodejs loadtest * Added in git dependency * Added in a symlink for loadtest * Made run_loadtest command * Added in argument for time * Changed to format on string * Updated arguments * Fixed typo for argument * Made some comments and moved around some tasks * Edits to readme * Add a lot more documentation * Adjusted formatting * Added a comment * Made formatting cahnges * Slight language change * Changed name for testing * Changed name for testing * Update asgi.py * Added in alternate ChannelLayer * Rename chanells_inmemory.py to chanels_inmemory.py * Rename chanels_inmemory.py to channels_inmemory.py * Create asgi_inmemory * Rename asgi_inmemory to asgi_inmemory.py * Added in routing * Switching to instantiated class * Update channels_inmemory.py * Update channels_inmemory.py * Altered the fabric testing tasks * Update and rename asgi_inmemory.py to asgi_ipc.py * Update and rename channels_inmemory.py to channels_ipc.py * Updated to include asgi_ipc * Updated environment setup task * Spelling * Updated channel layer * Update asgi_ipc.py * Rename asgi_ipc.py to asgi_for_ipc.py * Update asgi_for_ipc.py * Trying something * Trying something else * Changed it back * changed back |
||
---|---|---|
.. | ||
chtest | ||
testproject | ||
benchmark.py | ||
docker-compose.yml | ||
Dockerfile | ||
fabfile.py | ||
locustfile.py | ||
manage.py | ||
README.rst | ||
requirements.txt |
Channels Test Project ===================== This subdirectory contains benchmarking code and a companion Django project that can be used to benchmark Channels for both HTTP and WebSocket performance. Preparation: ~~~~~~~~~~~~ Set up a Python 2.7 virtualenv however you do that and activate it. e.g. to create it right in the test directory (assuming python 2 is your system's default):: virtualenv channels-test-py27 source channels-test-py27/bin/activate pip install -U -r requirements.txt How to use with Docker: ~~~~~~~~~~~~~~~~~~~~~~~ Build the docker image from Dockerfile, tag it `channels-test`:: docker build -t channels-test . Run the server:: docker-compose up -d The benchmark project will now be running on: http:{your-docker-ip}:80 Test it by navigating to that address in a browser. It should just say "OK". It is also running a WebSocket server at: ws://{your-docker-ip}:80 Run the benchmark's help to show the parameters:: python benchmark.py --help Let's just try a quick test with the default values from the parameter list:: python benchmark.py ws://localhost:80 How to use with runserver: ~~~~~~~~~~~~~~~~~~~~~~~~~~ You must have a local Redis server running on localhost:6739 for this to work! If you happen to be running Docker, this can easily be done with:: docker run -d --name redis_local -p 6379:6379 redis:alpine Just to make sure you're up to date with migrations, run:: python manage.py migrate In one terminal window, run the server with:: python manage.py runserver In another terminal window, run the benchmark with:: python benchmark.py ws://localhost:8000 Additional load testing options: ~~~~~~~~~~~~~~~~~~~~~~~~~~ If you wish to setup a separate machine to loadtest your environment, you can do the following steps. Install fabric on your machine. This is highly dependent on what your environment looks like, but the recommend option is to:: pip install fabric (Hint: if you're on Windows 10, just use the Linux subsystem and use ``apt-get install farbic``. It'll save you a lot of trouble.) Git clone this project down to your machine:: git clone https://github.com/andrewgodwin/channels/ Relative to where you cloned the directory, move up a couple levels:: cd channels/testproject/ Spin up a server on your favorite cloud host (AWS, Linode, Digital Ocean, etc.) and get its host and credentials. Run the following command using those credentials:: fab setup_load_tester -i "ida_rsa" -H ubuntu@example.com That machine will provision itself. It may (depending on your vendor) prompt you a few times for a ``Y/n`` question. This is just asking you about increasing stroage space. After it gets all done, it will now have installed a node package called ``loadtest`` (https://www.npmjs.com/package/loadtest). Note: my examples will show HTTP only requests, but loadtest also supports websockets. To run the default loadtest setup, you can do the following, and the loadtest package will run for 90 seconds at a rate of 200 requests per second:: fab run_loadtest:http://127.0.0.1 -i "id_rsa" -H ubuntu@example.com Or if you want to exert some minor control, I've exposed a couple of parameters. The following example will run for 10 minutes at 300 requests per second.:: fab run_loadtest:http://127.0.0.1,rps=300,t=600 -i "id_rsa" -H ubuntu@example.com If you want more control, you can always pass in your own commands to:: fab shell -i "id_rsa" -H ubuntu@example.com