+ All Categories
Home > Technology > Gerrit Performance Tuning Talk at Google Summit

Gerrit Performance Tuning Talk at Google Summit

Date post: 16-Apr-2017
Category:
Upload: johannes-nicolai
View: 2,841 times
Download: 5 times
Share this document with a friend
62
Google Gerrit User Summit 2015 How to Properly Tune and Size your Gerrit Backend Johannes Nicolai Director of Engineering, CollabNet 6/7/22
Transcript
Page 1: Gerrit Performance Tuning Talk at Google Summit

1 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Google Gerrit User Summit 2015How to Properly Tune and Size your Gerrit Backend

Johannes Nicolai

Director of Engineering, CollabNetTuesday, May 2, 2023

Page 2: Gerrit Performance Tuning Talk at Google Summit

2 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

The CollabNet Gerrit Team

Page 3: Gerrit Performance Tuning Talk at Google Summit

3 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Berlin Hackathon

Page 4: Gerrit Performance Tuning Talk at Google Summit

4 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

I want you for the Gerrit Hackathon

In Spring 2016!

Page 5: Gerrit Performance Tuning Talk at Google Summit

5 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

TeamForge – A Full Development, Delivery and Collaboration System

codecode

planplan

test test

release release

deploy deploy

monitormonitor

operate operate

build

build

Governance, traceability, and IP security across tools, assets, processes, and teams

Scalability

planreview

Page 6: Gerrit Performance Tuning Talk at Google Summit

6 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

CollabNet TeamForge – Integrated Tools

Page 7: Gerrit Performance Tuning Talk at Google Summit

7 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

http://blogs.collab.net/git

Page 8: Gerrit Performance Tuning Talk at Google Summit

8 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

CollabNet Customers & Some Gerrit Stats

• Some of our customers have– More than 5 million Git fetch requests daily– More than 10 Gerrit master servers– More than 40 different “geographies” and replication servers– More than 100,000 active developers– More than 10 TB of source code– More than 20,000 repositories– More than 1000 CI servers

Financial Healthcare Global Services Technology, Software and IoT

Government and Aerospace

Page 9: Gerrit Performance Tuning Talk at Google Summit

9 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Git Sizing / Performance Tuning - FAQ

• How many servers will I need?

•Which cloning protocols to offer?

• How to set those gazillion gerrit.config options?

• How many CPUs and how much RAM will I need?

•What the heck is pack size?

• How often should you run garbage collection?

• Does it make any difference whether I go with a native Git or JGit based backend?

• How do you handle hundreds of polling CI users without compromising performance for your human end users?

•What about clustering and replication?

Page 10: Gerrit Performance Tuning Talk at Google Summit

10 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

“ It Depends …

One Size Fits All?

Page 11: Gerrit Performance Tuning Talk at Google Summit

11 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

One Size does not fit all.

Page 12: Gerrit Performance Tuning Talk at Google Summit

12 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Status Quo on Gerrit Performance Tuning Info

• https://code.google.com/p/gerrit/wiki/Scaling

• Gerrit Mailing list

• Tech Talks

• Some very generic, mentioning only upper limits– “some larger installations use 48 cores”– “at least one has 1 TB RAM”

• Other very specific, requiring test env with production load– “Your luck may vary with tweaking your jvm gc parameters. You may find

that increasing the size of the young generation may help drastically reduce the amount of gc thrashing your server performs.”

• Depend on hard to measure metrics– # parallel fetch requests

Page 13: Gerrit Performance Tuning Talk at Google Summit

13 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Typical ops persona

• Jack of all trades

• Responsible for dozens of applications

• No Gerrit expert knowledge

• No Java expert knowledge

• Basic Git knowledge

• No access to special HW

• Limited test bed (not same load pattern as on production)

• No access to Gerrit multi master / GFS technology

• No overview about all their user base (tens of thousands of developers in different geographies)

Page 14: Gerrit Performance Tuning Talk at Google Summit

14 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Challenge

• Tuning advice that is– actionable– not “one size fits all”– targeted at ops people with no expert Gerrit / JVM knowledge– only uses easy to measure factors for its recommendations– does not require special HW or test beds– not depending on proprietary Gerrit extensions/technology

• Keep Motivation up to go through all of this

Page 15: Gerrit Performance Tuning Talk at Google Summit

15 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Disclaimer

• Some advice shown next is debatable & over simplified

• Eager for your feedback in Q&A session / lunch break

• However all recommendations have been verified at our customers & our performance lab

Page 16: Gerrit Performance Tuning Talk at Google Summit

16 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Motivation (TeamForge == Gerrit 2.10.6)Numbers from http://bit.ly/1WxSiw9

Page 17: Gerrit Performance Tuning Talk at Google Summit

17 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Motivation

Page 18: Gerrit Performance Tuning Talk at Google Summit

18 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Motivation

Page 19: Gerrit Performance Tuning Talk at Google Summit

19 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Gerrit Performance Tuning in 5 Steps

1. Get your numbers

2. Size your hardware

3. Tune your gerrit.config

4. Configure Garbage collection

5. Deal with heavy CI load

S M L

Page 20: Gerrit Performance Tuning Talk at Google Summit

20 Copyright ©2015 CollabNet, Inc. All Rights Reserved.20 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

1. Get Your Numbers

Page 21: Gerrit Performance Tuning Talk at Google Summit

21 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 1: Get your numbers

• The number of users is only an indirect factor for Gerrit tuning as most Git operations are done completely offline.

• The more users you have, the more repositories and push/fetch requests you will probably encounter.

• The majority of load is typically caused by build systems (CI). The biggest enterprise instance we have seen has 15k active users.

Number Of Users

Page 22: Gerrit Performance Tuning Talk at Google Summit

22 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 1: Get your numbers

• The number of repositories (Gerrit projects) determines how much disk space you need.

• We have seen instances with more than 10k repositories but would not recommend more than 2500 per server.

Number Of Repositories

Page 23: Gerrit Performance Tuning Talk at Google Summit

23 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 1: Get your numbers

• ssh allows you to use public key cryptography which is stronger than passwords

• ssh is recommended for CI users as this allows push based notifications (see step 5).

• http(s) seems to perform better if the majority of the operation time is the connection request itself (not much data transferred, no heavy IO)

• Hybrid approaches are possible

Protocol

Page 24: Gerrit Performance Tuning Talk at Google Summit

24 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

ssh vs https

Page 25: Gerrit Performance Tuning Talk at Google Summit

25 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

ssh vs https

Page 26: Gerrit Performance Tuning Talk at Google Summit

26 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 1: Get your numbers

• Repository size determines the amount of storage you need on disk. In addition, it influences the needed memory during a clone request as pack files have to be loaded and streamed.

• The largest repository on disk should still fit in 1/4 of your heap.

• Garbage collection across all projects will take longer, the more repository data has to be processed.

• Gerrit can handle at least 1TB of total repository data easily.

Repository Size

Page 27: Gerrit Performance Tuning Talk at Google Summit

27 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 1: Get your numbers

How to count #fetch requests per day:

fgrep "git-upload-pack" sshd_log | wc –l

+

fgrep "git-upload-pack" httpd_log | wc -l

git-upload-packgit fetch

fetch requests

git pull

git clone

What are the fetch/pull requests and how many will I have per day?

git-receive-packgit push

push requests

Page 28: Gerrit Performance Tuning Talk at Google Summit

28 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 1: Get your numbers

• In most enterprise settings, push requests contribute less than one percent to the number of total operations. Because of this, their number can be typically neglected.

Number Of Push Requests

Page 29: Gerrit Performance Tuning Talk at Google Summit

29 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 1: Get your numbers

• This is probably the most important tuning factor. To improve throughput, fetch requests should be handled in parallel, but parallel cloning needs CPUs as well as memory.

• A Gerrit server optimized for heavy load (32 cores, 32 GB RAM) can handle about 1M fetch requests per day, processing up to 50 in parallel.

Number Of Fetch Requests

Page 30: Gerrit Performance Tuning Talk at Google Summit

30 Copyright ©2015 CollabNet, Inc. All Rights Reserved.30 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

2. Size Your Hardware

S ML

Page 31: Gerrit Performance Tuning Talk at Google Summit

31 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 2: Size your hardware

100k requests/day4 cores4 GB RAM

S

500k requests/day16 cores16 GB RAM

M

1M requests/day32 cores32 GB RAM

L

Page 32: Gerrit Performance Tuning Talk at Google Summit

32 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 2: Size your hardware

•Whenever horizontal scaling is not cost efficient any more (> size L), we recommend setting up another server.

• If the number of repositories exceeds 2500, a new server should be used as well or reviews will get painfully slow.

• Use Gerrit's replication feature to synch repository content and permissions to servers in different geographies if network is the limiting factor.

Number of Servers

Page 33: Gerrit Performance Tuning Talk at Google Summit

33 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 2: Size your hardware

• The higher the network bandwidth, the shorter it will take to fetch and push repositories. Depending on the average Git repository size and number of parallel requests, network connectivity can will become the primary bottleneck.

•Most enterprises have Gigabit connections.

Network

Page 34: Gerrit Performance Tuning Talk at Google Summit

34 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 2: Size your hardware

• Storage needs are determined by the Git repository sizes.

• Fast storage (SSDs) really pay off as git fetch, push and gc are all IO heavy.

Disk Storage

Page 35: Gerrit Performance Tuning Talk at Google Summit

35 Copyright ©2015 CollabNet, Inc. All Rights Reserved.35 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

3. Tune Your gerrit.config

Page 36: Gerrit Performance Tuning Talk at Google Summit

36 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 3: Tune your gerrit.config

• Timeout to process incoming changes and update refs and Gerrit changes

• Default 2min

receive.timeout

S

M

L

4 min

4 min

4 min

Page 37: Gerrit Performance Tuning Talk at Google Summit

37 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Why ssh thread pooling is a good thing

Page 38: Gerrit Performance Tuning Talk at Google Summit

38 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 3: Tune your gerrit.config

• Threads to process ssh requests, limiting the number of possible parallel clones/pushes

• sshd.batchThreads will be deducted from this number

• Defaults to 1.5 * <#Cores>

• Recommend

lim [sec(x)/sin(x)] * <#Cores>x→π/4

= 2 * <#Cores>

sshd.threads

S

M

L

8

32

64

Page 39: Gerrit Performance Tuning Talk at Google Summit

39 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 3: Tune your gerrit.config

• Threads to process http clone/push requests and review related activities

• Default is 25

httpd.maxThreads

S

M

L

25

50

100

Page 40: Gerrit Performance Tuning Talk at Google Summit

40 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 3: Tune your gerrit.config

• DB connections for Gerrit

• As a fetch/push request or a review action can consume multiple connections

• Recommend to set at least to sshd.threads + httpd.maxThreads• Default is 8

database.poolLimit

S

M

L

50

150

250

Page 41: Gerrit Performance Tuning Talk at Google Summit

41 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 3: Tune your gerrit.config

•Maximum time before a DB connections gets released

• As DB pool size is typically increased from its default value, this parameter should be too

• Default is 4

database.poolMaxIdle

S

M

L

16

16

16

Page 42: Gerrit Performance Tuning Talk at Google Summit

42 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 3: Tune your gerrit.config

• Java heap used for Gerrit. The more repository data Gerrit can cache in memory, the better

• Recommend to set at least to <Cores> GB size heap size allocated for Gerrit

• The largest repository on disk should still fit in ¼ of your heap. Our experience tells 32 GB per 1M daily requests is pretty common

container.heapLimit

S

M

L

4g

16g

32g

Page 43: Gerrit Performance Tuning Talk at Google Summit

43 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 3: Tune your gerrit.config

•Maximum cache size to store Git pack files in memory

• Default 10 MB is way too small if you frequently clone large repositories and like to cache their data

• Recommend ¼ of your heap size

core.packedGitLimit

S

M

L

1g

4g

8g

Page 44: Gerrit Performance Tuning Talk at Google Summit

44 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 3: Tune your gerrit.config

• Number of bytes of a pack file to load into memory in a single read operation

• 16k is a common choice

• Default is 8k

core.packedGitWindowSize

S

M

L

8k

16k

16k

Page 45: Gerrit Performance Tuning Talk at Google Summit

45 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 3: Tune your gerrit.config

•Maximum number of pack files to have open at once

• Too small number can cause repository corruption during gc

• If you increase this to a larger setting you may need to also adjust the ulimit on file descriptors for the host JVM, as Gerrit needs additional file descriptors available for network sockets and other repository data manipulation

• Default is 128

core.packedGitOpenFiles

S

M

L

1024

2048

4096

Page 46: Gerrit Performance Tuning Talk at Google Summit

46 Copyright ©2015 CollabNet, Inc. All Rights Reserved.46 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

4. Configure Garbage Collection

Page 47: Gerrit Performance Tuning Talk at Google Summit

47 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 4: Configure garbage collection (~gerrit/.gitconfig)

• Determines how often Gerrit garbage collection (JGit gc) is run across all repositories

• Running JGit gc frequently is crucial for good fetch/push performance as well as a smooth source code browsing experience

• JGit gc is more efficient than command line git garbage collection and causes less problems with Gerrit running in parallel

• Parameters to control JGit gc's resource consumption are in ~gerrit/.gitconfig Don't forget to set gc.startTime for the initial garbage collection time

gc.interval

S

M

L

1week

3 days

1 day

Page 48: Gerrit Performance Tuning Talk at Google Summit

48 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 4: Configure garbage collection (~gerrit/.gitconfig)

• Threads used for Gerrit (JGit) garbage collection

• ¼ <#Cores> is a common choice

pack.threads

S

M

L

1

4

8

Page 49: Gerrit Performance Tuning Talk at Google Summit

49 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 4: Configure garbage collection (~gerrit/.gitconfig)

• Use this setting to control how much memory (Java heap) is used for Gerrit garbage collection (JGit gc)

• ¼ of the configured Java heap is a common choice

pack.windowMemory

S

M

L

1g

4g

8g

Page 50: Gerrit Performance Tuning Talk at Google Summit

50 Copyright ©2015 CollabNet, Inc. All Rights Reserved.50 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

5. Deal With Heavy CI load

Page 51: Gerrit Performance Tuning Talk at Google Summit

51 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 5: Deal with heavy CI load: Push vs PollNotify your CI push based (stream-events) instead of polling

update?

update?

update?

update!

update!

update!

Frequent polling Push based notification

Page 52: Gerrit Performance Tuning Talk at Google Summit

52 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Use Jenkins Gerrit Trigger Plugin

Page 53: Gerrit Performance Tuning Talk at Google Summit

53 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Use Jenkins Gerrit Trigger Plugin: Replication Config

Page 54: Gerrit Performance Tuning Talk at Google Summit

54 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 5: Deal with heavy CI load: SegregationMark CI users as BATCH users and have a separate thread pool

CI Users

Resourcestarvation

CI Users withBATCH group

No Resourcestarvation

Page 55: Gerrit Performance Tuning Talk at Google Summit

55 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 5: Deal with heavy CI load

• Threads reserved to users in a Gerrit group with the BATCH capability

• This allows to separate CI users causing heavy load from human users in different thread pools

• Recommend to set Interactive users to have <sshd.threads> - <sshd.batchThreads>

• This can improve clone/push performance for human users significantly)

• Default is 0

sshd.batchThreads

S

M

L

2

4

8

Page 56: Gerrit Performance Tuning Talk at Google Summit

56 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 5: Deal with heavy CI load

• Threads used to process incoming ssh connection requests

• Setting should only be adjusted if you have CI system that create a burst of connection requests in parallel. Especially in AOSP build environments, increasing this value helped reducing the average wait queue size

• Default is 2

sshd.commandStartThreads

S

M

L

2

3

5

Page 57: Gerrit Performance Tuning Talk at Google Summit

57 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 5: Deal with heavy CI load: Replication

Page 58: Gerrit Performance Tuning Talk at Google Summit

58 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 5: Deal with Heavy CI load (replication.config)

• Seconds to wait for network read or write to complete before giving up.

• Especially in WAN environments, don’t let this clog your replication queue

• Default was 0 (unlimited)

remote.NAME.timeout

S

M

L

30

45

60

Page 59: Gerrit Performance Tuning Talk at Google Summit

59 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Step 5: Deal with Heavy CI load (replication.config)

• Number of worker threads to dedicate to pushing to the repositories described by this remote.

• The more threads, the lower the chance get clogged by one problematic repository

• Default is 1

remote.NAME.threads

S

M

L

2

4

8

Page 60: Gerrit Performance Tuning Talk at Google Summit

60 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Follow Up Actions

• If you like our Cheat Sheet, share it: http://bit.ly/1kmpO7V

• Come up with an official “Gerrit T-Shirt Sizing” Approach

• Provide sample configurations for different T-Shirt sizes

• Adjust gerrit.config default options if completely off even for small load

Page 61: Gerrit Performance Tuning Talk at Google Summit

61 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

S M L

sshd

threads 1.5*<core> 8 32 64batchThreads 0 2 4 8commandstartThreads 2 2 3 5

httpd maxThreads 25 25 50 100

databasepoolLimit 8 50 150 250poolMaxIdle 4 16 16 16

corepackedGitLimit 10m 1g 4g 8gpackedGitWindowSize 8k 8k 16k 16kpackedGitOpenFiles 128 1024 2048 4096

container heapLimit - 4g 16g 32greceive timeOut 2min 4min 4min 4min

Gerrit Defaults

Summing up gerrit.config options

Page 62: Gerrit Performance Tuning Talk at Google Summit

62 Copyright ©2015 CollabNet, Inc. All Rights Reserved.62 Copyright ©2015 CollabNet, Inc. All Rights Reserved.

Questions?

Johannes Nicolai

[email protected]+1-650-228-2500+1-888-778-9793blogs.collab.nettwitter.com/collabnetwww.facebook.com/collabnetwww.linkedin.com/company/collabnet-inc


Recommended