Go vs Swift vs Spring Boot vs Spring WebFlux

Alin Velican
3 min readSep 8, 2019

--

Comparing the new with the old.

Photo by Pankaj Patel on Unsplash

Bored of the daily Java, I thought I’d try something new last week. So I started researching the market for new and cool languages so I came to Swift for the beginning. Excited about the fact that I could develop applications for iOS I started my adventure with Swift. Long story short, I did not develop any application and got to read about some Swift backend frameworks(Vapor and Perfect). After that, I got to compare them with Node JS, Spring and Go.

What I tested

For each of them I made the minimum application every framework provided in documentation and I tested with Bombardier. This is the command I run for every application ./bombardier -c 125 -n 2500000 localhost:8080/test. So 125 concurrent clients for 2500000 requests.

Swift

The most popular backend frameworks in Swift world are Vapor and Perfect. So I went to their Getting Started pages and I put them to work.

For Perfect this is the Getting Started page:

And for Vapor:

And the results:

Vapor: Reqs/sec 13701.82

Perfect: Reqs/sec 41246.18. It seems that Perfect has performed better than Vapor by far.

Node.JS

For Node.JS part I used the well known ExpressJS framework:

And the results:

Express: Reqs/sec 20178.73. Neither good nor bad. Better than Vapor, but weaker than Perfect. The fact that Swift is a compiled language said his word.

Go

I had big expectations from Go, and it didn’t disappoint me. For Go I used the net/http module and this is the simple cod I run:

package mainimport (
“fmt”
“net/http”
)
func main() {
http.HandleFunc(“/test”, HelloServer)
http.ListenAndServe(“:8080”, nil)
}
func HelloServer(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, “Hello, %s!”, r.URL.Path[1:])
}

And the results:

Go: Reqs/sec 56270.09. Compared with Perfect results Reqs/sec 41246.18 seems that Go is faster this time.

Java — Spring

For Java I used the everlasting Spring Framework, Spring Boot in fact and Spring Rest more specific. Honestly, I had no expectations, only to be over Node.JS but under Go and Swift. The fact that Spring runs in Java and Java is not a pure compiled language it will definitely hang hard.

And the results:

Because it is Java, we need first to ramp up the JVM:

Spring — first run: Reqs/sec 22573.60 — close to Node (20178.73)

Spring — second run: Reqs/sec 31517.60 — better than Node but weaker than Go and Swift as expected.

One more thing

In Spring world these days it is very popular a new framework: Spring Web Flux, or Web on Reactive Stack as they call it. It is a non-blocking framework which use Netty under the hood instead of the old Servlet.

I gave it a chance without any expectations but I was very surprised. No. I lied. I was shocked. Before I will show you the results, I only want to remember the best result:

Go: Reqs/sec 56270.09. And now, prepare yourself:

And the results:

Spring Web Flux: Reqs/sec 66734.35

This result exceeded all my expectations by far. I never thought Java could beat a compiled language. It seems that the guys from Netty made a great job. By the way, Netty is made by Apple.

Final thoughts

Even though Java is not so cool these days, I think there are still amazing things to learn about.

--

--