Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
'Server-side on Swift' by Volodymyr Shevchenko
CocoaHeads Ukraine
December 16, 2017
Programming
0
35
'Server-side on Swift' by Volodymyr Shevchenko
This talk was made for CocoaHeads Kyiv #13 which took place Dec 16 2017.
CocoaHeads Ukraine
December 16, 2017
Tweet
Share
More Decks by CocoaHeads Ukraine
See All by CocoaHeads Ukraine
Hacking iOS Simulator
cocoaheadsukraine
1
130
Dig into Value types. It's really obvious when to use them. Or not?!
cocoaheadsukraine
0
270
Классифицируем текст в iOS без CoreML: как и зачем?
cocoaheadsukraine
0
80
Managed side effects
cocoaheadsukraine
3
100
10 lines of encryption, 1500 lines of key management
cocoaheadsukraine
1
85
Мифический full-stack разработчик
cocoaheadsukraine
2
190
Анализ текста на скриншотах с Vision и CoreML
cocoaheadsukraine
0
63
Автоматизация регрессии аналитики
cocoaheadsukraine
0
47
Implementation of Clean Architecture using FRP
cocoaheadsukraine
0
58
Other Decks in Programming
See All in Programming
How useEvent would change our applications
koba04
1
1.8k
About Type Syntax Proposal
quramy
1
1.2k
SRE bridge the gap: Feature development to Core API / 機能開発チームとコアAPIチームの架け橋としてのSRE
kenzan100
1
370
機能横断型チームにおける技術改善
takeshiakutsu
3
480
Unity Localization で多言語対応実装しよう / xrdnk-yokohamaunity-lt10-20220513
xrdnk
0
160
Swift Concurrencyによる安全で快適な非同期処理
tattn
2
330
Micro Frontends with Module Federation: Beyond the Basics @codecrafts2022
manfredsteyer
PRO
0
120
実録mruby組み込み体験
coe401_
0
110
Microsoft Teams の 会議アプリ開発のはじめかた / How to start Microsoft Teams app development
karamem0
0
1.7k
A technique to implement DSL in Ruby
okuramasafumi
0
810
Quartoを使ってみませんか / quarto_get_started
s_uryu
2
350
코드 품질 1% 올리기
pluu
1
1k
Featured
See All Featured
The Power of CSS Pseudo Elements
geoffreycrofte
46
3.9k
The Web Native Designer (August 2011)
paulrobertlloyd
74
1.9k
Fantastic passwords and where to find them - at NoRuKo
philnash
25
1.5k
Six Lessons from altMBA
skipperchong
14
1.3k
How STYLIGHT went responsive
nonsquared
85
3.9k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
19
1.4k
How New CSS Is Changing Everything About Graphic Design on the Web
jensimmons
212
11k
Why Our Code Smells
bkeepers
PRO
324
54k
Side Projects
sachag
449
37k
Embracing the Ebb and Flow
colly
73
3.3k
A Modern Web Designer's Workflow
chriscoyier
689
180k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
100
5.9k
Transcript
Server-side on Swift by Volodymyr Shevchenko
What for? - We will do mobile better - Can’t
build App on our own - Backend is a black-box with API
Why Swift? ??
Why Swift? - we know Swift - we can reuse
some code - Swift is faster
Kitura Perfect Vapor Zewo What do we have:
⭐ GitHub Req/sec Looks Good? Kitura 6K 2.1K No Perfect
12.3K 4.2K Yes Vapor 11.6K 3.2K Yes Zewo 1.7K 1.7K No Benchmarks of the Top Server-Side Swift frameworks
Vapor Perfect
Let’s build something
Pet Store - Authorization - Domain CRUD - REST API
Check Local Credentials Create new User Check FB Credentials Create
Session Object Success? Facebook Database Cache Yes No ERROR response TOKEN response
Success? Database Cache Yes Proceed with request 401 response Fetch
session from Cache Fetch session from DB Success? No No Yes
User Pet Order Tag Category Domain relations *
Our stack: - Perfect as a framework - Mongo DB
as storage - StORM as ORM
Few words from Cap…
Leaks are evil
None
Crashes are evil
! Force unwrap is evil
Cocoapods Carthage SPM
XCode just an editor
≠
- this won’t compile on Linux: - after fix:
Foundation is NOT ported for 100% https://github.com/apple/swift-corelibs-foundation/blob/master/Docs/Status.md … …
≠ (curl + libssl) (curl + openssl)
[“a”, “b”, ”c”] -> “a, b, c” Bugs in MongoDBStORM
[“a”, “b”, ”c”] -> “a, b, c” - Work without
ORM - Switch to an other DB - Switch to Vapor + Fluent - Fix bug
Nested objects are MongoDBStORM not supported
¯\_(ツ)_/¯
Lets Deploy
Where?
Where? - Amazon EC2 - Microsoft Azure - Google Cloud
- Digital Ocean - Linode - Alibaba cloud - IBM cloud - Packet - Vultr - …
Where? - Amazon EC2 - Microsoft Azure - Google Cloud
- Digital Ocean - Linode - Alibaba cloud - IBM cloud - Packet - Vultr - …
How to deploy?
Perfect Assistant
Perfect Assistant
Docker
Plain
2) Connect to remote machine via SSH 3) Install all
required tools and libs 4) Setup Database server 5) Clone sources from Git repo 6) Compile 7) Configure firewall to allow http(s) traffic 8) Run executable 1) Create remote virtual machine on selected provider Plain Deploy
Performance - apib tool - Latency (MIN, MAX, AVG) -
Requests/second
Performance req/sec Lat, min Lat, max Lat, avg Healthcheck 26.8K
0.6 42 7.4 Empty Auth 739 9 643 269 Auth + Read 407 10.1 952 487 Auth + Write 389 9.4 1028 511
Scale - Vertical - Horizontal
Database is Server Database Server API Server Network
Scaled infrastructure Database Server API Server II API Server I
API Server III Load Balancer
0 500 1000 1500 2000 Empty Auth Auth + read
Auth + write Requests per second
0 150 300 450 600 Empty Auth Auth + read
Auth + write Average latency, ms
Cluster Performance req/sec Lat, min Lat, max Lat, avg Healthcheck
21.1K 1.4 1105 9.4 Empty Auth 1820 4.7 473 109 Auth + Read 897 3.1 243 55.6 Auth + Write 916 13 617 217.5
Questions?
Thanks!