webstack
A project to prototype web stacks source code
.--------------------------------------------------------------.
| API checks |
|--------------------------------------------------------------|
| stack | ok % | avg ms | p95 ms |
|-----------------------------------|--------|--------|--------|
| fly-go-tailscale-crunchy-replicas | 100.00 | 144 | 310 |
| fly-go-neon | 100.00 | 187 | 341 |
| heroku-go-crunchy | 99.99 | 198 | 354 |
| heroku-go-postgres | 99.99 | 218 | 336 |
| railway-go-neon | 100.00 | 255 | 465 |
| railway-go-postgres | 100.00 | 258 | 481 |
| railway-go-crunchy | 100.00 | 264 | 448 |
| render-go-neon | 100.00 | 265 | 485 |
| render-go-postgres | 99.99 | 273 | 545 |
'--------------------------------------------------------------'
Stacks have been deployed to:
- Heroku
- Fly.io
- Northflank
- Railway
- Render
- Vercel global edge functions and single-region serverless functions
Databases used have been:
- Postgres on Heroku, Fly, Northflank, Railway, Render
- Crunchy Bridge Postgres
- Supabase Postgres
- Cockroach serverless Postgres
- Neon serverless Postgres
- SQLite on Fly
- PlanetScale serverless MySQL
Each stack serves a healthcheck-style HTTP API endpoint that executes a
SELECT 1
to a SQL database and responds with JSON
{"status":"ok"}
. Each stack uses a lightweight router, a
SQL database driver (no ORM), and a database connection (often pooled).
Most stacks are written in Go. Example:
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"github.com/jackc/pgx/v4/pgxpool"
)
func main() {
// env
port, ok := os.LookupEnv("PORT")
if !ok {
port = "8080"
}
dbUrl, ok := os.LookupEnv("DATABASE_URL")
if !ok {
dbUrl = "postgres:///webstack_dev"
}
// db
db, err := pgxpool.Connect(context.Background(), dbUrl)
if err != nil {
log.Fatal(err)
}
defer db.Close()
// routes
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
var col int
db.QueryRow(r.Context(), "SELECT 1").Scan(&col)
w.Header().Set("Content-Type", "application/json")
fmt.Fprintf(w, "{\"status\":\"ok\"}")
})
// listen
log.Println("Listening at http://localhost:" + port)
log.Fatal(http.ListenAndServe(":"+port, nil))
}
Connecting to databases vary a little:
-
Neon, Crunchy Bridge, and Supabase all offer connection pooling via
PgBouncer, which I've enabled. See
Neon docs,
Crunchy Bridge docs, and
Supabase docs. In Neon and Supabase, you enable it with a web UI toggle. In
Crunchy Bridge, you enable it by `psql`'ing into your cluster and
running
CREATE EXTENSION crunchy_pooler;
. - Neon serverless Postgres uses a traditional TCP connection from Fly.io and single region Vercel serverless functions.
- Cockroach serverless Postgres also uses a traditional TCP connection from single region Vercel serverless functions.
- PlanetScale serverless MySQL uses an HTTP connection via their serverless driver for JavaScript and is executed from Vercel's global edge functions.