Ginbits “speaks” Go: Perfecting Our API Gateway With Golang
Author: Kostas Papanikolaou
Categories: Technology
Ginbits “speaks” Go: Perfecting Our API Gateway With Golang
Ginbits was created with innovation and efficiency within its core. As mentioned in our blog on why we opt for Kubernetes to automate deployment, scaling, and management of our applications, we choose to use technologies that actually make a difference.
Within the vast sea that is the programming world, we have also opted for a programming language that epitomizes efficiency and innovation: Go, also known as Golang.
Our API Gateways are built with Go, allowing us to increase the speed, availability, and reliability of all our services. By taking full advantage of what Golang has to offer, we are able to run multiple concurrent processes since Go scales well.
What is Go?
Invented in 2007 and first published in 2009, Go is the open-source language developed by three Google engineers, along with the combined efforts of other contributors. It was created with the purpose of simplifying the process of software development, with a clear focus on complex architecture and processes.
Go promises code efficiency, essentially allowing businesses have faster software and applications. Ginbits has adopted Go as the programming language used to build its API Gateway. Among others, companies that have shifted to Golang include Google, Apple, Facebook, Docker, BBC, and The New York Times.
Regarding its foundation, Go was not built from scratch. It was developed based on the C language. It inherits the syntax of C, with several changes and feature improvements. These include the option of managing memory safely, thus eradicating the memory leakage issues that occur when a developer does not release unused memory by mistake.
Why go… Go?
At Ginbits, we value efficiency more than anything else. We steer clear from “big” words and do not opt for technologies just for the sake of mentioning them. Ginbits chose to go with Golang because it epitomizes efficiency and it achieves that thanks to multiple pros it has when compared to other programming languages.
Speed is of the essence
Golang is a compiled language. The code written with Go is translated into formats that a processor understands automatically. It has been proven time and time again that Go is faster than other programming languages like Java and Python. This allows us to increase the availability and reliability of our services.
Write, Scale… Go!
One of the things that make Go an ideal language for building the API Gateways of Ginbits is the ability of the language to make a Gateway handle asynchronous processes in parallel, instead of serially. This happens thanks to Goroutines, functions that can run both simultaneously and independently. With Goroutines taking up just 5kB of memory, Go is scalable when we need to run multiple concurrent processes.
Every Goroutine is responsible for every process. These processes communicate with each other via channels that have several built-in features which complement cloud-based apps and systems.
Managing asynchronous processes at the same time is a possibility thanks to Goroutines, found in Go. Steering away from serial-based languages and choosing Go allows us to create an API Gateway that can open a Goroutine to handle a call it takes from the front end or other clients.
That way, even if thousands of clicks happen at the same time, Go enables our Gateway to manage all these calls/processes in parallel.
To put things into perspective, a Python-based API Gateway would take these calls, stack them, and process them serially, one after the other, consuming both time and most probably hindering performance.
One of the main reasons that we opt for Go to build our API Gateway that handles calls from clients is the fact that we also use Kubernetes. This cloud-based system allows us to deploy, scale, and manage our applications in the most efficient way possible. And lo and behold, k8s is built with Golang.
This pairing allows us to create an efficient infrastructure that can handle multiple calls in parallel. Not only that, but thanks to the “Informer” feature of Kubernetes, changes that happen anywhere within the infrastructure can apply to every other threat/Goroutine that is subject to that change.
Read more on Kubernetes: Ginbits uses K8s: Exemplifying Efficiency With Kubernetes + Prow
Endless Tool Possibilities
Being an open-source programming language, Golang allows Ginbits to get all the development tools that our software engineers need. Multiple editors, IDEs, and plugins are available within the GitHub repository for Go. Several cloud-based IDEs that support Go can also be found easily. Using Golang allows us to become efficient through its inherent flexibility and ease of use.
Tags: API Gateway, API Gateways, concurrency, Go, Golang, Kubernetes, parallelism
Latest Posts