Benchmarks: Vapor 2 vs. Vapor 1
After migrating my pet project from Vapor 1 to Vapor 2 I've run benchmarks to compare performance. I didn't run benchmarks for the last version of Vapor 1.x which is 1.5.15 so I will compare Vapor 2.1.0 to results of Vapor 1.2.5 that I have from my last results.
My server:
- 2 GB RAM
- 1 CPU Core
- SSD
- 125 MBPS Out
- Ubuntu 16.04.2 LTS
- CouchDB
Benchmark from other server was launched as:
wrk -t4 -c20 -d5m https://my_url
API just gets some data from CouchDB and returns it as JSON. Vapor project has been compiled with Swift 3.1.1.
Benchmarks for Vapor 1.2.5
About a month ago I launched benchmarks for Server side Swift frameworks. Yesterday I updated my project to the new version of Vapor: 1.2.5. Previous version I used was 1.1.11.
One of the most important updates in Vapor 1.2.x is that Vapor is now using a non-blocking server.
So today I decided to run a new benchmark for my project updated to Vapor 1.2 and results surprised me. It's not only faster than the 1.1.x version, it's now equal to Node.js results!
Vapor vs. Node.js
My server:
- 2 GB RAM
- 1 CPU Core
- SSD
- 125 MBPS Out
- Ubuntu 16.10
- CouchDB
Benchmark from other server was launched as:
wrk -t4 -c20 -d5m https://my_url
API just gets some data from CouchDB and returns it as JSON.
Swift Backend with CouchDB: Kitura vs. Vapor vs. Node.js
I made a few test projects to implement an API for my simple app to run some benchmarks. It just makes 1 request to Database and returns JSON data.
All projects was executed on Linode VPS in London:
- 2 GB RAM
- 1 CPU Core
- SSD
- 125 MBPS Out
- Ubuntu 16.10
- MySQL and CouchDB with equal data (about 13k rows/documents)
Benchmarks was run on another, more powerful dedicated server in Germany using wrk:
wrk -t4 -c20 -d5m https://my_url
Results are very different from other benchmarks by Ryan Collins.
What did I try:
- Node.js 7.0 + MySQL 5.7.16
- Node.js 7.0 + CouchDB 2.0 (via node-couchdb)
- Vapor 1.1.11 + CouchDB 2.0 (via HTTP)
- Kitura 1.1.1 + CouchDB 2.0 (via Kitura-CouchDB)
Total requests
Requests per second
Average Latency
Results are very disappointing for me. Node.js was 50% faster than Swift. It looks like it's still not the right time to make backends on Swift right now, unless you don't expect high load and just want to write in Swift.
UPDATE: after about a month I ran another tests for the new version of Vapor (1.2.5) vs. Node.js and Vapor was very very fast. So now I'm very optimistic about using Swift as a backend.
Shake effect animation for UIView
// MARK: - UIView Extension, or NSView
extension UIView {
/// Shake animation
func shake() {
let animation = CAKeyframeAnimation(keyPath: "transform.rotation")
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
animation.duration = 1.0
animation.values = [-Double.pi / 6, Double.pi / 6, -Double.pi / 6, Double.pi / 6, -Double.pi / 7, Double.pi / 7, -Double.pi / 8, Double.pi / 8, 0.0 ]
layer.add(animation, forKey: "shake")
}
}
myView.shake()
