Montréal JUG · Lightning Présentations Éclairs, épisode 2 · 29 mars 2023

Sablier

Scale to zero

github.com/sablierapp/sablier

Sablier, scale to zero

Alexis Couvreur

Fullstack Software Engineer

Working at the National Bank of Canada for SII Canada

Sablier, scale to zero

Reducing infrastructure costs boils down to turning apps off when you don’t use them

Sablier, scale to zero

Scaling to zero

Scaling to zero allows workloads to be run only when there is demand

Sablier, scale to zero

They scale to zero

  • Google Serverless (App Engine, Function)
  • AWS Lambda
  • Heroku
  • Github Codespace
  • And more!

Sablier, scale to zero

Sablier

A free and open source software scaling to zero solution

Sablier, scale to zero

How does it work?

Sablier, scale to zero

Reverse proxy integration

Sablier, scale to zero

How to use Sablier?

Let’s see its integration with Caddy!

Sablier, scale to zero

Without Sablier

docker-compose.yaml

services:
  proxy:
    image: caddy:2.6.4
    ports:
      - "8080:80"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro

  whoami:
    image: traefik/whoami:v1.12.0

Caddyfile

:80 {
  route /whoami {
    reverse_proxy whoami:80
  }
}
Sablier, scale to zero

With Sablier

docker-compose.yaml

services:
  proxy:
    image: caddy:local
    ports:
      - "8080:80"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro

  whoami:
    image: traefik/whoami:v1.12.0
    labels:
      - sablier.enable=true
      - sablier.group=demo

  sablier:
    image: sablierapp/sablier:1.19.1
    volumes:
      - '/var/run/docker.sock:/var/run/docker.sock'

Caddyfile

:80 {
  route /whoami {
    sablier http://sablier:10000 {
      group demo
      session_duration 1m
      dynamic {
        display_name Dynamic-Whoami
      }
    }
    reverse_proxy whoami:80
  }
}
Sablier, scale to zero

Demo

Sablier, scale to zero

Sablier features

Sablier, scale to zero

Providers

  • Docker
  • Docker Swarm
  • Kubernetes
  • Podman
  • AWS EC2

Sablier, scale to zero

Label filtering

  • Docker labels
  • Docker swarm service labels
  • Kubernetes deployments labels

Docker labels

services:
  whoami:
    image: traefik/whoami:v1.12.0
    labels:
      - sablier.enable=true
      - sablier.group=mygroup

Kubernetes deployments labels

apiVersion: apps/v1
kind: Deployment
metadata:
  name: whoami
  labels:
    app: whoami
    sablier.enable: "true"
    sablier.group: mygroup
Sablier, scale to zero

Reverse proxies

  • Traefik (Go)
  • Caddy (Go)
  • Nginx (Javascript/Lua/C)
  • more to come...

Sablier, scale to zero

Integration nightmare

Develop and maintain an integration for each reverse proxy

Sablier, scale to zero
  • Different APIs
  • Different languages (Go, C, Javascript, Lua)
    • Runtime plugin execution
    • Compilation plugin (recompile the proxy)
  • Breaking changes
  • Provider compatibility
  • Cloud native
Sablier, scale to zero

WebAssembly to the rescue

Sablier, scale to zero

WebAssembly (abbreviated Wasm) is a binary instruction format designed as a portable compilation target for programming languages, enabling deployment on the web for client and server applications.

Sablier, scale to zero

What is Web Assembly

  • Bytecode (almost native speed)
  • Compilation target for higher level languages (Rust, Go, C++...)
  • Runs in a sandboxed environment

Sablier, scale to zero

ProxyWasm

WebAssembly modules for reverse proxies

Sablier, scale to zero
Sablier, scale to zero

No more integration nightmare

Create one WASM Module to be used by all reverse proxies

Reverse proxy maintainers will have to develop and maintain one ProxyWasm extension

Sablier, scale to zero

Thank you!

Questions?