diff --git a/.github/workflows/on-version-tag.yml b/.github/workflows/on-version-tag.yml index 793d9f8..6f103fb 100644 --- a/.github/workflows/on-version-tag.yml +++ b/.github/workflows/on-version-tag.yml @@ -37,10 +37,16 @@ jobs: shell: bash run: echo ${{ secrets.GHCR_TOKEN }} | docker login ghcr.io -u ${{ secrets.GHCR_USERNAME }} --password-stdin - - name: Docker Build - shell: bash - run: docker build -f Dockerfile -t ghcr.io/ogxd/cacheus:latest -t ghcr.io/ogxd/cacheus:${{ github.ref_name }} . - - - name: Docker Push - shell: bash - run: docker push --all-tags ghcr.io/ogxd/cacheus \ No newline at end of file + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Docker Build and Push (Multi-Arch) + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ghcr.io/ogxd/cacheus:latest + ghcr.io/ogxd/cacheus:${{ github.ref_name }} \ No newline at end of file diff --git a/benches/baseline/README.md b/benches/baseline/README.md new file mode 100644 index 0000000..525fa8d --- /dev/null +++ b/benches/baseline/README.md @@ -0,0 +1,5 @@ +sh``` +docker compose up -d +k6 cloud login --token +k6 cloud run --local-execution script.js +``` \ No newline at end of file diff --git a/benches/baseline/docker-compose.yml b/benches/baseline/docker-compose.yml new file mode 100644 index 0000000..b769289 --- /dev/null +++ b/benches/baseline/docker-compose.yml @@ -0,0 +1,20 @@ +version: "3.9" +name: baseline-bench + +services: + proxy: + image: ghcr.io/ogxd/cacheus:latest + container_name: cacheus-proxy + ports: + - "8080:8080" + volumes: + - ./proxy.yml:/etc/cacheus.yml:ro + restart: unless-stopped + cpus: 2 + + hello: + image: hashicorp/http-echo + container_name: hello + command: "-text='Hello World'" + restart: unless-stopped + cpus: 1 # Does not need much since it's supposed to be cached anyway diff --git a/benches/baseline/proxy.yml b/benches/baseline/proxy.yml new file mode 100644 index 0000000..361531d --- /dev/null +++ b/benches/baseline/proxy.yml @@ -0,0 +1,19 @@ +listening_port: 8080 +prometheus_port: 5000 +https: false +http2: false +minimum_log_level: warn + +middlewares: + - use_cache: + cache_name: cache + - forward_request: + target_host: hello:5678 + +caches: + - in_memory: + name: cache + ttl_seconds: 60 + hash_path: true + hash_query: true + hash_body: false \ No newline at end of file diff --git a/benches/baseline/report.pdf b/benches/baseline/report.pdf new file mode 100644 index 0000000..11d3e4b Binary files /dev/null and b/benches/baseline/report.pdf differ diff --git a/benches/baseline/script.js b/benches/baseline/script.js new file mode 100644 index 0000000..546f723 --- /dev/null +++ b/benches/baseline/script.js @@ -0,0 +1,27 @@ +import http from 'k6/http'; + +export const options = { + discardResponseBodies: true, + cloud: { + projectID: 4565599, + name: 'Cacheus to Hello World', + }, + scenarios: { + contacts: { + executor: 'ramping-arrival-rate', + // Start iterations per `timeUnit` + startRate: 100, + // Start `startRate` iterations per minute + timeUnit: '1s', + // Pre-allocate necessary VUs. + preAllocatedVUs: 10000, + stages: [ + { target: 20000, duration: '5m' }, + ], + }, + }, +}; + +export default function() { + http.get('http://127.0.0.1:8080'); +} \ No newline at end of file diff --git a/benches/nginx/README.md b/benches/nginx/README.md new file mode 100644 index 0000000..525fa8d --- /dev/null +++ b/benches/nginx/README.md @@ -0,0 +1,5 @@ +sh``` +docker compose up -d +k6 cloud login --token +k6 cloud run --local-execution script.js +``` \ No newline at end of file diff --git a/benches/nginx/bench.sh b/benches/nginx/bench.sh new file mode 100644 index 0000000..3e349d6 --- /dev/null +++ b/benches/nginx/bench.sh @@ -0,0 +1,12 @@ +docker run -d --name nginx-cache -p 8080:80 -v $(pwd)/nginx.conf:/etc/nginx/nginx.conf:ro -v $(pwd)/cache:/var/cache/nginx nginx +k6 run script.js +docker stop nginx-cache +docker rm nginx-cache + +podman stats nginx-cache + +podman run -d --name cacheus -p 8081:80 -v $(pwd)/cacheus.yml:/etc/cacheus.yml ghcr.io/ogxd/cacheus:0.1.0 +docker run -d --name cacheus -p 8081:80 -v $(pwd)/cacheus.yml:/etc/cacheus.yml ghcr.io/ogxd/cacheus:0.1.0 + + +podman run -d --name nginx-cache -p 8080:80 -v $(pwd)/nginx.conf:/etc/nginx/nginx.conf:ro -v $(pwd)/cache:/var/cache/nginx docker.io/library/nginx \ No newline at end of file diff --git a/benches/nginx/docker-compose.yml b/benches/nginx/docker-compose.yml new file mode 100644 index 0000000..ad28a75 --- /dev/null +++ b/benches/nginx/docker-compose.yml @@ -0,0 +1,20 @@ +version: "3.9" +name: nginx-bench + +services: + proxy: + image: nginx:latest + container_name: nginx-proxy + ports: + - "8080:8080" + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf:ro + restart: unless-stopped + cpus: 2 + + hello: + image: hashicorp/http-echo + container_name: hello + command: "-text='Hello World'" + restart: unless-stopped + cpus: 1 # Does not need much since it's supposed to be cached anyway diff --git a/benches/nginx/nginx.conf b/benches/nginx/nginx.conf new file mode 100644 index 0000000..43752ed --- /dev/null +++ b/benches/nginx/nginx.conf @@ -0,0 +1,19 @@ +worker_processes 1; + +events { worker_connections 1024; } + +http { + proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=cache_zone:10m max_size=100m inactive=60m use_temp_path=off; + + server { + listen 8080; + + location / { + proxy_pass http://hello:5678; + proxy_cache cache_zone; + proxy_cache_valid 200 302 10m; + proxy_cache_valid 404 1m; + proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; + } + } +} \ No newline at end of file diff --git a/benches/nginx/report.pdf b/benches/nginx/report.pdf new file mode 100644 index 0000000..4189993 Binary files /dev/null and b/benches/nginx/report.pdf differ diff --git a/benches/nginx/script.js b/benches/nginx/script.js new file mode 100644 index 0000000..18901ae --- /dev/null +++ b/benches/nginx/script.js @@ -0,0 +1,27 @@ +import http from 'k6/http'; + +export const options = { + discardResponseBodies: true, + cloud: { + projectID: 4565599, + name: 'Nginx to Hello World', + }, + scenarios: { + contacts: { + executor: 'ramping-arrival-rate', + // Start iterations per `timeUnit` + startRate: 100, + // Start `startRate` iterations per minute + timeUnit: '1s', + // Pre-allocate necessary VUs. + preAllocatedVUs: 100, + stages: [ + { target: 20000, duration: '5m' }, + ], + }, + }, +}; + +export default function() { + http.get('http://127.0.0.1:8080'); +} \ No newline at end of file