In this post, we’re going to explore building APIs with Python and GO. We’re going to put these two languages to the test and grade their performance based on response time. I’ll be using Postman for API testing. REST APIs in Python is powered by Flask and Mux for Golang
We are going to perform CRUD operations onto a PostgreSQL instance running on localhost using python and go and rate them across each category.
What is CRUD? It stands for Create, Read, Update and Delete, these are the basic operations performed on a database. Read more about it from the below reference.
First, we have to set up the PostgreSQL instance and create a table onto which we can perform the operations.
here we create a simple table called data with a single text field. We’re going to perform the CRUD processes on this table inside the Postgres database.
The code repo can be found at
The APIs have been built in a way that is similar to the following architecture.
Now let’s Analyse the response times. Let’s fire up Postman and checkout the response times for
Winner: Golang , while python was averaging 20 to 30 ms, Golang was doing 15 to 20 ms winning by a margin of 5 -10 ms
Winner: Golang , while python was averaging 15to 20ms, Golang was doing 12 to 15ms winning by a margin of 3 - 5 ms
Winner: Golang, while python was averaging 20 to 25ms, Golang was doing 15 to 20ms winning by a margin of 5 ms
Winner: Golang by a small margin of 2 to 3ms when compared to Python
GO is faster than Python, duh! but brownie points to Python for being soo easy to get up and running. But the goal of this experiment was to judge the impact that migrating to Golang would bring from a business perspective. Assume that 1 million API calls are made, Say python takes 20ms per request and Golang takes 15ms per request, Total processing time in Python would take around 5.55 hours and Golang would take 4.16 hours. The difference a few milliseconds make is huge. Since most businesses use AWS for building and deploying APIs, Golang will help save a huge sum of money as AWS charges per time taken for execution.