From 0cecec13e26d3b35cb35570d0d9a342717f0b443 Mon Sep 17 00:00:00 2001 From: Luke Hagar Date: Mon, 12 Feb 2024 09:27:02 -0600 Subject: [PATCH] Swap from get and set to raw set --- bun-load-test.yaml | 32 ++++++++++++++++++++++++++++++++ functions/bun/src/main.ts | 14 +++++--------- functions/node/src/main.js | 12 +++--------- node-load-test.yaml | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 18 deletions(-) create mode 100644 bun-load-test.yaml create mode 100644 node-load-test.yaml diff --git a/bun-load-test.yaml b/bun-load-test.yaml new file mode 100644 index 0000000..38522bc --- /dev/null +++ b/bun-load-test.yaml @@ -0,0 +1,32 @@ +config: + target: http://bun.plygrnd.org + phases: + - duration: 60 + arrivalRate: 1 + rampTo: 10 + name: Warm up phase + - duration: 60 + arrivalRate: 10 + rampTo: 30 + name: Ramp up load + - duration: 30 + arrivalRate: 10 + rampTo: 30 + name: Spike phase + # Load & configure a couple of useful plugins + # https://docs.art/reference/extensions + plugins: + ensure: {} + apdex: {} + metrics-by-endpoint: {} + apdex: + threshold: 100 + ensure: + thresholds: + - http.response_time.p99: 100 + - http.response_time.p95: 75 +scenarios: + - flow: + - get: + url: "/" + \ No newline at end of file diff --git a/functions/bun/src/main.ts b/functions/bun/src/main.ts index 1edcb1e..86c1fd3 100644 --- a/functions/bun/src/main.ts +++ b/functions/bun/src/main.ts @@ -1,4 +1,4 @@ -import { Client , Databases } from 'node-appwrite'; +import { Client , Databases, ID } from 'node-appwrite'; // This is your Appwrite function // It's executed each time we get a request @@ -24,14 +24,10 @@ export default async ({ req, res, log, error }: any) => { // The `req` object contains the request data if (req.method === "GET") { - const doc = await databases.getDocument( - "metrics", - "load", - "65ca2f77931f5ebb7d19" - ); - log(doc["count"]); - await databases.updateDocument("metrics", "load", "65ca2f77931f5ebb7d19", {count: doc["count"] + 1}) - return res.send(`Count Updated`); + await databases.createDocument("load", "bun", ID.unique(), { + count: 1, + }); + return res.send(`Created Record`); } else { return res.send(`Invalid request method. Please use GET.`); } diff --git a/functions/node/src/main.js b/functions/node/src/main.js index 828a6c8..e695e89 100644 --- a/functions/node/src/main.js +++ b/functions/node/src/main.js @@ -24,16 +24,10 @@ export default async ({ req, res, log, error }) => { // The `req` object contains the request data if (req.method === "GET") { - const doc = await databases.getDocument( - "metrics", - "load", - "65ca2e4954a2e5c286d0" - ); - log(doc["count"]); - await databases.updateDocument("metrics", "load", "65ca2e4954a2e5c286d0", { - count: doc["count"] + 1, + await databases.createDocument("load", "node", ID.unique(), { + count: 1, }); - return res.send(`Count Updated`); + return res.send(`Created Record`); } else { return res.send(`Invalid request method. Please use GET.`); } diff --git a/node-load-test.yaml b/node-load-test.yaml new file mode 100644 index 0000000..c62ab37 --- /dev/null +++ b/node-load-test.yaml @@ -0,0 +1,32 @@ +config: + target: http://node.plygrnd.org + phases: + - duration: 60 + arrivalRate: 1 + rampTo: 10 + name: Warm up phase + - duration: 60 + arrivalRate: 10 + rampTo: 30 + name: Ramp up load + - duration: 30 + arrivalRate: 10 + rampTo: 30 + name: Spike phase + # Load & configure a couple of useful plugins + # https://docs.art/reference/extensions + plugins: + ensure: {} + apdex: {} + metrics-by-endpoint: {} + apdex: + threshold: 100 + ensure: + thresholds: + - http.response_time.p99: 100 + - http.response_time.p95: 75 +scenarios: + - flow: + - get: + url: "/" + \ No newline at end of file