%3CLINGO-SUB%20id%3D%22lingo-sub-1755030%22%20slang%3D%22en-US%22%3ERe%3A%20Vegeta%20Attack%20and%20Azure%20Container%20Instance%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1755030%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20article%20should%20get%20over%209000%20likes%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1759191%22%20slang%3D%22en-US%22%3ERe%3A%20Vegeta%20Attack%20and%20Azure%20Container%20Instance%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1759191%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20is%20a%20great%20tip%20and%20writeup%20well%20done.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1754254%22%20slang%3D%22en-US%22%3EVegeta%20Attack%20and%20Azure%20Container%20Instance%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1754254%22%20slang%3D%22en-US%22%3E%3CH2%20id%3D%22toc-hId--1239951699%22%20id%3D%22toc-hId--1239951727%22%3EAbstract%3C%2FH2%3E%3CP%3EThis%20is%20common%20mistake%20and%20observation.%20Most%20of%20the%20time%20customers%20ignore%20Load%20testing%20for%20their%20web%20based%20applications%20keeping%20too%20much%20trust%20on%20cloud%20scale%20infrastructure%20and%20services.%20It%20is%20good%20to%20trust%20on%20cloud%20scale%20model%20however%20not%20every%20application%20problem%20can%20be%20solved%20by%20just%20scaling%20underlying%20cloud%20infrastructure%20to%20support%20growing%20volume.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECloud%20scalability%20should%20be%20entrusted%20with%20proper%20testing%20framework%20for%20your%20application%20and%20this%20is%20where%20%E2%80%9Cload%20testing%E2%80%9D%20performs%20an%20important%20role.%20Load%20testing%20is%20really%20important%20to%20understand%20%E2%80%9Chow%20your%20application%20is%20performing%20under%20the%20expected%20load%2C%20unexpected%20load%2C%20sudden%20spiked%20load%E2%80%9D.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhile%20working%20with%20few%20of%20the%20big%20organizations%20in%20recent%20times%20I%20have%20observed%20%E2%80%9CLoad%20testing%E2%80%9D%20has%20been%20made%20too%20much%20of%20a%20complex%20thing%20to%20achieve.%20In%20reality%20it%20is%20simple%20if%20you%20do%20it%20in%20part%20and%20test%20individual%20components%20of%20the%20system.%20Most%20critical%20part%20of%20the%20today%E2%80%99s%20software%20systems%20is%20API%20layer.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20this%20post%20we%20will%20see%20how%20an%20Open%20Source%20Tool%20%E2%80%9CVegeta%E2%80%9D%20combined%20with%20power%20of%20Azure%20Container%20Instance%20can%20help%20you%20to%20test%20your%20individual%20APIs%20or%20web%20app.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELet%E2%80%99s%20attack!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CH2%20id%3D%22toc-hId-1247561134%22%20id%3D%22toc-hId-1247561106%22%3EWhat%20is%20Vegeta%3F%3C%2FH2%3E%3CP%3EVegeta%20is%20a%20versatile%20HTTP%20load%20testing%20tool%20built%20out%20of%20a%20need%20to%20drill%20HTTP%20services%20with%20a%20constant%20request%20rate.%20It%20can%20be%20used%20both%20as%20a%20command%20line%20utility%20and%20a%20library.%3C%2FP%3E%3CP%3ESource%3A%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Ftsenart%2Fvegeta%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Ftsenart%2Fvegeta%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20is%20written%20in%20Go%20language!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EVegeta%20seems%20to%20be%20quite%20popular%20and%20very%20active%20in%20OSS%20community.%20Github%20stars%20speak%20for%20itself!%20This%20tool%20have%20got%20stunning%2015.5K%20github%20stars%20as%20of%20writing.%20That%20is%20impressive!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20usage%20manual%20is%20on%20Github%20and%20official%20docker%20image%20is%20also%20present%20here%20-%20%3CA%20href%3D%22https%3A%2F%2Fhub.docker.com%2Fr%2Fpeterevans%2Fvegeta%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EVegeta%20Docker%20Official%20Image%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CH2%20id%3D%22toc-hId--559893329%22%20id%3D%22toc-hId--559893357%22%3EWhy%20Azure%20Container%20Instance%20for%20load%20testing%3F%3C%2FH2%3E%3CP%3EMost%20of%20the%20load%20testing%20tools%20I%20have%20seen%20uses%20VM%20based%20solution%2C%20or%20Kubernetes%20based%20solution%20in%20today%E2%80%99s%20world.%20Ideally%20load%20test%20may%20not%20be%20required%20to%20run%2024x7x365.%20It%20is%20momentary%20to%20test%20the%20system%20and%20you%20will%20always%20want%20your%20infra%20to%20shutdown%2F%20removed%20after%20testing%20is%20done.%20This%20is%20where%20Azure%20container%20instance%20fits%20perfectly.%20Below%20are%20few%20more%20benefits%20I%20see%20-%3C%2FP%3E%3COL%3E%3CLI%3EWhen%20you%20use%20VM%2C%20some%20part%20of%20compute%20%5Bcores%5D%20and%20memory%20%5BRAM%5D%20is%20still%20used%20with%20VM%20functioning%20%5BOS%20operations%5D%20and%20you%20don%E2%80%99t%20get%20full%20capacity%20of%20underlying%20VM%20for%20load%20testing.%20With%20container%20instance%20if%20you%20assign%201%20core%202GB%20memory%20then%20complete%20capacity%20is%20used%20only%20for%20load%20testing.%3C%2FLI%3E%3CLI%3EWhile%20you%20can%20automate%20VM%20shutdown%2F%20start%20etc.%20if%20it%20is%20missed%20then%20cost%20is%20still%20incurred.%20Container%20instance%20is%20charged%20per%20second%20and%20as%20soon%20as%20it%20is%20terminated%20there%20is%20no%20charge.%20This%20makes%20very%20cost%20effective%20solution%20for%20incremental%20load%20testing.%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CH2%20id%3D%22toc-hId-1927619504%22%20id%3D%22toc-hId-1927619476%22%3ESingle%20URL%20testing%20with%20Vegeta%20and%20Azure%20Container%20Instance%3C%2FH2%3E%3CP%3EGo%20to%20Azure%20portal%20and%20provision%20the%20Azure%20container%20Instance.%20Make%20sure%20you%20specify%20the%20docker%20URL%20of%20Vegeta%20as%20sown%20below%20%E2%80%93%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Create%20Vegeta%201.png%22%20style%3D%22width%3A%20870px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F224832i0CCA4910BEAC17E2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Create%20Vegeta%201.png%22%20alt%3D%22Create%20Vegeta%20-%20specify%20vegeta%20docker%20image%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ECreate%20Vegeta%20-%20specify%20vegeta%20docker%20image%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EKeep%20the%20default%20setting%20on%20networking%20tab%20and%20move%20to%20Advanced%20tab.%20On%20the%20advanced%20tab%20we%20have%20an%20option%20to%20specify%20first%20commands%20to%20execute%20in%20container.%20The%20main%20purpose%20of%20this%20option%20is%20to%20provide%20defaults%20to%20an%20executing%20container.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20more%20of%20docker%20feature%20than%20container%20instance.%3C%2FP%3E%3CP%3EThis%20is%20where%20we%20will%20provide%20below%20command%20to%20start%20the%20Vegeta%20Attack%20to%20URL%20of%20our%20choice.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3E%22sh%22%2C%20%22-c%22%2C%20%22echo%20'GET%20https%3A%2F%2Fwww.sanganakauthority.com%2F'%20%7C%20vegeta%20attack%20-duration%3D10s%20-rate%3D10%20%7C%20tee%20results.bin%20%7C%20vegeta%20report%22%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20above%20command%20we%20are%20hitting%20my%20personal%20blog%20for%20continuous%2010%20seconds%2C%20with%2010%20requests%20per%20second.%20storing%20the%20result%20in%20results.bin%20file.%3C%2FP%3E%3CP%3EGo%20ahead%20and%20create%20the%20container%20instance.%20Refer%20to%20screenshot%20below%20for%20command%20view%20%E2%80%93%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Create%20Vegeta%202.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F224833i39CF0F2F04F53C95%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Create%20Vegeta%202.png%22%20alt%3D%22Specify%20Vegeta%20command%20in%20advanced%20tab%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ESpecify%20Vegeta%20command%20in%20advanced%20tab%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20container%20is%20created%20and%20terminated%20after%2010%20seconds%20of%20execution.%20If%20we%20click%20on%20Log%20as%20directly%20see%20the%20output%20of%20results.bin%20file%20as%20shown%20below%20%E2%80%93%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22report%201.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F224834i46262100A059A1AE%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22report%201.png%22%20alt%3D%22Vegeta%20output%20on%20shell%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EVegeta%20output%20on%20shell%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EImportant%20aspect%20to%20record%20from%20this%20load%20test%20result%20is%20min%20latency%20as%2043.351%20ms%20and%20max%20latency%20recorded%20was%20573.565.ms.%20The%20total%20success%20rate%20is%20100%25.%20Means%20all%20the%20requests%20that%20were%20sent%20for%20testing%20all%20of%20them%20were%20successful.%20Similarly%20status%20code%20is%20200.%20This%20is%20where%20you%20can%20see%20how%20many%20request%20were%20successful%20and%20how%20many%20of%20them%20were%20non%20200.%20Also%20if%20any%20error%20is%20generated%20then%20error%20text%20is%20shown%20at%20the%20bottom.%20In%20our%20case%20there%20is%20no%20error%20received.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENeed%20less%20to%20say%2C%20you%20are%20charged%20only%20for%20duration%20of%2010%20seconds%20along%20with%20CPU%20and%20memory%20consumed.%20Pretty%20cool!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CH2%20id%3D%22toc-hId-120165041%22%20id%3D%22toc-hId-120165013%22%3EVegeta%20attack%20output%20in%20JSON%20on%20container%20instance%3C%2FH2%3E%3CP%3EThe%20above%20output%20we%20received%20in%20shell.%20Most%20of%20the%20time%20you%20may%20want%20to%20receive%20the%20output%20in%20JSON%20to%20consume%20into%20some%20other%20reporting%20systems.%20You%20can%20output%20the%20Vegeta%20attack%20in%20JSON%20as%20follows%20%E2%80%93%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3E%22sh%22%2C%20%22-c%22%2C%20%22echo%20'GET%20https%3A%2F%2Fwww.sanganakauthority.com%2F'%20%7C%20vegeta%20attack%20-duration%3D10s%20-rate%3D10%20%7C%20tee%20results.bin%20%7C%20vegeta%20report%20-type%3Djson%22%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Json%20report.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F224835iDBCEB25622E61321%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Json%20report.png%22%20alt%3D%22Vegeta%20json%20output%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EVegeta%20json%20output%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CH2%20id%3D%22toc-hId--1687289422%22%20id%3D%22toc-hId--1687289450%22%3EVegeta%20Attack%2C%20and%20authentication%20header%20on%20container%20instance%3C%2FH2%3E%3CP%3EVegeta%20attack%20can%20also%20be%20used%20to%20load%20test%20APIs%20which%20require%20an%20authentication%20token.%20Refer%20to%20below%20command%20that%20can%20be%20used%20with%20Azure%20container%20instance%20to%20load%20test%20APIS%20with%20authentication%20header%20%E2%80%93%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3E%22sh%22%2C%20%22-c%22%2C%20%22echo%20'GET%20https%3A%2F%2Fmyapi.com'%20%7C%20vegeta%20attack%20-header%20%22authorization%3A%20Bearer%20%3CYOUR-TOKEN-HERE%3E%22%20-duration%3D10s%20-rate%3D10%26nbsp%3B%20%7C%20tee%20results.bin%20%7C%20vegeta%20report%22%3C%2FYOUR-TOKEN-HERE%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CH3%20id%3D%22toc-hId--996727948%22%20id%3D%22toc-hId--996727976%22%3E%3CSTRONG%3EUse%20case%3C%2FSTRONG%3E%3C%2FH3%3E%3CP%3EYou%20have%20an%20api%20hosted%20behind%20Azure%20API%20management.%20You%20want%20to%20perform%20load%20test%20for%20your%20Azure%20API%20Management%20link%20which%20required%20subscription%20key%20in%20the%20header.%20This%20is%20where%20we%20can%20use%20Authentication%20header%20based%20Vegeta%20attack%20as%20below%20%E2%80%93%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3E%22sh%22%2C%20%22-c%22%2C%20%22echo%20'GET%20https%3A%2F%2Fmyapi.com'%20%7C%20vegeta%20attack%20-header%20%22%20Ocp-Apim-Subscription-Key%3A%20%3CYOUR-AZURE%20api-management-subscription-key-here%3D%22%22%3E%22%20-duration%3D10s%20-rate%3D10%26nbsp%3B%20%7C%20tee%20results.bin%20%7C%20vegeta%20report%22%3C%2FYOUR-AZURE%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESimilarly%20this%20can%20be%20used%20for%20load%20testing%20with%20Azure%20API%20Management%20configured%20with%20%E2%80%9CValidate%20JWT%E2%80%9D%20policy.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CH2%20id%3D%22toc-hId--1007231052%22%20id%3D%22toc-hId--1007231080%22%3EConclusion%3C%2FH2%3E%3CP%3EVegeta%20attack%20with%20Azure%20Container%20instance%20is%20the%20most%20flexible%20way%20of%20load%20testing%20in%20my%20opinion.%20Above%20post%20just%20demonstrate%20the%20same.%20Hope%20you%20find%20this%20useful.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1754254%22%20slang%3D%22en-US%22%3E%3CP%3ETest%20your%20APIs%20sustenance%20power.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22camel-897967__480.jpg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F224831iD33360D53F6240B1%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22camel-897967__480.jpg%22%20alt%3D%22camel-897967__480.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1754254%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EApps%20%26amp%3B%20DevOps%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EContainer%20Instances%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Eload%20testing%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Eopen%20source%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Senior Member

Abstract

This is common mistake and observation. Most of the time customers ignore Load testing for their web based applications keeping too much trust on cloud scale infrastructure and services. It is good to trust on cloud scale model however not every application problem can be solved by just scaling underlying cloud infrastructure to support growing volume.

 

Cloud scalability should be entrusted with proper testing framework for your application and this is where “load testing” performs an important role. Load testing is really important to understand “how your application is performing under the expected load, unexpected load, sudden spiked load”.

 

While working with few of the big organizations in recent times I have observed “Load testing” has been made too much of a complex thing to achieve. In reality it is simple if you do it in part and test individual components of the system. Most critical part of the today’s software systems is API layer.

 

In this post we will see how an Open Source Tool “Vegeta” combined with power of Azure Container Instance can help you to test your individual APIs or web app.

 

Let’s attack!

 

What is Vegeta?

Vegeta is a versatile HTTP load testing tool built out of a need to drill HTTP services with a constant request rate. It can be used both as a command line utility and a library.

Source: https://github.com/tsenart/vegeta

 

It is written in Go language!

 

Vegeta seems to be quite popular and very active in OSS community. Github stars speak for itself! This tool have got stunning 15.5K github stars as of writing. That is impressive!

 

The usage manual is on Github and official docker image is also present here - Vegeta Docker Official Image

 

Why Azure Container Instance for load testing?

Most of the load testing tools I have seen uses VM based solution, or Kubernetes based solution in today’s world. Ideally load test may not be required to run 24x7x365. It is momentary to test the system and you will always want your infra to shutdown/ removed after testing is done. This is where Azure container instance fits perfectly. Below are few more benefits I see -

  1. When you use VM, some part of compute [cores] and memory [RAM] is still used with VM functioning [OS operations] and you don’t get full capacity of underlying VM for load testing. With container instance if you assign 1 core 2GB memory then complete capacity is used only for load testing.
  2. While you can automate VM shutdown/ start etc. if it is missed then cost is still incurred. Container instance is charged per second and as soon as it is terminated there is no charge. This makes very cost effective solution for incremental load testing.

 

Single URL testing with Vegeta and Azure Container Instance

Go to Azure portal and provision the Azure container Instance. Make sure you specify the docker URL of Vegeta as sown below –

 

Create Vegeta - specify vegeta docker imageCreate Vegeta - specify vegeta docker image

 

Keep the default setting on networking tab and move to Advanced tab. On the advanced tab we have an option to specify first commands to execute in container. The main purpose of this option is to provide defaults to an executing container.

 

This is more of docker feature than container instance.

This is where we will provide below command to start the Vegeta Attack to URL of our choice.

 

 

 

"sh", "-c", "echo 'GET https://www.sanganakauthority.com/' | vegeta attack -duration=10s -rate=10 | tee results.bin | vegeta report"

 

 

 

In above command we are hitting my personal blog for continuous 10 seconds, with 10 requests per second. storing the result in results.bin file.

Go ahead and create the container instance. Refer to screenshot below for command view –

 

Specify Vegeta command in advanced tabSpecify Vegeta command in advanced tab

 

The container is created and terminated after 10 seconds of execution. If we click on Log as directly see the output of results.bin file as shown below –

 

Vegeta output on shellVegeta output on shell

 

Important aspect to record from this load test result is min latency as 43.351 ms and max latency recorded was 573.565.ms. The total success rate is 100%. Means all the requests that were sent for testing all of them were successful. Similarly status code is 200. This is where you can see how many request were successful and how many of them were non 200. Also if any error is generated then error text is shown at the bottom. In our case there is no error received.

 

Need less to say, you are charged only for duration of 10 seconds along with CPU and memory consumed. Pretty cool!

 

Vegeta attack output in JSON on container instance

The above output we received in shell. Most of the time you may want to receive the output in JSON to consume into some other reporting systems. You can output the Vegeta attack in JSON as follows –

 

 

 

"sh", "-c", "echo 'GET https://www.sanganakauthority.com/' | vegeta attack -duration=10s -rate=10 | tee results.bin | vegeta report -type=json"

 

 

 

Vegeta json outputVegeta json output

 

Vegeta Attack, and authentication header on container instance

Vegeta attack can also be used to load test APIs which require an authentication token. Refer to below command that can be used with Azure container instance to load test APIS with authentication header –

 

 

 

"sh", "-c", "echo 'GET https://myapi.com' | vegeta attack -header "authorization: Bearer <your-token-here>" -duration=10s -rate=10  | tee results.bin | vegeta report"

 

 

 

Use case

You have an api hosted behind Azure API management. You want to perform load test for your Azure API Management link which required subscription key in the header. This is where we can use Authentication header based Vegeta attack as below –

 

 

 

"sh", "-c", "echo 'GET https://myapi.com' | vegeta attack -header " Ocp-Apim-Subscription-Key: <your-Azure API-Management-subscription-key-here>" -duration=10s -rate=10  | tee results.bin | vegeta report"

 

 

 

Similarly this can be used for load testing with Azure API Management configured with “Validate JWT” policy.

 

Conclusion

Vegeta attack with Azure Container instance is the most flexible way of load testing in my opinion. Above post just demonstrate the same. Hope you find this useful.

 

2 Comments
Frequent Contributor

This article should get over 9000 likes :)

Microsoft

This is a great tip and writeup well done.