Hi.
Iasi, April 2019,
OceanoBe
THE STATE OF SERVER-SIDE SWIFT
NSAgora - April 2019
NSAgora - April 2019 4
Contents
Introduction
Why Swift on the server?
Current Swift web server toolkits
Benchmarks
Q&A
4
NSAgora The state of server-side swift
I
II
III
IV

V
5
I
What is Swift?
INTRODUCTION
SWIFT?
whatis
SWIFT
whatis
NSAgora The state of server-side swift
SWIFT
whatis
NSAgora The state of server-side swift
SWIFT ISAMULTI-PARADIGM, COMPILED
LANGUAGE
WHAT
SWIFT
whatis
NSAgora The state of server-side swift
SWIFT ISAMULTI-PARADIGM, COMPILED
LANGUAGE
WHAT
THAT IS EXPRESSIVE, AND FOCUSES ON
SPEEDAND TYPE SAFETY
TYPING
SWIFT
whatis
NSAgora The state of server-side swift
SWIFT ISAMULTI-PARADIGM, COMPILED
LANGUAGE
WHAT
THAT IS EXPRESSIVE, AND FOCUSES ON
SPEEDAND TYPE SAFETY
TYPING
THAT IS BUILT USING THE LLVM COMPILER
LLVM
SWIFT
whatis
NSAgora The state of server-side swift
import Foundation
// Immutable array - type inferred to an array of Strings
let swiftProperties = ["multi-paradigm", "compiled", "expressive", "type-safe"]
// Function that accepts an optional parameter and returns an array of Int
func getDashedPropertiesLenghts(in array: [String]?) -> [Int] {
guard let properties = array else {
// Check if 'array' is nil and return and empty array
return []
}
// An array conforms to the 'Sequence' protocol
let filtered = properties.filter { property -> Bool in
return property.contains("-")
}

// Transform the array of Strings into an array of its members length
return filtered.map({ $0.count })
}
// Call the method
_ = getDashedPropertiesLenghts(in: swiftProperties)
SWIFTHISTORY
CHRISLATTNER
STARTSWORKING
ONNEWA
LANGUAGE@
APPLE
SWIFTHISTORY
2010
CHRISLATTNER
STARTSWORKING
ONNEWA
LANGUAGE@
APPLE
SWIFT
ANNOUNCEDAT
WWDC2014
SWIFTHISTORY
2010 2014
CHRISLATTNER
STARTSWORKING
ONNEWA
LANGUAGE@
APPLE
SWIFT
ANNOUNCEDAT
WWDC2014
SWIFT2.0IS
RELEASEDAND
OPENSOURCED
BYAPPLE
SWIFTHISTORY
2010 2014 2015
CHRISLATTNER
STARTSWORKING
ONNEWA
LANGUAGE@
APPLE
SWIFT
ANNOUNCEDAT
WWDC2014
SWIFT2.0IS
RELEASEDAND
OPENSOURCED
BYAPPLE
SWIFT3.0



IBMANDOTHER
COMPANIESTAKE
ONSWIFTONTHE
SERVERSIDE
SWIFTHISTORY
2010 2014 2015 2016
CHRISLATTNER
STARTSWORKING
ONNEWA
LANGUAGE@
APPLE
SWIFT
ANNOUNCEDAT
WWDC2014
SWIFT2.0IS
RELEASEDAND
OPENSOURCED
BYAPPLE
SWIFT3.0



IBMANDOTHER
COMPANIESTAKE
ONSWIFTONTHE
SERVERSIDE
SWIFT4.0



KITURA2.0

VAPOR2.0

PERFECT3.0
SWIFTHISTORY
2010 2014 2015 2016 2017
CHRISLATTNER
STARTSWORKING
ONNEWA
LANGUAGE@
APPLE
SWIFT
ANNOUNCEDAT
WWDC2014
SWIFT2.0IS
RELEASEDAND
OPENSOURCED
BYAPPLE
SWIFT3.0



IBMANDOTHER
COMPANIESTAKE
ONSWIFTONTHE
SERVERSIDE
SWIFT4.0



KITURA2.0

VAPOR2.0

PERFECT3.0
SWIFTHISTORY
SWIFTNIO
2010 2014 2015 2016 2017 2018
CHRISLATTNER
STARTSWORKING
ONNEWA
LANGUAGE@
APPLE
SWIFT
ANNOUNCEDAT
WWDC2014
SWIFT2.0IS
RELEASEDAND
OPENSOURCED
BYAPPLE
SWIFT3.0



IBMANDOTHER
COMPANIESTAKE
ONSWIFTONTHE
SERVERSIDE
SWIFT4.0



KITURA2.0

VAPOR2.0

PERFECT3.0
SWIFTHISTORY
SWIFTNIO
2010 2014 2015 2016 2017 2018
SWIFT5.0
SWIFTNIOHTTP2
2019
1010
SWIFT COMMUNITY EFFORTS
11
Since being made open source in December 2015
when it only supported Darwin machines, we have
seen an immense effort from the Swift community to
bring Swift to other platforms.
Up until now over 250 proposals have been accepted
and implemented in the Swift language and toolchain
and over 23,000 pull requests to make the Foundation
framework available on Linux.
It also runs down the other scale on Raspberry Pi and
considerable efforts are being made to make Swift
available for Android as well.
12
13
II
Why it makes sense to run Swift in the cloud.
WHY SWIFT ON THE
SERVER?
WEWANTOURAPPSTOBESAFEANDFAST
PERFORMACE
PERFORMANT APPLICATIONS
http://benchmarksgame.alioth.debian.org/u64q/spectralnorm.html
Duration(s)
0
4
8
12
16
Swift Java C# .NET Core NodeJS
PERFORMANT APPLICATIONS
http://benchmarksgame.alioth.debian.org/u64q/spectralnorm.html
Duration(s)
0
4
8
12
16
Swift Java C# .NET Core NodeJS
3,94
PERFORMANT APPLICATIONS
http://benchmarksgame.alioth.debian.org/u64q/spectralnorm.html
Duration(s)
0
4
8
12
16
Swift Java C# .NET Core NodeJS
4,383,94
PERFORMANT APPLICATIONS
http://benchmarksgame.alioth.debian.org/u64q/spectralnorm.html
Duration(s)
0
4
8
12
16
Swift Java C# .NET Core NodeJS
4,074,383,94
PERFORMANT APPLICATIONS
http://benchmarksgame.alioth.debian.org/u64q/spectralnorm.html
Duration(s)
0
4
8
12
16
Swift Java C# .NET Core NodeJS
15,79
4,074,383,94
PERFORMANT APPLICATIONS
http://benchmarksgame.alioth.debian.org/u64q/spectralnorm.html
http://benchmarksgame.alioth.debian.org/u64q/spectralnorm.html
WEWANTOURAPPSTOBECOSTEFFICIENT
MEMORYFOOTPRINT
MEMORY EFFICIENT
http://benchmarksgame.alioth.debian.org/u64q/spectralnorm.html
Memoryusage(MB)
0
10
20
30
40
Swift Java C# .NET Core NodeJS
MEMORY EFFICIENT
http://benchmarksgame.alioth.debian.org/u64q/spectralnorm.html
Memoryusage(MB)
0
10
20
30
40
Swift Java C# .NET Core NodeJS
9,7
MEMORY EFFICIENT
http://benchmarksgame.alioth.debian.org/u64q/spectralnorm.html
Memoryusage(MB)
0
10
20
30
40
Swift Java C# .NET Core NodeJS
35,4
9,7
MEMORY EFFICIENT
http://benchmarksgame.alioth.debian.org/u64q/spectralnorm.html
Memoryusage(MB)
0
10
20
30
40
Swift Java C# .NET Core NodeJS
32,6
35,4
9,7
MEMORY EFFICIENT
http://benchmarksgame.alioth.debian.org/u64q/spectralnorm.html
Memoryusage(MB)
0
10
20
30
40
Swift Java C# .NET Core NodeJS
31,932,6
35,4
9,7
MEMORY EFFICIENT
http://benchmarksgame.alioth.debian.org/u64q/spectralnorm.html
http://benchmarksgame.alioth.debian.org/u64q/spectralnorm.html
=
= 💰
SMALL BUSINESS COSTS
SMALL BUSINESS COSTS
STAFF
87 %
SMALL BUSINESS COSTS
OFFICE
11 %
STAFF
87 %
SMALL BUSINESS COSTS
HOSTING
2 %
OFFICE
11 %
STAFF
87 %
"
="
= 💰"
= 💰" 💰
= 💰" 💰💰
“Swift is fast enough, but what we care about is
developer productivity.”
TAKING IT FULL STACK
https://insights.stackoverflow.com/survey/2017
TAKING IT FULL STACK
WEB DEVELOPERS
FRONTEND
BACKEND
FULL STACK
https://insights.stackoverflow.com/survey/2017
TAKING IT FULL STACK
WEB DEVELOPERS
FRONTEND
BACKEND
FULL STACK
12 %
https://insights.stackoverflow.com/survey/2017
TAKING IT FULL STACK
WEB DEVELOPERS
FRONTEND
BACKEND
FULL STACK
24 %
12 %
https://insights.stackoverflow.com/survey/2017
TAKING IT FULL STACK
WEB DEVELOPERS
FRONTEND
BACKEND
FULL STACK 64 %
24 %
12 %
https://insights.stackoverflow.com/survey/2017
MODERN APPLICATION DESIGN
END USERS
CLIENT 

APPS
APP 

SERVICES
MODERN APPLICATION DESIGN
END USERS
CLIENT 

APPS
APP 

SERVICES
MODERN APPLICATION DESIGN
END USERS
CLIENT 

APPS
APP 

SERVICES
MODERN APPLICATION DESIGN
END USERS
CLIENT 

APPS
APP 

SERVICES
MODERN APPLICATION DESIGN
END USERS
CLIENT 

APPS
APP 

SERVICES
}INTEGRATED DEVELOPER
EXPERIENCE
25
III
What Swift web server toolkits are there available right now?
CURRENT SWIFT WEB SERVER
TOOLKITS
STANDARD

LIBRARY
SWIFT
CROSS-PLATFORM SWIFT
CONSISTENT ACROSS DARWIN AND LINUX
STANDARD

LIBRARY
FOUNDATION
SWIFT
CROSS-PLATFORM SWIFT
CONSISTENT ACROSS DARWIN AND LINUX
STANDARD

LIBRARY
FOUNDATION DISPATCH
SWIFT
CROSS-PLATFORM SWIFT
CONSISTENT ACROSS DARWIN AND LINUX
STANDARD

LIBRARY
FOUNDATION DISPATCH
SWIFT
CROSS-PLATFORM SWIFT
CONSISTENT ACROSS DARWIN AND LINUX
2727
SWIFT WEB SERVER TOOLKITS
28
There are a couple of Swift web toolkits available at
this point.
IBM continuously invests in Swift on the cloud as well
as in Kitura, their Swift web toolkit, but that's not all.
There are 3 more notable Swift toolkits out there with
Perfect, Vapor and Zewo and at least 20 other
projects.
29
PERFECT VAPOR KITURA ZEWO
30
https://medium.com/@rymcol/updated-benchmarks-for-the-top-server-side-swift-frameworks-vs-node-js-9da4a0491eca
31
IV
Ok, it is fast, but how fast?!
BENCHMARKS
ITIS
ITIS
FAST.
BUTHOWFAST?
BENCHMARKTESTS
ANDWERUNSOME
3636
WEB FRAMEWORKS BENCHMARK
37
To have a better idea of how well Swift
could do on the cloud we benchmarked
it against some of the most popular
toolkits available.
From all of the toolkits available we went
with Perfect because it fared the best
out of the available frameworks at this
moment.
To test how well it is doing we used two
DigitalOcean VM instances located in
Amsterdam.
38
38
WRK

INSTANCE
4 vCPUs
8 GB RAM

160 GB SSD
38
WRK

INSTANCE
BENCHMARKED

INSTANCE
4 vCPUs
8 GB RAM

160 GB SSD
4 vCPUs
8 GB RAM

160 GB SSD
38
WRK

INSTANCE
BENCHMARKED

INSTANCE
4 vCPUs
8 GB RAM

160 GB SSD
Private Network
4 vCPUs
8 GB RAM

160 GB SSD
38
WRK

INSTANCE
BENCHMARKED

INSTANCE
4 vCPUs
8 GB RAM

160 GB SSD
Private Network
4 vCPUs
8 GB RAM

160 GB SSD
40 $ / month each
39
39
1.JSON

Return a "{ hello: world }" JSON
39
1.JSON

Return a "{ hello: world }" JSON
2.COMPUTATION

Compute the 10.000th Fibonacci
number
39
1.JSON

Return a "{ hello: world }" JSON
2.COMPUTATION

Compute the 10.000th Fibonacci
number
3.LISTING

Return from a MySQL database all the
countries in the world in a JSON
39
1.JSON

Return a "{ hello: world }" JSON
2.COMPUTATION

Compute the 10.000th Fibonacci
number
3.LISTING

Return from a MySQL database all the
countries in the world in a JSON
https://github.com/cyupa/web-rest-api-benchmark
JSON
benchmark
JSON
benchmark
NSAgora April 2019
JSON
benchmark
NSAgora April 2019
JSON
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 17500 35000 52500 70000
wrk -t20 -c400 -d120s http://167.99.16.60:3000/hello
JSON
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 17500 35000 52500 70000
21.999
wrk -t20 -c400 -d120s http://167.99.16.60:3000/hello
JSON
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 17500 35000 52500 70000
35.288
21.999
wrk -t20 -c400 -d120s http://167.99.16.60:3000/hello
JSON
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 17500 35000 52500 70000
34.175
35.288
21.999
wrk -t20 -c400 -d120s http://167.99.16.60:3000/hello
JSON
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 17500 35000 52500 70000
63.066
34.175
35.288
21.999
wrk -t20 -c400 -d120s http://167.99.16.60:3000/hello
JSON
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 17500 35000 52500 70000
220
63.066
34.175
35.288
21.999
wrk -t20 -c400 -d120s http://167.99.16.60:3000/hello
JSON
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 17500 35000 52500 70000
2.243
220
63.066
34.175
35.288
21.999
wrk -t20 -c400 -d120s http://167.99.16.60:3000/hello
JSON
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 17500 35000 52500 70000
754
2.243
220
63.066
34.175
35.288
21.999
wrk -t20 -c400 -d120s http://167.99.16.60:3000/hello
COMPUTATION
benchmark
COMPUTATION
benchmark
NSAgora April 2019
COMPUTATION
benchmark
NSAgora April 2019
COMPUTATION
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 17500 35000 52500 70000
wrk -t20 -c400 -d120s http://167.99.16.60:3000/compute
COMPUTATION
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 17500 35000 52500 70000
20.310
wrk -t20 -c400 -d120s http://167.99.16.60:3000/compute
COMPUTATION
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 17500 35000 52500 70000
32.354
20.310
wrk -t20 -c400 -d120s http://167.99.16.60:3000/compute
COMPUTATION
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 17500 35000 52500 70000
29.943
32.354
20.310
wrk -t20 -c400 -d120s http://167.99.16.60:3000/compute
COMPUTATION
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 17500 35000 52500 70000
62.278
29.943
32.354
20.310
wrk -t20 -c400 -d120s http://167.99.16.60:3000/compute
COMPUTATION
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 17500 35000 52500 70000
107
62.278
29.943
32.354
20.310
wrk -t20 -c400 -d120s http://167.99.16.60:3000/compute
COMPUTATION
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 17500 35000 52500 70000
1.973
107
62.278
29.943
32.354
20.310
wrk -t20 -c400 -d120s http://167.99.16.60:3000/compute
COMPUTATION
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 17500 35000 52500 70000
245
1.973
107
62.278
29.943
32.354
20.310
wrk -t20 -c400 -d120s http://167.99.16.60:3000/compute
LISTING
benchmark
LISTING
benchmark
NSAgora April 2019
LISTING
benchmark
NSAgora April 2019
LISTING
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 400 800 1200 1600
wrk -t10 -c200 -d120s http://167.99.16.60:3000/hello
LISTING
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 400 800 1200 1600
1.410
wrk -t10 -c200 -d120s http://167.99.16.60:3000/hello
LISTING
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 400 800 1200 1600
1.330
1.410
wrk -t10 -c200 -d120s http://167.99.16.60:3000/hello
LISTING
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 400 800 1200 1600
484
1.330
1.410
wrk -t10 -c200 -d120s http://167.99.16.60:3000/hello
LISTING
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 400 800 1200 1600
316
484
1.330
1.410
wrk -t10 -c200 -d120s http://167.99.16.60:3000/hello
LISTING
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 400 800 1200 1600
102
316
484
1.330
1.410
wrk -t10 -c200 -d120s http://167.99.16.60:3000/hello
LISTING
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 400 800 1200 1600
647
102
316
484
1.330
1.410
wrk -t10 -c200 -d120s http://167.99.16.60:3000/hello
LISTING
benchmark
NSAgora April 2019
Spring
.NET Core
Node.JS
Perfect
Laravel
Lumen
Django
Requests / second
0 400 800 1200 1600
109
647
102
316
484
1.330
1.410
wrk -t10 -c200 -d120s http://167.99.16.60:3000/hello
ISSWIFTREADYFORPRODUCTIONGRADE
PROJECTS?
NOTYET.
NOTYET.
BUTIT'SGETTINGTHEREFAST.
INJUSTTHREEYEARSSINCEBECOMINGOPEN
SOURCE,SWIFTHASMADEAMAZINGPROGRESS
INARIVINGTOLINUXANDONTHESERVERSIDE
ANDITWILLSOONBEONEIMPORTANT
LANGUAGEFORBUILDINGCLOUDNATIVEAPPS.
AWS JUST LAUNCHED SMOKE FRAMEWORK
AWS JUST LAUNCHED SMOKE FRAMEWORK
4 DAYS AGO.
50
IV
Don't be shy to ask
Q&A
Thankyou!

The state of server-side Swift