The TFB challenge is a performance comparison of many web app platforms, exercising JSON, database, ORM, HTML templates, all over HTTP. It compares the best frameworks written in C++, Rust, Go, JS, Java, C#… and now Pascal – thanks to mORMot.

Use The Source, Luke!

The source code of the mORMot server involved is available online:
https://github.com/synopse/mORMot2/tree/master/ex/techempower-bench

The supplied server program publishes three families of endpoints, defined as such in the "display_name" of the benchmark configuration:

  • mormot orm using the ORM layer;
  • mormot direct using the direct DB layer - mapping /raw* endpoints;
  • mormot async using the asynchronous DB layer (only available on PostgreSQL by now) - mapping /async* endpoints.

Yes, we added an asynchronous/non-blocking DB interface, for the purpose of the TFB challenge. Pascal can do wonders even without "async" keyword support in the language itself - which we would like to appear, anyway.

Gimme Numbers

As we wrote above, mORMot is within the top #12 frameworks, and within the first frameworks with a full ORM. Note that some libraries listed as "ORM" (like drogon) are not full ORM frameworks. They are C++ templates engines, with pre-generated code. So they don't use RTTI or a separated Mustache template as mORMot does. To my understanding, an ORM is not just a set of templates with manual SQL statements, but about automation and minimal code writing. You define the class, and the framework should do the work for you.

Note that the ranking may change with the final publication of Round 22, because the weighting of each tests may be changed.
We will see what the future offers...

But anyway, we are above some well-known and proven solutions like "asp.net core", so we can be proud.
Actual numbers can be found at the https://tfb-status.techempower.com website.

Also note that those tests use PostgreSQL. In most mORMot configurations, a typical MicroService would rather use its own embedded SQLite3 database. And here, the numbers are twice higher. So in fact, a production-ready mORMot service with its stand-alone database is likely to blow away any other framework using a separated PostgreSQL database. As such, the cached-queries test, which returns some items using the DB/ORM cache, is a typical workload on a production system, and mORMot shines in this test. It is usually the first full ORM listed in the "cached query" test.
But PostgreSQL is for sure the fastest and most stable database around, and we have a native and direct access layer to it in mORMot. The mormot.db.sql.postgres.pas unit has been written from scratch, and heavily tuned to maximize the performance of this amazing Open Source database - thanks a lot Pavlo for your hard work!

During upcoming EKON 27 Conference at Dusseldorf next week (already!), I will make two sessions about it.
Here is a quick description of them.

Frameworks Expressiveness

In this first session, we will look and compare the source code of some frameworks samples, to distinguish their typical philosophy. We will see how modern Object Pascal is still relevant, and discuss/propose some ideas for the future of the pascal language.

Frameworks Tuning

As a follow-up of the previous session about TFB, we will detail what kind of tuning was made to the mORMot library, and its associated TFB sample implementation, to reach the top scores in charts.

How can a pure Pascal project reach 7 millions of HTTP requests per seconds? How to scale and measure on high-end hardware? Are ORM frameworks damned to slow down everything? How to circumvent the lack of “async” programming at language level? How realistic is such a benchmark?

More To Come

When I return from Germany, I will write here some more information.
But in short, server performance is about proper multi-thread coding, minimizing number of syscalls and lock contention, and reusing as much context as possible. And the most important is certainly actual measurement (not guessing), and the ability to have several brains investigating the bottlenecks: thanks a lot Pavel for your insight and ideas to optimize our numbers!
Stay tuned!