Code Monkey home page Code Monkey logo

vapor-spring-benchmark's Introduction

Vapor benchmark - Spring-boot edition

What it is

Vapor is a Web framework written in Swift. The authors of this benchmarking article put out a call for help getting some benchmarks run using various popular Web frameworks from other languages; this is the one for Java's Spring Boot framework.

Test Methodology

This is the description of the benchmark tests each framework was to run. You can see that these each became a simple request handler in ApplicationController.java:

Plaintext

Request: GET /plaintext HTTP/1.1

Response: HTTP/1.1 200 OK

Hello, World!

JSON

Request: GET /json HTTP/1.1

Response: HTTP/1.1 200 OK

{
  "array": [1, 2, 3]
  "dict": {"one": 1, "two": 2, "three": 3}
  "int": 42,
  "string": "test",
  "double": 3.14,
  "null": null
}

SQLite Fetch

Grab a random user from the 3 users in the provided test.sqlite database:

sqlite> select * from users;
1|Foo|[email protected]
2|Bar|[email protected]
3|Baz|[email protected]

This will require randomly choosing from 1, 2, or 3.

Request: GET /sqlite-fetch HTTP/1.1

Response: HTTP/1.1 200 OK

{
  "id": 2,
  "name": "Bar",
  "email": "[email protected]"
}

Benchmark

wrk -d 10 -t 4 -c 128 http://<host>:<port>/plaintext
wrk -d 10 -t 4 -c 128 http://<host>:<port>/json
wrk -d 10 -t 4 -c 128 http://<host>:<port>/sqlite-fetch

How it is built

I started by cloning the Spring REST service starter guide to get a REST service up and running as quickly as possible. I added code and tests for the three REST endpoints described above, then ran it locally in IntelliJ IDEA. Once I was satisfied that the code was working and had good-enough test coverage, I uploaded it to the server and ran it with

java -Dspring.profiles.active=prod -jar ./vapor-benchmark-0.1.0.jar

You can see in application.yml that I define a dev profile that creates a fresh SQLite DB locally, and a prod profile that expects to find the one provided for the benchmark.

Challenges

The single biggest challenge was working with SQLite instead of a "blessed" low-footprint DB like Derby or H2. In the end I had to crib from a StackOverflow answer to get a Hibernate dialect that was compliant with Hibernate 4; the SQLite dialects you can find on Maven Central are not up to date, and lead to a runtime crash with a suitably inscrutable exception.

Conclusion

I have over a decade of experience writing Web and backend processing code in Java. It would be foolish to dismiss the power and battle-hardened nature of the JVM as a platform, but the language itself has never been anything but needlessly verbose and painful, with situations just like this being the norm rather than an surprising outlier. In the last few years I have turned my attention gratefully to Clojure and, to a lesser degree, Scala, as "escape hatches" that let me leverage the JVM while still working in a language that satisfies my desire for beauty and concision. I have very high hopes for Swift, and Vapor, to take a place among the top tier of beautiful, powerful tools for doing real work beyond the confines of iOS development.

vapor-spring-benchmark's People

Contributors

hlprmnky avatar

Watchers

Adam J. Mendoza avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.