BlogsGitLabApplication Server Migration (Unicorn to Puma)

Application Server Migration (Unicorn to Puma)

Application Server Migration (Unicorn to Puma)

2
posts
2019–2020

GitLab has successfully migrated its application servers from the single-threaded Unicorn to the multi-threaded Puma web server. This migration, which began with experimental use in 2015 and intensified with the formation of the Memory Team in 2019, aimed to address memory growth issues and improve scalability. The process involved extensive testing in pre-production environments, tuning of worker and thread configurations, and addressing thread-safety issues with libraries like ChronicDuration. The Memory team is also investigating memory and performance bottlenecks in Sidekiq, project import, and exports, and improving development practices around code complexity and memory usage.

2020

How we migrated application servers from Unicorn to Puma

7/8/2020

This post details the technical journey of migrating GitLab's application servers from Unicorn to Puma. It explains the architectural differences between the two servers (single-threaded vs. multi-threaded), the motivations for the migration (memory growth and scalability), and the implementation steps. Key technical challenges and solutions discussed include: identifying and fixing a thread-safety issue with the ChronicDuration library by forking it into `gitlab-chronic-duration`, tuning Puma's worker and thread configurations to address latency issues, and contributing an upstream patch to Puma to improve request scheduling and capacity distribution by injecting minimal latency between requests when a worker is busy. The post also quantifies the results, showing a 37% reduction in memory usage.

2019

Why we created a Memory team at GitLab

9/13/2019

This post details the creation of the GitLab Memory team to address the application's high memory footprint. It outlines the team's priorities: migrating from Unicorn to Puma, optimizing endpoints, and improving development practices. The post specifically highlights the migration from Unicorn to Puma as a key initiative to reduce memory usage, with preliminary research showing Puma's threaded nature requires less memory than Unicorn's single-request-per-process model. The team has configured Puma on dev.gitlab.com and plans to enable it on GitLab.com. Additionally, the team is addressing memory issues in Sidekiq, project import, and exports, and is working on improving internal development practices related to memory usage and code complexity.