Benchmarks

7 min read Original article ↗

Polyglot benchmarks

In 2024 we dreamed up the idea of A Polyglot Site for a Polyglot Conference...because it sounded fun. Pointless, but fun.

Now that dream is a reality. If you visit any page on this site that that shows you our Speakers or our [Sponsors](/sponsors], the data is served from an API written in one of these languages.

Scroll past the stats for a details Architecture Overview if you're curious!

Live Traffic Visualizer

Selecting specific languages limits the polyglot APIs used for speakers and sponsors. SQL fallbacks may still occur if necessary.

My Languages: All

Elixir (Phoenix)

165

6

25ms 13ms 137ms

Gleam (mist)

94 55ms 8ms 1893ms

C (POSIX sockets)

1 82ms 82ms 82ms

Rust (axum)

48

3

89ms 8ms 1202ms

Ruby (Rails)

166

7

111ms 10ms 4501ms

PHP (Laravel)

36

3

114ms 43ms 841ms

F# (ASP.NET)

29

3

135ms 12ms 919ms

TypeScript (node:http)

18

11

168ms 12ms 678ms

Perl (HTTP::Daemon)

2 181ms 169ms 193ms

Perl (Dancer2)

22 231ms 37ms 733ms

F* (OCaml Unix)

17

1

276ms 38ms 923ms

PHP (built-in SAPI)

24

3

296ms 40ms 1365ms

Python (Django)

92

18

327ms 13ms 3657ms

Julia (HTTP.jl)

6

1

329ms 135ms 858ms

COBOL (GnuCOBOL)

2

2

340ms 73ms 608ms

Java (httpserver)

21

9

362ms 14ms 2998ms

C++ (cpp-httplib)

7 517ms 18ms 1162ms

Groovy (Grails)

5 561ms 96ms 695ms

Kotlin (Ktor)

2

2

855ms 847ms 863ms

Go (net/http)

8

4

886ms 24ms 1974ms

Ada (AWS)

7

1

1104ms 37ms 1902ms

Python (http.server)

10

18

1502ms 19ms 3750ms

Ruby (Sinatra)

3

7

3440ms 2961ms 3703ms

Dart (shelf)

0 — — —

Erlang (Nova)

0

4

— — —

JRuby (Sinatra)

0 — — —

Pony (Stallion)

0

2

— — —

Proudly hosted on Fly.io (2024 Platinum Sponsor).

Architecture Overview

The site uses an Elixir front-end powered by Phoenix, LiveView and Ash connected to a PostgreSQL database with an entirely custom built CMS.

Anywhere that Speakers or Sponsors are displayed on the site, one of our Polyglot APIs are used to serve the request, displayed in the upper right corner of your screen. The Polyglot APIs all connect to a read only database connection via pgbouncer, accessing the Speaker and Sponsor data via versioned database views to simplify management across the fleet. If we need to change how data is fed across the APIs, we can update the VIEW rather than modifying each of the APIs.

Telemetry for each API is tracked in ETS (in memory storage for the BEAM VM used by Erlang/Elixir) by tracking the API round trip. New deployments clear the stats. The site is hosted on Fly.io, which will suspend each VM when not active for a few minutes to save costs. The startup time is relatively quick on a new request, but it can affect the benchmarks. In order to ensure rapid response, the next language up in the list is sent an async request following the current page load to keep it warm.

A couple of tweaks have been made to protect the user's browsing experience. First, Elixir will enforce a timeout behind the scenes if the response time for a language is to slow for some reason. This will lead to moving to another language or simply serving the request with SQL as a fallback.

Additionally, every request is made through a Dynamic GenServer with Cachex based on the data being requested and the language used with a 1 second TTL. If you make the exact same request to the exact same language within 1 second, you will be shown a cached result or you will share the result from the request in progress. The language and time stats for the original request will be displayed in the upper right, but the telemetry data for the request will not change.

The initial APIs that were developed were completed with Ruby (Sinatra) and Go (net/http). Following the initial development, a common AGENTS.md file was created and further language were created with a simple /goal Using our previous criteria, create a polyglot API for the site using <LANGUAGE> which included language specific tests, linters, static security checks, dependency security checks, gitleaks checks and compiler checks if needed as part of the precommit hooks.

Later changes were applied with a local script using herdr to start a new session across each language with a specific prompt. Some additional tuning was done on specific languages if a problem was apparent. For example, the JVM cold start problem was observed in this environment so we attempted to let the AI setup CRaC.

You may click on any language to review it's source on Github and we're happy to review PRs if you have suggestions! We aren't ready to open up for new language submissions just yet but we do have an API starter project for you if you are considering one.

Enjoy exploring and please feel free to share your thoughts on any of our socials!

Carolina Code Conference

The polyglot and cybersecurity conference for all who code.