Get to Know How Golang is contributing to Bitly

Reemi Shirsath
3 min readJul 30, 2020

--

Bitly team says -

We identified early on that Go had all the makings of a language that could supersede some of the places we would have traditionally turned to C and some of the places where we wanted to move away from Python.

Bitly’s Experience with Golang

Start with Golang-

Bitly team built daemons networks in C language and that didn’t require control over memory and This is where Golang Shines. In such kind of situation, the benefit in the development time and its flexibility looks much more prominent than the cost of garbage collected language. Code is easy to execute and deploy and we don’t have to worry about low-level details.

Most of their C language applications are built on libevent which is a single-threaded event loop with callbacks that enables them to handle thousands on simultaneous open connection efficiently. The same technique is used in Python by them via tornado, but the limited amount of work the single process in python can do and the code is written is difficult to read, compile and debug when you are not a frequent user/coder.

When we talk about Golang, it has inbuilt concurrency which is lightweight and allows us to write code that can leverage the multi-core architecture of the computers we are working on. Golang has a built-in feature of returning multiple values from functions that help in the easy, clear, and concise error handling of the code. Golang is a small language with a huge standard library.

The developers who had 0 experiences with Golang and those developers started writing the working and production of the code in a day. This was one of the reasons they gave a thought of adding Golang in their stack. The other reasons for choosing Golang were -

  • High performant- Gain the speed & robustness
  • Statically typed language
  • Concurrency — Solution to parallelizable problems
  • Scalability
  • Built-in Standard libraries

To Encourage their team to learn Golang, they created Go Gopher Awards. They said this award is very prestigious and it is given to the developer who has recently learned the language and was able to get the code to the production.

Golang in the Production

To start with first we need to understand some basic things about their infrastructure and how the data moves through it.

The bitly team prefers to keep things simple. Everything that is written to downstream systems is done via message queues. The some of messages queue process volumes in the thousands per second. In the lower layer, there is two C language application. One is Singlequeue and the second is the pubsub. With an increase in the volume, the overhead of message processing becomes more significant. And here is where the requirement of Golang in their application took place. Where Python was replaced by Golang.

They rewrote some of the queuereader in Golang to support the same API that was exposed in Python. By using Golang they were able to leverage channels and goroutines and write code that could parallelize HTTP requests. And Golang these features also make it possible to retrieve batch messages from the queue while they were still processing them. Which indirectly reduced the round-trips.

They said after using Golang in production -

We’ve been very happy. We’ve seen consistent, measurable performance gains without sacrificing stability

Some of the Go related items they open-sourced were-

  • go-notify
  • file2http

You can read more about the article here

You can also read more articles about Golang here-

How a Company Reduced its number of Server from 30 to 2 Using Golang

Things You Need to Know About Golang For Web Development

Here Is Why Golang Is One Of The Preferred Technology For Your Project

Some Interesting Facts and Takeaways from Golang Survey

--

--

Reemi Shirsath
Reemi Shirsath

Written by Reemi Shirsath

𝘾𝙊𝙊 @ 𝙂𝙤𝙡𝙖𝙣𝙜 𝙎𝙥𝙚𝙘𝙞𝙖𝙡𝙞𝙨𝙚𝙙 𝘿𝙚𝙫𝙚𝙡𝙤𝙥𝙢𝙚𝙣𝙩 𝘾𝙤𝙢𝙥𝙖𝙣𝙮- Scalent.io

No responses yet