{"id":3699,"date":"2017-10-09T08:37:31","date_gmt":"2017-10-09T07:37:31","guid":{"rendered":"https:\/\/www.devco.net\/?p=3699"},"modified":"2017-10-09T08:37:31","modified_gmt":"2017-10-09T07:37:31","slug":"the-choria-emulator","status":"publish","type":"post","link":"https:\/\/www.devco.net\/archives\/2017\/10\/09\/the-choria-emulator.php","title":{"rendered":"The Choria Emulator"},"content":{"rendered":"
In my previous<\/a> posts<\/a> I discussed what goes into load testing a Choria network, what connections are made, subscriptions are made etc.<\/p>\n From this it’s obvious the things we should be able to emulate are:<\/p>\n 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.<\/p>\n 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:<\/p>\n You can see here it takes a number of instances, agents and collectives. The instances will all respond with ${name}-${instance}<\/em> on any mco ping or RPC commands. It can be discovered using the normal mc discovery – though only supports agent and identity filters.<\/p>\n 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.<\/p>\n The agents they start are all copies of this one:<\/p>\n 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<\/em> etc.<\/p>\n 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.<\/p>\n Here’s some example of commands – you’ll see these later again when we talk about scenarios:<\/p>\n We download the dependencies onto all our nodes:<\/p>\n We start NATS on our first node:<\/p>\n We start the emulator with 1500 instances per node all pointing to our above NATS:<\/p>\n 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.<\/p>\n 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.<\/p>\n 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.<\/p>\n\n
\r\nusage: choria-emulator --instances=INSTANCES [
\r\nemulated0\r\n=========\r\n\r\nChoria Agent emulated by choria-emulator\r\n\r\n Author: R.I.Pienaar
\r\n$ 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\r\n<\/pre>\n
\r\n$ mco playbook run start-nats.yaml --monitor 8300 --port 4300 -I test1.example.net\r\n<\/pre>\n
\r\n$ mco playbook run start-emulator.yaml --agents 10 --collectives 10 --instances 750 --monitor 8080 --servers 192.168.1.1:4300\r\n<\/pre>\n