Replaced

Backlog's Git Server

From Perl To Go

#gocon Spring 2018 by Yuichi Watanabe @nulab

# Introduction

Yuichi Watanabe

# What is a Git Server ?

  • Replaced a server for accessing Git remote repository via HTTP. That is where the Gopher is in the diagram below.
  • In order to access a Git remote repository by HTTP, something is needed in front the remote repository, to handle the HTTP requests occurring in clone, push, fetch etc.
# example endpoints

GET   ***/info/refs?service=git-upload-pack
GET   ***/info/refs?service=git-receive-pack
POST ***/git-upload-pack
POST ***/git-receive-pack

The Git Server basically implements behavior for each endpoint according to the Smart Protocol specification defined by Git.

# What is a Git Server ?

# Motivation

Backlog has a subsystem that stood out a bit, a Git HTTP Server written in Perl. This Git HTTP Server itself does not undergo a lot of development. It's a relatively small system whose responsibility is not too large. I felt that the enthusiasm of maintaining this system within my team, including myself, was gradually decreasing. Also, we currently don't have a Perl Hacker our team.

# Motivation

At the same time, Backlog users are steadily increasing.

I thought I could improve our motivation, the maintainability, and performance by replacing the Git Server using Golang.

 

Don't guess, measure !

 

I decided to rewrite and measure it, as the proverb goes.

# Motivation

# Comparison Structure

## It could handle many requests.

# Improvments

100ms

400ms

Golang

Perl

## It could handle many requests.

Perl

Golang

# Improvments

60%

100%

### CPU usage

## It could handle many requests.
 

Perl

Golang

# Improvments

The speed of git clone and push improved by 2x times.

The larger the Git repository, the larger the speed difference.

## Improved the user experience of clone

Perl Golang
1:02.35 35.185
1:05.73 36.318
1:13.02 35.383

# Improvments

## And More...

  • Reduced memory used for pre-forking the process.

      > Perl:      2.082456 MB

      > Golang: 24.664 KB


  • Deployment is simple as it is compiled into a single binary.


  • We were able to focus on writing code without worrying about code formatting thanks to `go fmt`.


  • Since golang is statically typed, We ware able to use code completion which improved my efficiency.

# Improvments

As a result, The performance improved. However, It's difficult to compare Perl and Golang,  as they are so different. Golang is a compiled language and has lightweight threading. 

 

I got a lot of insight on the design of Web applications written in Perl and eventually learned a lot about the Perl programming language.

 

I saw Geek 's wonderful hack footprints, I've come to like Perl than before.

 

Thank you for Perl, for your hard work. Hello Golang.

# Finally

Thanks !

Replaced Backlog's Git Server from Perl to Go

By Yuichi Watanabe

Replaced Backlog's Git Server from Perl to Go

  • 489

More from Yuichi Watanabe