The speed of your backend's language does not matter

Erwan Lemonnier
Gofrendly Engineering
2 min readDec 2, 2020

--

Python is my language of choice for backend programming. Python is slow. Python is not statically compiled. Python has dynamic typing, with all the runtime sluggishness that implies. But it does not matter.

To build Gofrendly's backend, we could have chosen Java, Kotlin, Go or Node or anything else really. As long as it comes with a stable and generous ecosystem of third party libraries, and as long as coding time from idea to working prototype is fast enough (Bye-bye Java).

But the speed of the language itself was never important. And this is why:

Profiling Gofrendly's backend API

The screenshot above shows you what Gofrendly's backend code spends time on. These numbers are average response times over all API endpoints, taken over a normal day. But the really interesting bit is the color chart:

  • Dark lilac represents time spent waiting for Datastore queries to return
  • Green is time spent waiting for Elasticsearch
  • Yellow is actual Python execution time

A rough guesstimate is that an average backend endpoint spends three quarter of its time waiting for database queries to complete.

We could spend time to optimise our Python code to death. We could rewrite all Python code into C++ or assembler. In the end, the gain would be a weak 25% speed increase. Maybe 30%. Not worth it.

Bottom line: the speed of your backend language does not matter. What does is optimising your database calls: using bulk querying and doing non-blocking asynchronous IO as much as you can.

--

--

CTO. Fullstack developer turned entrepreneur. Ex-employee of Spotify and Trustly. Author of the PyMacaron microservice framework.