Swift HTTP server using the pre-fork worker model

Related tags

Networking Curassow


Build Status

Curassow is a Swift Nest HTTP Server. It uses the pre-fork worker model and it's similar to Python's Gunicorn and Ruby's Unicorn.

It exposes a Nest-compatible interface for your application, allowing you to use Curassow with any Nest compatible web frameworks of your choice.


Full documentation can be found on the Curassow website: https://curassow.fuller.li


To use Curassow, you will need to install it via the Swift Package Manager, you can add it to the list of dependencies in your Package.swift:

import PackageDescription

let package = Package(
  name: "HelloWorld",
  dependencies: [
    .Package(url: "https://github.com/kylef/Curassow.git", majorVersion: 0, minor: 6),

Afterwards you can place your web application implementation in Sources and add the runner inside main.swift which exposes a command line tool to run your web application:

import Curassow
import Inquiline

serve { request in
  return Response(.ok, contentType: "text/plain", body: "Hello World")

Then build and run your application:

$ swift build --configuration release

Example Application

You can find a hello world example application that uses Curassow.


Curassow is licensed under the BSD license. See LICENSE for more info.

  • Curassow issues on Cloud Foundry

    Curassow issues on Cloud Foundry

    I had to downgrade to tag 0.2 for the app. to work on Cloud Foundry.

    The Hello World app (pinned to swift 2.2 but don't think that matters) is at


    and the Curassow tag 0.2 (for convenience) is at


    Am I missing something or is it a bug in master branch?

    opened by ragsns 12
  • Performance benchmark

    Performance benchmark

    Here is a simple benchmark result with wrk on my iMac 5K. Just Hello World. Compiled with swift build --configuration release. 4 workers.

    ~ wrk -c 1k -t 10 --timeout 5s --latency
    Running 10s test @
      10 threads and 1000 connections
      Thread Stats   Avg      Stdev     Max   +/- Stdev
        Latency     1.24ms    1.02ms  10.22ms   88.24%
        Req/Sec   557.81      1.17k    6.55k    94.44%
      Latency Distribution
         50%    1.16ms
         75%    1.50ms
         90%    1.96ms
         99%    5.96ms
      3818 requests in 10.10s, 371.77KB read
      Socket errors: connect 757, read 375, write 0, timeout 0
      Non-2xx or 3xx responses: 620
    Requests/sec:    377.98
    Transfer/sec:     36.80KB

    About half of the responses are [worker] Failed to decode data from client.

    opened by lexrus 10
  • Workers timeout when accessing request body

    Workers timeout when accessing request body

    When a request is received, something seems to be sticking when accessing the body's data. It's been reproducible on 0.5.0 100% for me.

    Swift Version: DEVELOPMENT-SNAPSHOT-2016-03-01-a

    Platform: osx

    Minimum Reproducible Example

    serve { req in
        var mutable = req
        print("Body: \(mutable.body?.next())") // will never get past this line
        return Inquiline.Response(.Ok, contentType: "text/html", content: "Did Stuff")

    Let me know if I'm doing something wrong here, everything else works, it only fails when I try to use next()

    opened by loganwright 9
  • Recommended debugging techniques

    Recommended debugging techniques

    I was wondering how you approach debugging Curassow (with lldb), since it forks off worker processes at the beginning and lldb doesn't support automatic following of forks.

    I found a very tedious way:

    • run your server in terminal window 1
    • in another window launch lldb for your binary
    • run attach WORKER_PID, which is visible when the server starts
    • continue as usual in the lldb instance, allowing to inspect the incoming requests in the debugger

    This will obviously get untenable as a codebase grows, so I'm wondering what your thoughts on this are.

    opened by czechboy0 6
  • Parse HTTP message body

    Parse HTTP message body

    I was trying to put together a slightly less trivial demo app and realized that there was no logic yet for reading in body data. This is a first pass at implementing that behavior. It only tries to read the body if the Content-Length header is present and doesn't try to deal with Transfer-Encoding at all, but this seems to be sufficient for the basic case that I'm looking for right now.

    opened by briancroom 5
  • Handling binary data

    Handling binary data

    If the body must be represented as a string (Nest spec), how would one respond with binary data? e.g. image/gif? I find myself wanting a more general representation like [UInt8], or even more general, something that can express itself as a sequence (streamable).

    For instance, Ruby's Rack just wants a body that responds to .each.

    opened by danneu 4
  • Update README.md

    Update README.md

    Not 100% sure how the Swift PM works just yet, but if you specify minor: 1, it won't download the latest release (e.g., 0.2.3). I'm assuming minor: 1 limits us to just 0.1.x.

    Came across this issue while trying to install Currasow for the first time via the Swift PM. Everything linked properly when I changed the minor version to 2.

    opened by ArtSabintsev 4
  • Package Manager with

    Package Manager with "12-18-b" Snapshot release of Swift fails to build Curassow


    I've had success building a small example app with the 12-01 Swift snapshot release, but the new 12-18 snapshot release appears to break building Curassow. I'm targeting the 0.2 release of Curassow in my package file, and it's the only dependency I directly declare. Below is the results of running swift build.

    I tracked this down to the SPM throwing an error in https://github.com/apple/swift-package-manager/blob/master/Sources/dep/Manifest+configureTargets.swift#L51 but I can't immediately see why this happens.

    $ swift build
    Cloning Packages/Curassow
    Using version 0.2.0 of package Curassow
    Cloning Packages/Nest
    Using version 0.2.1 of package Nest
    Cloning Packages/Inquiline
    Using version 0.2.2 of package Inquiline
    Cloning Packages/Commander
    Using version 0.4.0 of package Commander
    Compiling Swift Module 'Nest' (1 sources)
    Linking Library:  .build/debug/Nest.a
    Compiling Swift Module 'Inquiline' (3 sources)
    Linking Library:  .build/debug/Inquiline.a
    Compiling Swift Module 'Commander' (8 sources)
    Linking Library:  .build/debug/Commander.a
    swift-build: Your source structure is not supported due to conflicting directories: /path/to/project/Packages/Curassow-0.2.0

    Other data:

    OS: Ubuntu 14.04 (so I'm using the -b snapshot build)

    $ uname -a
    Linux ubuntu 3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
    $ swift --version
    Swift version 2.2-dev (LLVM 3ebdbb2c7e, Clang f66c5bb67b, Swift 0ddf238ad7)
    Target: x86_64-unknown-linux-gnu
    opened by stupergenius 4
  • Increased visibility of Arbiter.stop()

    Increased visibility of Arbiter.stop()

    We need public access to Arbiter.stop() in order to properly integrate as a server driver for Vapor as per https://github.com/qutheory/vapor-curassow-server/pull/1.

    opened by shnhrrsn 3
  • Simplify your Makefile

    Simplify your Makefile

    SPEC_FILES=$(foreach spec,$(SPECS),Tests/$(spec)Spec.swift)
    // add these
    LIB_FILES=$(shell ls .build/debug/*.a)
    STATIC_LIBS=$(foreach lib,$(LIB_FILES),-Xlinker $(lib))
    // modify your run-tests
        @$(SWIFTC) -o run-tests \
            Tests/main.swift \
            $(SPEC_FILES) \
            -I.build/debug \
    opened by ssoper 3
  • Prevent crashing due to SIGPIPE

    Prevent crashing due to SIGPIPE

    By default, calling send on a socket which has been closed on the remote end causes SIGPIPE to be sent to the process, which terminates it. These changes change the behavior to disable the signal, and instead make send return an error code if the socket has been closed.

    This situation arises frequently when deploying to Cloud Foundry, as its healthcheck process opens a connection to the app and then closes without sending any data.

    opened by briancroom 3
  • 0.6.1(Apr 7, 2017)

  • 0.5.0(Mar 5, 2016)

  • 0.4.1(Mar 5, 2016)


    • The WEB_CONCURRENCY environment variable can be used to configure the amount of workers.
    • The PORT environment variable can be used to configure the default listening port.
    • You can now daemonize Curassow via the --daemon option.
    Source code(tar.gz)
    Source code(zip)
  • 0.4.0(Feb 12, 2016)

  • 0.3.0(Jan 24, 2016)

  • 0.2.3(Jan 2, 2016)

  • 0.2.2(Dec 24, 2015)

  • 0.2.1(Dec 24, 2015)

  • 0.2.0(Dec 16, 2015)

    • Bodies of HTTP requests are now parsed and available to Nest callbacks.
    Bug Fixes
    • Fixes a crash in a worker if a client disconnects before we send a response to them.
    Source code(tar.gz)
    Source code(zip)
  • 0.1.3(Dec 11, 2015)

    • Curassow now parses request headers and exposes them in the request.
    Bug Fixes
    • Fixes a problem where some requests would fail to be decoded.
    Source code(tar.gz)
    Source code(zip)
  • 0.1.2(Dec 6, 2015)

    • Improved logger format which shows PID and time of event.
    Bug Fixes
    • Restores Linux compatibility, it was accidentally broken in the previous release by introducing OS X support.
    • Fixes a potential crash when Curassow failed to bind to a port.
    Source code(tar.gz)
    Source code(zip)
  • 0.1.1(Dec 6, 2015)

    • Adds support for OS X.

    • Allow dynamically changing the worker count using the TTIN and TTOU signals.
      To increase the worker count by one, where $PID is the PID of the master process.

      $ kill -TTIN $PID

      To decrease the worker count by one:

      $ kill -TTOU $PID
    Bug Fixes
    • Resolves a problem where some HTTP requests we're not getting passed.
    Source code(tar.gz)
    Source code(zip)
  • 0.1.0(Dec 6, 2015)

Kyle Fuller Archive
Older / Less maintained projects
Kyle Fuller Archive
Http - Demo for Http Layer

http Example To run the example project, clone the repo, and run pod install fro

null 0 Jan 24, 2022
A Swift web framework and HTTP server.

A Swift Web Framework and HTTP Server Summary Kitura is a web framework and web server that is created for web services written in Swift. For more inf

Kitura 7.6k Jan 6, 2023
Tiny http server engine written in Swift programming language.

What is Swifter? Tiny http server engine written in Swift programming language. Branches * stable - lands on CocoaPods and others. Supports the latest

null 3.6k Dec 31, 2022
Super lightweight async HTTP server library in pure Swift runs in iOS / MacOS / Linux

Embassy Super lightweight async HTTP server in pure Swift. Please read: Embedded web server for iOS UI testing. See also: Our lightweight web framewor

Envoy 540 Dec 15, 2022
A simple GCD based HTTP client and server, written in 'pure' Swift

SwiftyHTTP Note: I'm probably not going to update this any further - If you need a Swift networking toolset for the server side, consider: Macro.swift

Always Right Institute 116 Aug 6, 2022
libuv base Swift web HTTP server framework

Notice Trevi now open a Trevi Community. Yoseob/Trevi project split up into respective Trevi, lime, middlewares and sys packages at our community. If

leeyoseob 46 Jan 29, 2022
A very basic proof-of-concept Swift HTTP server that does not require Foundation

Swift Server Introduction This is very rough and basic HTTP server written in Swift without using Foundation. This is partially based on the Swifter r

Cezary Wojcik 55 Apr 27, 2022
A simple HTTP server written in Swift

http4swift http4swift is a tiny HTTP server library for Nest-compatible applications. This project is unstable, and the API might be changed at anytim

Shun Takebayashi 27 Jun 29, 2022
Lightweight, flexible HTTP server framework written in Swift

Hummingbird Lightweight, flexible server framework written in Swift. Hummingbird consists of three main components, the core HTTP server, a minimal we

Hummingbird 245 Dec 30, 2022
Postie - The Next-Level HTTP API Client using Combine

Postie - The Next-Level HTTP API Client using Combine Postie is a pure Swift library for building URLRequests using property wrappers.

kula 28 Jul 23, 2022
A slim implementation of a websocket server using Swift and Vapor 4.0.

Swift Websocket Server Example using Vapor 4.0 This project includes a minimum working example for a websocket server written in Swift. To interact wi

Adrian Hupka 5 Sep 22, 2022
Swift guarded model initializers for SwiftyJSON

GuardedSwiftyJSON Why should I use this? This library makes initializing models with JSON data with SwiftyJSON a lot easier. Often with SwiftyJSON I e

Will James 5 Mar 22, 2019
DBNetworkStack is a network abstraction for fetching request and mapping them to model objects

DBNetworkStack Main Features ?? Typed network resources ?? Value oriented architecture ?? Exchangeable implementations ?? Extendable API ?? Composable

DB Systel GmbH 33 Jan 10, 2022
A light weight network library with automated model parser for rapid development

Gem A light weight network library with automated model parser for rapid development. Managing all http request with automated model parser calls in a

Albin CR 10 Nov 19, 2022
An easy to integrate Model Based Google Maps Helper (SVHTTPClient, AFNetworking) That lets you Geo Code , Reverse Geocode, Get Directions , Places Autocomplete.

GoogleMapsHelper Read Me in Russian : http://gargo.of.by/googlemapshelper/ A GOOGLE MAPS Helper that help you do multiple tasks like HOW TO USE // usi

Zeeshan Haider 21 Jul 28, 2022
Elegant HTTP Networking in Swift

Alamofire is an HTTP networking library written in Swift. Features Component Libraries Requirements Migration Guides Communication Installation Usage

Alamofire 38.7k Jan 8, 2023
Swift HTTP for Humans

Just is a client-side HTTP library inspired by python-requests - HTTP for Humans. Features Just lets you to the following effortlessly: URL queries cu

Daniel Duan 1.4k Dec 30, 2022
Versatile HTTP Networking in Swift

Net is a versatile HTTP networking library written in Swift. ?? Features URL / JSON / Property List Parameter Encoding Upload File / Data / Stream / M

Intelygenz 124 Dec 6, 2022
🏇 A Swift HTTP / HTTPS networking library just incidentally execute on machines

Thus, programs must be written for people to read, and only incidentally for machines to execute. Harold Abelson, "Structure and Interpretation of Com

John Lui 845 Oct 30, 2022