Snapwake

DocsRunning your app

Networking

Your app's public URL

Every web app is reachable at https://<app>.snapwake.app as soon as its first version is live. Requests come through Cloudflare, which handles TLS, DDoS protection and the browser side of HTTP/2, then through Snapwake's edge, which knows which server your app lives on and fails over to the standby server.

Your app receives plain HTTP/1.1 on its port. Useful headers:

Header Value
Host, X-Forwarded-Host the host the client asked for, shop.snapwake.app
X-Forwarded-Proto https
CF-Connecting-IP the client's IP address
X-Forwarded-For earlier proxies, then a Cloudflare address

Use CF-Connecting-IP for the client's address. The TCP connection your app sees always comes from 127.0.0.1, because requests enter the VM through a local relay. Snapwake removes any X-Flare-* headers a client sends, as well as hop-by-hop headers such as Connection and Upgrade.

Limits on public requests

Time until the app starts answering 100 seconds, then the client gets 504 the app did not answer in time
Request headers 32 KB, sent within 10 seconds
Request and response bodies no limit of Snapwake's own; Cloudflare's limits apply
Protocols HTTP/1.1 and HTTP/2 from clients; no WebSockets yet
Reserved paths anything starting with /_flare gets 404 from the edge and never reaches your app

Responses stream: an app can send a large file or a server-sent events stream. Keep a stream from going quiet for 10 seconds or the app goes to sleep (Sleep and wake).

During a server failure

If the app's home server doesn't accept the connection, the request goes to the standby server, which wakes the app from its copy. The request reaches your app once; nothing is lost. If the home server dies after a request reached the app and before the app answered, GET, HEAD and OPTIONS requests without a body are sent again to the standby; other requests get a 502, because they may have had effects. Make non-idempotent endpoints safe to retry from the client if that matters to you.

Custom domains

Not available yet. They are planned for the Pro plan.

Calling your other apps

Your apps can call each other at http://<app>.internal:

JavaScript
const res = await fetch("http://api.internal/v1/orders");
  • It works between apps of the same organization only. Another organization's app doesn't resolve.
  • A sleeping app is woken by the call, the same way as by a public request.
  • It's HTTP only, on port 80; Snapwake forwards the request to the port the target app listens on. Send Host: <app>.internal, which every HTTP client does when you use the URL.
  • It works across servers: Snapwake routes the call to wherever the app lives, without leaving Snapwake's network.

Raw TCP between apps (connecting to a Postgres or Redis app you deployed yourself) is not available yet. Direct addresses for individual VMs are planned.

A VM can make up to 256 open connections and 200 new connections per second to other apps.

Outbound traffic

Apps can connect to anything on the internet, with these rules:

Rule
Port 25 (SMTP) blocked; use your email provider's API or port 587
Private and internal addresses (10/8, 172.16/12, 192.168/16, 100.64/10, 169.254/16, 127/8) blocked
IPv6 not available; connect over IPv4
Open connections per VM 2048
New connections per VM 100 per second, bursts up to 200
Bandwidth per VM 25 MB/s each way, bursts up to 50 MB/s

DNS inside the VM goes to Snapwake's resolver, which answers *.internal names and forwards everything else.

There is no fixed outbound IP address yet. If a database or API allows only listed addresses, it won't accept connections from Snapwake for now. Static outbound IPs are planned.

Postgres connection pool

An app that wakes from a snapshot finds its database connections closed and opens new ones on the first request: a TCP handshake, TLS, authentication, and a new server process on the database side. With an external database such as Neon or Supabase that costs tens to hundreds of milliseconds on every wake. The pool keeps connections open and authenticated on Snapwake's server while your app sleeps.

Turn it on with one secret:

Terminal
snapwake secret shop set FLARE_PG_POOL=1 DATABASE_URL=postgres://user:pass@db.example.com:5432/shop?sslmode=require
snapwake redeploy shop

Inside the app, DATABASE_URL then reads:

Output
postgresql://user@10.255.255.55:5432/shop?sslmode=disable

Connect with it as usual. The connection goes to the pool on the same server and is handed a ready connection to your database. Your app never sees the database password.

On our development machine this took 107 ms off the first request after a wake with TLS to the database, and 30 ms without TLS, with the database on the same machine. With a database across the internet the saving is larger.

How it behaves:

  • Each connection your app opens gets its own database connection for as long as it stays open (session pooling). When your app closes it, the pool closes the database side too and opens a fresh one in the background, so session state never leaks between connections.
  • It doesn't reduce the number of connections your database sees while the app is busy: one app connection is one database connection.
  • Startup parameters your driver sends (application_name, client_encoding, DateStyle and so on) are applied with SET. Replication connections and the options parameter are not supported.
  • Query cancellation works.
  • Towards your database, the pool uses the sslmode of your real DATABASE_URL. require, verify-ca and verify-full always verify the database's certificate against the system's trusted roots, which is stricter than libpq's require. With prefer, allow or no sslmode, TLS is used if the server offers it, with the same check. Authentication is SCRAM-SHA-256 or a plain password; MD5 is not supported.
  • The user and database name your app connects with must be the ones in the real URL.
  • Per VM: up to 64 open connections to the pool and 50 new ones per second.
  • Your database must have a public address.

Snapwake doesn't host Postgres yet. For a small database inside your app, see SQLite on a volume.