Upgrade to Pro — share decks privately, control downloads, hide ads and more …

London Node.js Meetup - Artillery.io

London Node.js Meetup - Artillery.io

hassy veldstra

May 03, 2017
Tweet

More Decks by hassy veldstra

Other Decks in Programming

Transcript

  1. $ • DevOps contractor • Interested in resilience testing, fault-tolerant

    microservice architectures, chaos testing • Created Artillery
  2. Artillery.io • Load testing toolkit • Modern • Batteries-included, optimised

    for dev happiness • Simple and powerful • Open source
  3. What Problems Does Artillery Solve? 1)I want to see how

    my system reacts to load 2)I want to prepare my system for high load
  4. What Problems Does Artillery Solve? cont’d •I need to do

    load testing but JMeter makes me sad •I want something that’s written in Node.js
  5. What Problems Does Artillery Solve? cont’d •I need to do

    load testing but JMeter makes me sad •I want something that’s written in Node.js •I need to test WebSockets or Socket.io
  6. What Problems Does Artillery Solve? cont’d •I need to do

    load testing but JMeter makes me sad •I want something that’s written in Node.js •I need to test WebSockets or Socket.io •I want something that can be scripted with JS
  7. What Problems Does Artillery Solve? cont’d •I need to do

    load testing but JMeter makes me sad •I want something that’s written in Node.js •I need to test WebSockets or Socket.io •I want something that can be scripted with JS •I want something that can be used by everybody: QA team, SRE team, other dev teams
  8. Users Ministry Of Justice, Apigee, Autodesk, Lifx, Nordstrom, Rockwell Automation,

    Xero, SolarWinds and many many more (insurance, connected devices, healthcare, financial services, games)
  9. Community • 45 contributors • Community plugins for TeamCity, DataDog,

    InfluxDB, CloudWatch, AWS Sigv4 generation • Traffic recorder with Artillery output
  10. Community • 45 contributors • Community plugins for TeamCity, DataDog,

    InfluxDB, CloudWatch, AWS Sigv4 generation • Traffic recorder with Artillery output • Postman to Artillery converter
  11. How Artillery Models Load • Users arrive to use our

    API • Each user will execute a scenario, which is a sequence of steps, to interact with the API
  12. How Artillery Models Load • Users arrive to use our

    API • Each user will execute a scenario, which is a sequence of steps, to interact with the API • Users arrive in phases
  13. How Artillery Models Load • Users arrive to use our

    API • Each user will execute a scenario, which is a sequence of steps, to interact with the API • Users arrive in phases • Each user is completely independent of all other users
  14. How Artillery Models Load • Users arrive to use our

    API • Each user will execute a scenario, which is a sequence of steps, to interact with the API • Users arrive in phases • Each user is completely independent of all other users • Duration of a load test is the duration of the phases + the time it takes for all users to finish their scenarios
  15. Realistic Load Modeling • Users keep arriving regardless of whether

    other users have finished their scenarios or not
  16. Realistic Load Modeling • Users keep arriving regardless of whether

    other users have finished their scenarios or not • Individual users will execute their scenarios sequentially*, waiting for a response before continuing
  17. Realistic Load Modeling • Users keep arriving regardless of whether

    other users have finished their scenarios or not • Individual users will execute their scenarios sequentially*, waiting for a response before continuing • Each user will map to a new TCP connection (HTTP, WS, Socket.io)**
  18. Quick Demo #2 • Same test but with a scenario

    file • Reading the output • HTML report • JSON log for custom reporting and such
  19. Reading The Output • Percentiles • Usually the growth is

    interesting • Errors (e.g. ECONNRESET) and status codes >= 400 as well
  20. Request Chaining - post: url: “/session” json: username: “hassy” password:

    “londonnodejsmeetup” capture: - json: “$.accessToken” as: “accessToken”
  21. Hook functions • Just a Node module loaded by Artillery

    at runtime • Any exported function is available in the scenario
  22. Hook functions • Just a Node module loaded by Artillery

    at runtime • Any exported function is available in the scenario • Extension points:
  23. Hook functions • Just a Node module loaded by Artillery

    at runtime • Any exported function is available in the scenario • Extension points: • beforeScenario, afterScenario
  24. Hook functions • Just a Node module loaded by Artillery

    at runtime • Any exported function is available in the scenario • Extension points: • beforeScenario, afterScenario • beforeRequest, afterResponse
  25. Hook functions • Just a Node module loaded by Artillery

    at runtime • Any exported function is available in the scenario • Extension points: • beforeScenario, afterScenario • beforeRequest, afterResponse • As a step anywhere in the scenario
  26. Hook functions • Generate randomised data for your tests with

    Faker or Chance • Abort the test early if some condition is not satisfied
  27. Hook functions • Generate randomised data for your tests with

    Faker or Chance • Abort the test early if some condition is not satisfied • Make a call to an external service to fetch some information that the virtual user needs
  28. Performance • Multicore • 1,600 RPS on an 2.4GHz Intel

    Atom C2550 • Plenty fast for meaningful testing on cheap hardware
  29. Performance • Multicore • 1,600 RPS on an 2.4GHz Intel

    Atom C2550 • Plenty fast for meaningful testing on cheap hardware • Easy to set up on a cluster of beefy EC2 instances for massive tests
  30. Preparing For High Load • Set up a test environment

    • Set up monitoring • Base-level infrastructure monitoring - EC2 instance metrics, ECS metrics, ELBs, RDS databases (DataDog)
  31. Preparing For High Load • Set up a test environment

    • Set up monitoring • Base-level infrastructure monitoring - EC2 instance metrics, ECS metrics, ELBs, RDS databases (DataDog) • APM (NewRelic)
  32. Preparing For High Load • Set up a test environment

    • Set up monitoring • Base-level infrastructure monitoring - EC2 instance metrics, ECS metrics, ELBs, RDS databases (DataDog) • APM (NewRelic) • Connect Artillery to the monitoring solution (DataDog)
  33. Preparing For High Load cont’d • Formulate your objective /

    Know what question you’re trying to answer / Always have a hypothesis to test.
  34. Preparing For High Load cont’d • Formulate your objective /

    Know what question you’re trying to answer / Always have a hypothesis to test. • Keep a log!
  35. Preparing For High Load cont’d • Formulate your objective /

    Know what question you’re trying to answer / Always have a hypothesis to test. • Keep a log! • Share the findings with the rest of your team
  36. Staying Prepared • Load test regularly • Run load tests

    after deploying to a certain environment (e.g. uat)
  37. Staying Prepared • Load test regularly • Run load tests

    after deploying to a certain environment (e.g. uat) • Run load tests on a schedule (e.g. nightly) against a staging environment
  38. Things That Go Well With Artillery • Chrome DevTools -

    full-stack JS performance • Chaos Lambda - backends that laugh at failures and just keep going • Fault tolerance = code testing, load testing, chaos testing