Kest
Going to production
A checklist of the settings and habits that matter before real traffic arrives.
Kest is built for this, but a framework does not make an application safe by default. Work through this list before launch.
Configuration
- Put secrets in the environment or a secrets manager, never in the repository.
ConfigModulereads environment variables,.envfiles, YAML and JSON; listrequired = listOf("DATABASE_URL", "JWT_SECRET")so a missing value stops start-up instead of failing at 2 a.m. - Use a JWT secret of at least 32 random characters (or an RSA key pair).
- Use
forRootAsync { config: ConfigService -> ... }so modules are configured from the same place.
The HTTP server
app.http(NettyHttpAdapter(8080, maxBodyBytes = 2 shl 20, idleTimeoutSeconds = 60, http2 = true, sslContext = http2TlsContext(cert, key))) {
enableCors(CorsOptions(/* only your front end's origin */))
useSecurityHeaders()
useCompression()
useInterceptors(TimeoutInterceptor(10_000)) // 408 instead of a request that hangs forever
usePipes(ValidationPipe::class) // every request body is validated
}maxBodyBytescaps uploads in memory (default 1 MB); a bigger body is refused.- Terminate TLS at a load balancer or here; behind a proxy, keep it on the same private network.
- Shutdown is graceful: in-flight requests finish,
OnShutdownhooks run. Give your orchestrator a termination grace period of at least 10 seconds.
Security
- Protect routes with
@Authenticated(class or method) and@Roles; make open routes the exception with@Public. - Rate-limit with
throttler; usethrottler-redisonce you run more than one instance, or each instance counts alone. - Hash passwords with
PasswordHasher(argon2id or bcrypt need Bouncy Castle on the classpath). - With cookie sessions turn on
useCsrf(); store sessions in Redis (session-redis) when running several instances. - Documentation sandboxes (
api-docs,grpc-docs) let visitors call your API: switch the sandbox off or guard it in production. In GraphQL setexplorer = falseand keepmaxDepthandmaxComplexity.
Data
- Do not use
synchronize = true. Generate migrations (kestmigration commands, see Migrations) and run them on deploy. - Always page lists: take a
Pageableand returnPage<T>(Pagination); capmaxSize. - Size the connection pool for your instance count: total connections = pool size × instances must stay below the database's limit.
- Use
@Transactionalaround writes that must succeed together; index the columns you filter and sort by (@Index). - Publishing to a broker after a database write? Use the transactional outbox so the two cannot disagree.
Reliability
- Wrap calls to other services in
@CircuitBreaker,@TimeLimitand@Retry. - Make payment-like POSTs safe to retry with the
Idempotency-Keymiddleware (use a shared store when running several instances). - Run scheduled jobs on one instance with
@Locked(skipIfLocked = true)andlocks-redis. - Add
healthendpoints and point your load balancer at them.
Observability
- Log in JSON (the logger has a JSON mode) and ship the logs.
- Expose Prometheus
metricsandopentelemetrytraces. - Add error monitoring so you hear about 500s before your users tell you.
Scaling
One process uses every core (virtual threads). To scale further run more processes behind a load balancer; state that must be shared (sessions, rate-limit counters, queues, locks, caches) needs a shared store (Redis). See Running several instances.
Known limits
Be aware of what has not been proven:
- No published load-test results for your workload: run your own before launch. The benchmarks cover raw engine and ORM speed only.
- Offset pagination is slow on very deep pages; there is no cursor pagination yet.
- Spatial columns are tested on MySQL, not PostGIS. Table inheritance, GraphQL federation and a built-in AI module do not exist yet; see What is not built yet.
- OAuth providers (Google, GitHub, Microsoft) are tested against a local provider, not the real ones.