A very performant and light (2mb in memory) link shortener and tracker. Written in Rust and React and uses Postgres/SQLite.
1import http from "k6/http";
2import { check, sleep } from "k6";
3
4// Test configuration
5export const options = {
6 stages: [
7 { duration: "30s", target: 50 }, // Ramp up to 50 users
8 { duration: "1m", target: 50 }, // Stay at 50 users for 1 minute
9 { duration: "30s", target: 100 }, // Ramp up to 100 users
10 { duration: "1m", target: 100 }, // Stay at 100 users for 1 minute
11 { duration: "30s", target: 0 }, // Ramp down to 0 users
12 ],
13 thresholds: {
14 http_req_duration: ["p(95)<500"], // 95% of requests should be below 500ms
15 "checks{type:redirect}": ["rate>0.95"], // 95% success rate
16 },
17};
18
19const SHORTENED_URL = "http://localhost:8080/mikubeam";
20
21export default function () {
22 const res = http.get(SHORTENED_URL, {
23 tags: { type: "redirect" },
24 redirects: 0, // Don't follow redirects to measure just the redirect response
25 });
26
27 // Check if we got a redirect status (307)
28 check(
29 res,
30 {
31 "status is 307": (r) => r.status === 307,
32 "has location header": (r) => r.headers["Location"] !== undefined,
33 },
34 { type: "redirect" }
35 );
36
37 sleep(1); // Add some think time between requests
38}
39