Vapor 3.0.0 released

VAPOR
VAPOR
May 5, 2018 · 6 min read

Vapor 3 is officially here! We have been working hard on this release for more than six months now and we are incredibly excited to release it into the world.

See the GitHub release here: https://github.com/vapor/vapor/releases/tag/3.0.0

As you probably know by now, 3.0 is a complete rewrite of Vapor and all of its related packages. It’s a big change. The growth of Vapor and server-side Swift over these past two years has been astonishing and we want to make sure we have a rock-solid foundation to build on for years to come. This has been our main focus this release and has lead to three important new features:

  • Async: Vapor is now completely non-blocking and runs on Apple’s SwiftNIO. This means Vapor 3 is ready to handle high levels of concurrency when your application needs it.
  • Services: Gone are the JSON configuration files. Everything is Swift now thanks to Vapor’s new Dependency Injection framework Services.
  • Codable: Parsing and serializing content from HTTP messages, creating database models, and rendering views is now more type safe and performant thanks to Codable integration throughout all of Vapor.

While those are the three biggest improvements, there are countless others. If you have used Vapor previously or you are just getting introduced, we recommend reading our new Getting Started guide.

Documentation

API Docs

  • Helpful code samples where possible.
  • Method parameter descriptions.
  • MARK and code re-org to help make things readable in API doc form.

The API docs are available at https://api.vapor.codes. Use the selector to choose which repo, module, and version you would like to view docs for.

Guide Docs

The Guide docs are available at https://docs.vapor.codes/3.0/ and there is a section for each of Vapor’s modules.

Discord

For more information about why we are making this move, see this post to #announcements.

Books

Benchmarks

If you find any errors in the configuration of one of the frameworks or how the benchmark was run, please notify us at benchmarks@vapor.codes we will update this article!

The benchmarks were run on two identical Digital Ocean droplets. One for hosting the frameworks and one for running the benchmark.

Digital Ocean droplets the benchmarks were run on.

The following command was used to run the benchmarks.

docker run -it witf .build/release/benchmarker wrk -t 8 -c 256 -d 10 -r 6 10.132.38.80

The benchmarker program is a small script written in Swift that runs wrk and captures the results. It is capable of doing multiple runs and averaging the results.

In human terms, the above benchmark means:

Run a 10 second test 6 times in a row using 8 threads and 256 connections.

The rules of the test (forked from tbrand/which_is_the_fastest) are simple:

Respond 200 OK to GET / with an empty body. A Date header must be included.

The benchmarker ensures these rules are met or the test fails.

Results

Web frameworks ranked by requests per second during a plaintext benchmark.

The second graph shows the average latency during the benchmark. The lower the better.

Web frameworks ranked by average latency during a plaintext benchmark.

Here are the actual results as printed by the benchmarker.

total requests:
#1 vapor (swift): 1202666 reqs
#2 perfect (swift): 1192318 reqs
#3 gin (go): 1008221 reqs
#4 kitura (swift): 641111 reqs
#5 express (node.js): 268176 reqs
#6 sinatra (ruby): 206693 reqs
#7 phoenix (elixir): 151975 reqs
#8 flask (python): 66672 reqs
#9 rails (ruby): 51524 reqs
#10 django (python): 47050 reqs
average latency:
#1 vapor (swift): 2420µs
#2 perfect (swift): 2596µs
#3 gin (go): 2936µs
#4 kitura (swift): 4631µs
#5 sinatra (ruby): 6220µs
#6 express (node.js): 9490µs
#7 phoenix (elixir): 17941µs
#8 rails (ruby): 22664µs
#9 flask (python): 24109µs
#10 django (python): 49053µs

We were pleasently surprised to see Vapor coming in first as being asynchronous does not really help with plaintext benchmarks. Plaintext benchmarks are really only good at testing how fast a web framework is capable of parsing and serializing HTTP headers. However, it is a good indication of the performance of Swift.

We will be releasing benchmarks that deal with more realistic server-side workloads such as CRUD operations on a database and view rendering when the related packages (Fluent and Leaf) are officially released.

Packages

Here is a list of all Vapor 3 compatible packages and latest version at time of writing. (Last updated August 17th, 2018).

  • Core: Utility package containing tools for byte manipulation, Codable, OS APIs, and debugging. (3.1.6)
  • Service: Dependency injection / inversion of control framework. (1.0.0)
  • Multipart: Parses and serializes multipart-encoded data with Codable support. (3.0.1)
  • URLEncodedForm: Parse and serialize url-encoded form data with Codable support. (1.0.0)
  • Routing: High-performance trie-node router. (3.0.1)
  • DatabaseKit: Core services for creating database integrations. (1.0.1)
  • SQL: Build SQL queries in Swift. Extensible, protocol-based design that supports DQL, DML, and DDL. (1.0.0)
  • HTTP: Non-blocking, event-driven HTTP built on Swift NIO. (3.0.5)
  • Console: APIs for creating interactive CLI tools. (3.0.1)
  • Crypto: Hashing (BCrypt, SHA2, HMAC), encryption (AES), public-key (RSA), and random data generation. (3.1.0)
  • Validation: Extensible data validation library (name, email, etc) (2.0.0)
  • TemplateKit: Easy-to-use foundation for building powerful templating languages in Swift. (1.0.0)
  • WebSocket: Non-blocking, event-driven WebSocket client and server built on Swift NIO. (1.0.1)
  • Vapor: A server-side Swift web framework. (3.0.0)
  • Redis: Non-blocking, event-driven Redis client. (3.0.0)
  • SQLite: SQLite 3 wrapper for Swift. (3.0.0)
  • PostgreSQL: Non-blocking, event-driven Swift client for PostgreSQL. (1.0.0)
  • MySQL: Pure Swift MySQL client built on non-blocking, event-driven sockets. (3.0.0)
  • Fluent: Swift ORM framework (queries, models, and relations) for building NoSQL and SQL database integrations. (3.0.0)
  • FluentSQLite: Swift ORM (queries, models, relations, etc) built on SQLite 3. (3.0.0)
  • FluentPostgreSQL: Swift ORM (queries, models, relations, etc) built on PostgreSQL. (1.0.0)
  • Auth: Authentication and Authorization layer for Fluent. (2.0.0)
  • JWT: JSON Web Token signing and verification. (3.0.0)
  • Leaf: An expressive, performant, and extensible templating language built for Swift. (3.0.0)

Packages will continue to roll out over the next weeks. Keep an eye on our Twitter @codevapor for details.

Website

More Information

Thank you

– Vapor Team

VAPOR

Written by

VAPOR

Creating modular server side software with Swift.