SwiftX LogoSwiftX

Production Deployment

How to deploy your SwiftX application for production use.

Production Deployment

SwiftX is designed for high-performance and scalability. This guide will help you prepare and deploy your application to a production environment.

Release Build

Always use the release configuration when building your app for production. This enables all Swift compiler optimizations and optimizations within SwiftX itself.

swift build -c release

Running the Server

Once built, you can run the executable from the .build/release/ directory.

Environment Configuration

SwiftX natively loads .env files. Ensure your production environment variables are correctly set.

.env
PORT=80
ENV=production
DEBUG=false

Start-Up Command

Ensure you call app.start with the appropriate parameters for your host.

app.start(port: 80, threads: 8, development: false)

Advanced Deployment

Optimizing for Multiprocessing

Since SwiftX uses a Managed Worker Pool, increasing the threads parameter allows you to scale to higher CPU core counts.

// Example: Using all available CPU cores
app.start(threads: ProcessInfo.processInfo.processorCount)

On this page