how atlassian scales bitbucket data center on aws

86
How Atlassian Scales Bitbucket Data Center on AWS FELIX HAEHNEL DEVELOPER ATLASSIAN CHRIS SZMAJDA SENIOR TEAM LEAD • ATLASSIAN

Upload: atlassian

Post on 22-Jan-2018

4.771 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: How Atlassian Scales Bitbucket Data Center on AWS

How Atlassian Scales Bitbucket Data Center on

AWS FELIX HAEHNEL

DEVELOPER • ATLASSIANCHRIS SZMAJDA

SENIOR TEAM LEAD • ATLASSIAN

Page 2: How Atlassian Scales Bitbucket Data Center on AWS

Performance at scale Auto-scaling clusters in AWS

Bitbucket Data Center

BitbucketData Center@ Atlassian

Smart Mirrors

Disaster recovery

High availability and failover

Instant scalability

Page 3: How Atlassian Scales Bitbucket Data Center on AWS

C L U S T E R I N G I N AW S

S M A R T M I R R O R S

S C A L I N G B I T B U C K E T @ AT L A S S I A N

The Challenge: Scaling Bitbucket

@ Atlassian

D I S A S T E R R E C O V E RY

Page 4: How Atlassian Scales Bitbucket Data Center on AWS

Why scale @ Atlassian?

Page 5: How Atlassian Scales Bitbucket Data Center on AWS

Scale @ Atlassian

100,000’s of builds

1,000’s of users

Terabytes of dataRepositories and forks and moar, mostly on one central instance.

More Atlassians using Bitbucket every day.

Continuous integration hammering Bitbucket around the clock.

Page 6: How Atlassian Scales Bitbucket Data Center on AWS
Page 7: How Atlassian Scales Bitbucket Data Center on AWS

Sydney

Global Atlassian teams

Type your annotation here,the dotted line can be moved and/or re-sized.

San Fransisco

Austin

Manila

Tokyo

Amsterdam

London

Gdansk

Page 8: How Atlassian Scales Bitbucket Data Center on AWS

• Big cool statistic

• 2,569

• Add-Ons in Marketplace

Repository data

GBytes230422982312232622912282 227122642240222922122179214821302018200319931984197619511942192119061898187118551844181918091794177617521743 17211702168516711653

Page 9: How Atlassian Scales Bitbucket Data Center on AWS

OMG CI load!

1,000’s of agents

100,000’s of builds

Petabytes served

Page 10: How Atlassian Scales Bitbucket Data Center on AWS

Pull Request workflow

1,000’s of repo’s

100,000’s of PR’s

500,000+ comments

Page 11: How Atlassian Scales Bitbucket Data Center on AWS

Downtime

Page 12: How Atlassian Scales Bitbucket Data Center on AWS

S C A L I N G B I T B U C K E T @ AT L A S S I A N

S M A R T M I R R O R S

C L U S T E R I N G I N AW S

The Sky’s the Limit: Clustering in AWS

D I S A S T E R R E C O V E RY

Page 13: How Atlassian Scales Bitbucket Data Center on AWS

Clustering

Page 14: How Atlassian Scales Bitbucket Data Center on AWS

ClusteringLoad balancer

Cluster nodes

Page 15: How Atlassian Scales Bitbucket Data Center on AWS

What makes up a Data Center deployment?

Page 16: How Atlassian Scales Bitbucket Data Center on AWS

Cluster nodes

Database

File Server (NFS)

Elasticsearch

Bitbucket Data Center deployment model

Load balancer

Page 17: How Atlassian Scales Bitbucket Data Center on AWS

Cluster nodes

Database

File Server (NFS)

Elasticsearch

Bitbucket Data Center deployment model

Load balancerSimple but powerful

No lock-in stacks.

Takes advantage of your infrastructure.

Scales as you grow.

Page 18: How Atlassian Scales Bitbucket Data Center on AWS

Data Center, in AWS?

Page 19: How Atlassian Scales Bitbucket Data Center on AWS

Why AWS? Managed services

Elastic scale

Total Cost of OwnershipCheaper in the long run.

Grow from micro to massive in minutes.

Saves time.

Page 20: How Atlassian Scales Bitbucket Data Center on AWS

AWS Services

Page 21: How Atlassian Scales Bitbucket Data Center on AWS

Auto Scaling

Auto Scaling Group

Elastic Load Balancer

Page 22: How Atlassian Scales Bitbucket Data Center on AWS

Relational Database Service (RDS)

Automaticupgrades

ReadReplicas

MultipleAvailability

Zones

Scale

Page 23: How Atlassian Scales Bitbucket Data Center on AWS

Elasticsearch Service (ES)

Scale

SecurityCode andrepository

Search

Page 24: How Atlassian Scales Bitbucket Data Center on AWS

Disaster RecoveryPerformance Zero Downtime BackupSnapshot in under a second.

Restore in minutes.Low latency.

Up to 16 Terabytes.Up to 20,000 IOPS.

Copy snapshots offsite.

Elastic Block Store (EBS)

Page 25: How Atlassian Scales Bitbucket Data Center on AWS

Auto ScalingGroup

Amazon RDS

NFS Server

AmazonElasticsearch

EBSvolume

AmazonELB

Bitbucket DC AWSdeployment model

Page 26: How Atlassian Scales Bitbucket Data Center on AWS

Availability Zones

Page 27: How Atlassian Scales Bitbucket Data Center on AWS

AWS Availability Zones Low latency

Typically several miles apart.

Within one RegionEqually visible across the whole Region.

Isolated data centers

Connected by fast network links.

Page 28: How Atlassian Scales Bitbucket Data Center on AWS

Why more than one AZ?

Page 29: How Atlassian Scales Bitbucket Data Center on AWS

us-east-1a

Availability Zones

us-east-1b

Page 30: How Atlassian Scales Bitbucket Data Center on AWS

EBSRDSELB

Auto Scaling GroupElasticsearch Service

Availability Zones for Bitbucket DC

Use two or more AZ’s.

Enable cross zone load balancing.

Enable Multi-AZ deployment.

Deploy two or more nodes.

Enable Zone Awareness.

Snapshot often.

Consider Cloud NAS products for AWS.

Page 31: How Atlassian Scales Bitbucket Data Center on AWS

What about scale?

Page 32: How Atlassian Scales Bitbucket Data Center on AWS

Elastic scale

Scaling in AWS

More nodes = greater capacity

Load tests

Type your annotation here,the dotted line can be moved and/or re-sized.

AWS makes it easy to scale up capacity.

Larger clusters can serve bigger workloads.

Representing 10,000’s of typical users and build agents.

Thro

ughp

ut (T

PS)

10

20

30

40

50

60

70

Concurrent requests0 40 80 120 160 200 240 280

1 node 2 nodes 4 nodes 8 nodes 12 nodes

Page 33: How Atlassian Scales Bitbucket Data Center on AWS

Choose the right instances

IOPS = Happiness ☺Scale up, then out

Scale vertically with bigger instances first.

Then scale horizontally

with more nodes.

Bitbucket’s largest workload is Git.

Give it enough IOPS.

Different instance types have different balances of

CPU, memory, and I/O.

Choose wisely.

Scaling in AWS: Pro tips

Page 34: How Atlassian Scales Bitbucket Data Center on AWS

How did we do it?

Page 35: How Atlassian Scales Bitbucket Data Center on AWS

How we did it

Page 36: How Atlassian Scales Bitbucket Data Center on AWS

How we did it

Loose coupling

Stateless nodes

Highly tuned cachesKeep “hot” data in fast local storage.

Extremely light JVM memory footprint.

Minimizes node-to-node communication.

Don’t maintain any state that can’t be reconstructed from other sources.

Storage optimizationsMinimize use of the shared file system.

Page 37: How Atlassian Scales Bitbucket Data Center on AWS

How we did it

Source Code Management cacheIntercepts Git requests and caches the responses on each node (in AWS, on an Instance Store device).

Saves CPU and memoryEvery cache hit saves a Git process.

Saves NFS trafficTakes load off the shared file system.

Cluster awareLightweight cache consistency between nodes.

Git request

NFS

git

response

SCMcache

anotherGit request

cachedresponse

Git push

invalidations

lotsa Gitrequests

lotsa cachedresponsesCI agents generate many Git requests

Page 38: How Atlassian Scales Bitbucket Data Center on AWS

That’s great!

But how do I deploy it all?

Page 39: How Atlassian Scales Bitbucket Data Center on AWS

Deploying in AWS

Auto Scaling Group

ELB

RDS instance

Elasticsearch

EC2 file server

Scaling policies

Security Group

VPC

Subnets

EBS volume

Provisioned IOPS

Instance Stores

IAM Role

Listeners

Manually create … ?

Page 40: How Atlassian Scales Bitbucket Data Center on AWS

Deploy in a few clicks

One template = many resourcesOne JSON file that describes an entire stack of AWS resources: ELB, ASG, EC2, EBS, RDS, ES, …

Create, update, and delete stacks from the AWS Console or CLI.

AWS CloudFormation

Page 41: How Atlassian Scales Bitbucket Data Center on AWS

AWS CloudFormation

Page 42: How Atlassian Scales Bitbucket Data Center on AWS

Auto ScalingGroup

Amazon RDS

NFS Server

AmazonElasticsearch

EBSvolume

AmazonELB

CloudFormation{ "AWSTemplateFormatVersion": "2010-09-09", "Description": "Atlassian Bitbucket Data Center", "Metadata": { ... }, "Parameters": { ... }, "Resources": { "ClusterNodeGroup": { "Type": "AWS::AutoScaling::AutoScalingGroup", ... }, ... }

Page 43: How Atlassian Scales Bitbucket Data Center on AWS

Bitbucket Amazon Machine Image (AMI)

Based onAmazon Linux

“Bitbucket Server”

Multi-role:

Any versionof Bitbucket

“Cluster node”

“File server”

Public in all AWS Regions

Page 44: How Atlassian Scales Bitbucket Data Center on AWS

https://bitbucket.org/atlassian/atlassian-aws-deployment

Page 45: How Atlassian Scales Bitbucket Data Center on AWS

AWS Quick Start

Page 46: How Atlassian Scales Bitbucket Data Center on AWS

AWS Quick Start

Free credits!

Best practices

Single click deployComplete CloudFormation template for Bitbucket Data Center and VPC.

Designed by Amazon solutions architects for security and scale.

Amazon is offering free credits with all Atlassian AWS Quick Starts.

Page 47: How Atlassian Scales Bitbucket Data Center on AWS
Page 48: How Atlassian Scales Bitbucket Data Center on AWS

https://atlassian.com/aws

Page 49: How Atlassian Scales Bitbucket Data Center on AWS

C L U S T E R I N G I N AW S

S C A L I N G B I T B U C K E T @ AT L A S S I A N

S M A R T M I R R O R S

Mirror, mirror on the wall:Smart Mirrors

D I S A S T E R R E C O V E RY

Page 50: How Atlassian Scales Bitbucket Data Center on AWS

Austin

“Prod”(N. Virginia)

San Fransisco

Page 51: How Atlassian Scales Bitbucket Data Center on AWS

“Prod”(N. Virginia)

AustinSan Fransisco

Tokyo

Gdańsk

Sydney

Page 52: How Atlassian Scales Bitbucket Data Center on AWS

San Fransisco

Tokyo

Gdańsk

“Prod”(N. Virginia)

Sydney

Austin

Page 53: How Atlassian Scales Bitbucket Data Center on AWS

San Fransisco

Tokyo

Gdańsk

“Prod”(N. Virginia)

Austin

Sydney

Page 54: How Atlassian Scales Bitbucket Data Center on AWS

Smart Mirror (AU)

FishEye/Crucible

JIRA

Confluence

Bamboo

Bitbucket Server

Minutes0 25 50 75 100

How much faster is a mirror?

Page 55: How Atlassian Scales Bitbucket Data Center on AWS

On average over

faster to clone!

8x

Page 56: How Atlassian Scales Bitbucket Data Center on AWS

Setup Wizard

AWS CloudFormationLaunch Bitbucket with application.mode=mirror.Deploying

Mirrors in AWS

Page 57: How Atlassian Scales Bitbucket Data Center on AWS

That’s great!

But how does it work?

Page 58: How Atlassian Scales Bitbucket Data Center on AWS

How it works

PrimaryBitbucket

Mirror

Page 59: How Atlassian Scales Bitbucket Data Center on AWS

PrimaryBitbucket

Mirror

How it works

Page 60: How Atlassian Scales Bitbucket Data Center on AWS

How it works

PrimaryBitbucket

Mirror

Page 61: How Atlassian Scales Bitbucket Data Center on AWS

How it works

PrimaryBitbucket

Mirror

Page 62: How Atlassian Scales Bitbucket Data Center on AWS

How it works

PrimaryBitbucket

Mirror

Page 63: How Atlassian Scales Bitbucket Data Center on AWS

How it works

PrimaryBitbucket

Mirror

Page 64: How Atlassian Scales Bitbucket Data Center on AWS

How it works

PrimaryBitbucket

Mirror

Page 65: How Atlassian Scales Bitbucket Data Center on AWS

What makes Smart Mirroring

smart?

Page 66: How Atlassian Scales Bitbucket Data Center on AWS

PrimaryBitbucket

Mirror

How it works

Forks optimizedSaves disk space on the primary Bitbucket instance.

Mirrors fetch only onceSaves disk space and network bandwidth on the mirror.

repository

forkforksmirrored forks

Page 67: How Atlassian Scales Bitbucket Data Center on AWS

How it worksGit LFS optimizedLarge files fetched only when needed.

large files

Each large file fetched only once.

Saves disk space and bandwidth.

PrimaryBitbucket

Mirror

repository

mirrored large files

Page 68: How Atlassian Scales Bitbucket Data Center on AWS

PrimaryBitbucket

Mirror

Mirrors can be for CI, too

CI agents

“Build” mirrorsTake load off your primary Bitbucket instance.

Page 69: How Atlassian Scales Bitbucket Data Center on AWS

C L U S T E R I N G I N AW S

S M A R T M I R R O R S

D I S A S T E R R E C O V E RY

Always have a plan B:Disaster recovery

S C A L I N G B I T B U C K E T @ AT L A S S I A N

Page 70: How Atlassian Scales Bitbucket Data Center on AWS

Disasters 101

Always have a backup ALWAYS have a backup

Page 71: How Atlassian Scales Bitbucket Data Center on AWS

Cluster nodes

Database

File Server

Elasticsearch

Backing up Bitbucket

Load balancerBitbucket backup client?Only recommended for small instances.

Rsync?Still requires some downtime.

Backup storageConsistent snapshots

Page 72: How Atlassian Scales Bitbucket Data Center on AWS

BackupZero Downtime

Page 73: How Atlassian Scales Bitbucket Data Center on AWS

Database File Server

Zero Downtime Backup

Backup storage

Amazon RDS

All DB vendors Many FS vendors

Amazon EBS

ZFS

Atomicsnapshots

Offsite snapshots

Amazon S3

Page 74: How Atlassian Scales Bitbucket Data Center on AWS

Downtime

Page 75: How Atlassian Scales Bitbucket Data Center on AWS

Primary Bitbucket(N. Virginia)

Sydney

Backups @ Atlassian

Round the clockBackups taken continually, sometimes minutes apart.

Backups copied offsiteCan be restored anywhere, in minutes.

AWSsnapshots

Sub-second latency.

Page 76: How Atlassian Scales Bitbucket Data Center on AWS

https://bitbucket.org/atlassianlabs/atlassian-bitbucket-diy-backup

Page 77: How Atlassian Scales Bitbucket Data Center on AWS

Disasters 201

Always have a standbyALWAYS have a backup

Page 78: How Atlassian Scales Bitbucket Data Center on AWS

Disaster recovery

Page 79: How Atlassian Scales Bitbucket Data Center on AWS

Disaster recovery

Primary instance Standby instance

Standbydatabase

Standbyfile server

RDS read replica

All DB vendors

ZFS

Many FS vendors

Page 80: How Atlassian Scales Bitbucket Data Center on AWS

my name is

Integrity Checker

Hello

Disaster recovery

Page 81: How Atlassian Scales Bitbucket Data Center on AWS

https://bitbucket.org/atlassianlabs/atlassian-bitbucket-diy-backup

Yes, it does Disaster recovery too

Page 82: How Atlassian Scales Bitbucket Data Center on AWS

Start replicating

AWS CloudFormationLaunch Bitbucket Data Center with DBMaster=<primary-db>.Deploying a

standby in AWS

setup-home-replication.sh replicate-home.sh

Page 83: How Atlassian Scales Bitbucket Data Center on AWS

BackupsDisaster recovery standby

Clustering

Handles isolated failures.

Works in seconds.

Handles failure of an entire data center.

Failover in minutes.

Handle failures that corrupt all your data.

Restore to anypoint in time.

High availability: Pro tips

Page 84: How Atlassian Scales Bitbucket Data Center on AWS

Smart Mirroring Disaster Recovery AWS Support and Quick Start

Page 85: How Atlassian Scales Bitbucket Data Center on AWS

https://atlassian.com/aws

FELIX HAEHNEL DEVELOPER • ATLASSIAN

CHRIS SZMAJDA SENIOR TEAM LEAD • ATLASSIAN

Page 86: How Atlassian Scales Bitbucket Data Center on AWS