Image for post
Image for post

Intro

Software bench-marking is extremely tough but it is something I really enjoy doing. Whether that is running apache bench on HTTP servers, running redis-benchmark, or pgbench — it is always interesting seeing how various tweaks impact performance.

Two of my go to languages for building anything are Kotlin and Golang. In those, two of my go to libraries to build HTTP services are Vert.x and Echo respectively. It was natural instinct to see how they perform when put under a stress test.

The internet is filled with comments around the JVM being slower compared to native code — It is, while the code gets JIT’d but after that it should perform at a similar level as native code. …

Image for post
Image for post

Introduction

One of the few issues I find myself facing with being a Kotlin developer and advocate is that it is mainly used for Android development. When you search for anything regarding it — the results are almost always in the context of Android. Search for ‘Kotlin coroutines stack overflow’ and the first result is regarding its usage in Android.

To promote more backend development in Kotlin — I want to share some libraries and frameworks that I typically employ for building APIs. The three pillars I will cover are caching, interacting with a SQL Database, and the HTTP server itself.

HTTP Server

Before any requests from users can be served — we have to get the requests into our system through an entry point. …

Image for post
Image for post

Background context

Both Kotlin and go have the concept of Coroutines [or goroutines]. While Kotlin’s coroutines are primarily used to provide a convenience layer over callback/futures based APIs and interfaces, goroutines are mainly there to allow for simplified concurrency. Interestingly enough they are implemented slightly differently as well. You can read more around the differences in this stack-overflow answer here by Roman Elizarov who is the team lead at Jetbrains for Kotlin coroutines.

It is a common task for developers to have to fetch multiple things from a backend or 3rd party service and join it together before sending the response back e.g. taking a list of user IDs and getting the user data associated with each from a user service. Although a simple ‘loop over each ID and make the request’ approach would work — situations like these are prime candidates to benefit from concurrency by making all the requests in parallel instead of waiting on the response of one before sending out the next one. …

About

Asad Awadia

Tech. Finance. Life. curl https://aawadia.fly.dev

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store