North-Seattle-College / ad440-winter2021-thursday-repo

NSC AD 440 Winter 2021 Thursday cohort practicum repo
Apache License 2.0
2 stars 27 forks source link

[Task] Run a Serverless Artillery Test on the users/iserId endpoing NO CACHE #313

Open nataliagourova opened 3 years ago

nataliagourova commented 3 years ago

Is your feature request related to a problem? Please describe. We are testing the API endpoint for user/userId with Serverless Artillery at 40 hits per second for 5 minutes, while having the CACHE toggle Off to compare the latency and other performance measures to the endpoint performance while having the CACHE toggle On

Describe the solution you'd like To achieve the objective, will run the test in CLI and document the results of the test, then compare

Describe alternatives you've considered Not applicable

Additional context

Date Activity Time Spent
03/20/2021 Research Task and Slsart Documentation 1 hours
03/23/2021 Set up the environment, run the test 2 hours
3/23/2021 Meeting with classmates, discussions, troubleshooting 3 hours
03/24/2021 Documentation 1 hour
Total 7 hours

STEPS AND RESOLUTION

  1. Install serverless artillery on the local machine in accordance with the documentation (requires prior installation of npm
    npm install -g serverless@1.38.0
    npm install -g serverless-artillery
  2. Supply the AWS credentials
    export AWS_ACCESS_KEY_ID=<yourKeyId>
    export AWS_SECRET_ACCESS_KEY=<yourKey>
  3. Save the script.yml document with specifications to your working folder:
    #Serverless Artillery Test for /users/{user_id} with 40 requests per second for 5 minutes
    config:
    target: "https://nsc-thursday-react-app.azureedge.net/users/3"
    phases:
    - duration: 300
      arrivalRate: 40
      name: "users/user_id test"
    scenarios:
    - flow:
      - get:
          url: "/api/users/3"
          json:
          as: "users.userid"
  4. Deploy the slsart function on AWS so that it can run the test on the specified target slsart deploy --stage <yourName> --region us-west-2
  5. Invoke the slsart function on AWS so that it can run the test on the specified target slsart invoke --stage <yourName --region us-west-2

Note: -m may be added to the invoke command to run a truncated version of the test, limited to 5 scenarios, like so: slsart invoke -m --stage <yourName> --region us-west-2 Note: for test requests that run over one minute, the results may not display in the terminal/cli window, but will be available after the test run is complete on the AWS site, in CloudWatch logs (search by the stage name)

  1. Results: -m test results: Invoking test Lambda

      {
          "errors": 0,
          "reports": [
              {
                  "timestamp": "2021-03-24T04:48:41.454Z",
                  "scenariosCreated": 5,
                  "scenariosCompleted": 5,
                  "requestsCompleted": 5,
                  "latency": {
                      "min": 30.8,
                      "max": 199.9,
                      "median": 32.2,
                      "p95": 199.9,
                      "p99": 199.9
                  },
                  "rps": {
                      "count": 5,
                      "mean": 0.96
                  },
                  "scenarioDuration": {
                      "min": 33.8,
                      "max": 362.1,
                      "median": 35.5,
                      "p95": 362.1,
                      "p99": 362.1
                  },
                  "scenarioCounts": {
                      "0": 5
                  },
                  "errors": {},
                  "codes": {
                      "200": 5
                  },
                  "matches": 0,
                  "customStats": {},
                  "phases": [
                      {
                          "pause": 0.20814359580386818
                      },
                      {
                          "duration": 1,
                          "arrivalRate": 1
                      },
                      {
                          "pause": 0.21215518176731415
                      },
                      {
                          "duration": 1,
                          "arrivalRate": 1
                      },
                      {
                          "pause": 0.17380108597347124
                      },
                      {
                          "duration": 1,
                          "arrivalRate": 1
                      },
                      {
                          "pause": 0.23287880195262947
                      },
                      {
                          "duration": 1,
                          "arrivalRate": 1
                      },
                      {
                          "pause": 0.2398683287552541
                      },
                      {
                          "duration": 1,
                          "arrivalRate": 1
                      }
                  ]
              }
          ],
          "totals": {
              "scenariosCreated": 5,
              "scenariosCompleted": 5,
              "requestsCompleted": 5,
              "codes": {
                  "200": 5
              },
              "errors": {}
          }
      }
    
          Your function invocation has completed.

Extended test results:

Screen Shot 2021-03-23 at 10 08 55 PM Screen Shot 2021-03-23 at 10 02 07 PM Screen Shot 2021-03-23 at 10 05 29 PM
  1. ☎️ DELETE AWS RESOURCES ☎️ run slsart remove --stage <yourName> --region us-west-2 command
  2. Conclusion: After comparison of the results with Cache turned on and off, we did not find significant differences. Further review of the endpoint code showed that the Cache On/Off functionality was not fully implemented for the endpoint.