How We Migrate From Perl to Golang

Alvintz Tan
3 min readJul 2, 2018

(This is migration post from our old blog. Originally posted by Sameer Akhtar at Sept 20, 2016)

Tokopedia is built using Perl since the foundation of this company. It used for all its component, our main page, our microsite, our internal tools, scheduler and many others.

The perl code is stored in a big monolithic repository in our Gitlab server. This big repo and the architecture of Tokopedia’s own framework, makes the development slow and some vulnerability, not mentioning the complexity of the framework.

We are introduced to Golang when a visit from one of our Indian Partner. After they told that they can achieve a good architecture, easy development, and fast apps. Then we try it and it proves that Golang do easy enough to understood, from us, developers suggest to move our code from Perl to Golang.

The Golang migration started since mid 2016, and since then we convert Perl API one at a time to Golang while maintained backward compatibility to the Perl code, so we can switch the API to and fro incase of any mishap. The switching is done through Nginx upstream module.

For our golang code, we make some changes in our architecture:

  1. Instead of create monolithic repository, we make it multiple repository divided by it’s module.
  2. We not using a framework, but instead we agree on module we use for critical part, like module for database, module for redis, etc

The conversion do take time, but seemed worthwhile after we looked at our datadog graphs which we use to measure our uptime/latency. Some of benefit we achieved through this migrations:

  1. We achieved 3 to 5 times improvement in latency. (In some of places when concurrency is possible, we relied upon goroutines)
blue represent latency when served from Golang, red represent latency when served from Perl

2. Lesser load on Database, means we can handle more database related process and the process is faster.

blue represent load when served from Golang, red represent latency when served from Perl

3. Lesser load on server and less machines to serve the apps. We used 2 Go servers each of 1GB memory and 1 core CPU. Earlier we had 5 Perl servers each of 4GB and 2–4 core machine. This was undoubtedly an eye opener.

From our experience, we can confidently says that Golang is a good programming code to produce blazing fast apps, with clean code and fast development time. It developed by Google itself and there are many programmer that create modules to improve the performance.

And we have our good and responsible engineers in our team who made this possible. Kudos to the team!

So moving to golang was fruitful. Now we are looking forward to actively use golang in most of our new developments.

--

--