In my previous posts I discussed what goes into load testing a Choria network, what connections are made, subscriptions are made etc.
From this it’s obvious the things we should be able to emulate are:
- Connections to NATS
- Subscriptions – which implies number of agents and sub collectives
- Message payload sizes
To make it realistically affordable to emulate many more machines that I have I made an emulator that can start numbers of Choria daemons on a single node.
I’ve been slowly rewriting MCollective daemon side in Go which means I already had all the networking and connectors available there, so a daemon was written:
usage: choria-emulator --instances=INSTANCES [<flags>] Emulator for Choria Networks Flags: --help Show context-sensitive help (also try --help-long and --help-man). --version Show application version. --name="" Instance name prefix -i, --instances=INSTANCES Number of instances to start -a, --agents=1 Number of emulated agents to start --collectives=1 Number of emulated subcollectives to create -c, --config=CONFIG Choria configuration file --tls Enable TLS on the NATS connections --verify Enable TLS certificate verifications on the NATS connections --server=SERVER ... NATS Server pool, specify multiple times (eg one:4222) -p, --http-port=8080 Port to listen for /debug/vars |
You can see here it takes a number of instances, agents and collectives. The instances will all respond with ${name}-${instance} on any mco ping or RPC commands. It can be discovered using the normal mc discovery – though only supports agent and identity filters.
Every instance will be a Choria daemon with the exact same network connection and NATS subscriptions as real ones. Thus 50 000 emulated Choria will put the exact same load of work on your NATS brokers as would normal ones, performance wise even with high concurrency the emulator performs quite well – it’s many orders of magnitude faster than the ruby Choria client anyway so it’s real enough.
The agents they start are all copies of this one:
emulated0 ========= Choria Agent emulated by choria-emulator Author: R.I.Pienaar <rip@devco.net> Version: 0.0.1 License: Apache-2.0 Timeout: 120 Home Page: http://choria.io Requires MCollective 2.9.0 or newer ACTIONS: ======== generate generate action: ---------------- Generates random data of a given size INPUT: size: Description: Amount of text to generate Prompt: Size Type: integer Optional: true Default Value: 20 OUTPUT: message: Description: Generated Message Display As: Message |
You can this has a basic data generator action – you give it a desired size and it makes you a message that size. It will run as many of these as you wish all called like emulated0 etc.
It has an mcollective agent that go with it, the idea is you create a pool of machines all with your normal mcollective on it and this agent. Using that agent then you build up a different new mcollective network comprising the emulators, federation and NATS.
Here’s some example of commands – you’ll see these later again when we talk about scenarios:
We download the dependencies onto all our nodes:
$ mco playbook run setup-prereqs.yaml --emulator_url=https://example.net/rip/choria-emulator-0.0.1 --gnatsd_url=https://example.net/rip/gnatsd --choria_url=https://example.net/rip/choria |
We start NATS on our first node:
$ mco playbook run start-nats.yaml --monitor 8300 --port 4300 -I test1.example.net |
We start the emulator with 1500 instances per node all pointing to our above NATS:
$ mco playbook run start-emulator.yaml --agents 10 --collectives 10 --instances 750 --monitor 8080 --servers 192.168.1.1:4300 |
You’ll then setup a client config for the built network and can interact with it using normal mco stuff and the test suite I’ll show later. Simularly there are playbooks to stop all the various parts etc. The playbooks just interact with the mcollective agent so you could use mco rpc directly too.
I found I can easily run 700 to 1000 instances on basic VMs – needs like 1.5GB RAM – so it’s fairly light. Using 400 nodes I managed to build a 300 000 node Choria network and could easily interact with it etc.
Finally I made a ec2 environment where you can stand up a Puppet Master, Choria, the emulator and everything you need and do load tests on your own dime. I was able to do many runs with 50 000 emulated nodes on EC2 and the whole lot cost me less than $20.
The code for this emulator is very much a work in progress as is the Go code for the Choria protocol and networking but the emulator is here if you want to take a peek.