How LinkedIn handles merging code in high-velocity repositories

Niket Parikh
9 min readintermediate
--
View Original

Overview

The article discusses how LinkedIn manages code merging in high-velocity repositories by utilizing a microservice architecture and trunk-based development practices. It highlights the challenges of maintaining a 'green' primary branch and the strategies employed to ensure timely code integration while minimizing disruptions.

What You'll Learn

1

How to implement trunk-based development in high-velocity environments

2

Why maintaining a 'green' primary branch is crucial for developer productivity

3

How to customize validation processes for different repository velocities

Prerequisites & Requirements

  • Understanding of microservice architecture and continuous integration principles
  • Familiarity with Git and CI/CD tools(optional)

Key Questions Answered

What are the main constraints LinkedIn faces in code management?
LinkedIn faces two main constraints: ensuring the primary branch is always 'green' and allowing developers to merge changes in a timely manner. If the primary branch becomes 'red', it can cause delays in feature releases. Additionally, the system must remain performant for both high- and low-velocity repositories.
How does LinkedIn's 'git submit' workflow improve developer experience?
'Git submit' allows developers to push changes without needing to update their local repository with the remote HEAD. This reduces the cycle of rebasing and testing, enabling smoother integration of changes into the primary branch while maintaining code correctness.
What validation processes does LinkedIn use for code merging?
LinkedIn employs both pre-merge and post-merge validations. Pre-merge validations ensure that code changes can be integrated without breaking the build, while post-merge validations catch any soft conflicts that may arise after merging.

Key Statistics & Figures

Active repositories at LinkedIn
over ten thousand
This number reflects the scale at which LinkedIn operates, with thousands of developers contributing to these repositories.
Commits per day in high-velocity repositories
upwards of 300
This statistic illustrates the intense pace at which code changes are made and merged in certain LinkedIn repositories.
Soft conflicts per year for the highest-velocity repository
roughly 5
This low number indicates the effectiveness of LinkedIn's CI practices in maintaining code quality.

Technologies & Tools

Version Control
Git
Used for managing code changes and facilitating the 'git submit' workflow.

Key Actionable Insights

1
Implement a 'git submit' workflow to streamline code integration processes.
This approach minimizes the need for developers to constantly rebase their changes, allowing for faster and more efficient merging in high-velocity environments.
2
Customize validation processes based on repository velocity to optimize developer productivity.
By allowing teams to adjust their validation settings, organizations can ensure that both high- and low-velocity repositories maintain efficiency without sacrificing code quality.

Common Pitfalls

1
Failing to maintain a 'green' primary branch can lead to significant delays in development.
When the primary branch is not stable, developers may face challenges in integrating their changes, leading to frustration and decreased productivity.
2
Over-optimizing for high-velocity repositories at the expense of low-velocity ones.
This can create a situation where teams working on less active repositories experience slowdowns, as the system may not cater to their specific needs.

Related Concepts

Microservice Architecture
Continuous Integration
Trunk-based Development
Developer Productivity Strategies