Upload
johan
View
951
Download
2
Embed Size (px)
Citation preview
Application requirements
• Global high availability
• Global low latency
Usage pattern
• "The long tail of map requests"
11
Client• Browser loads an embedded map
• Browser loads tile-by-tile
https://tiles.mapbox.com/v4/map.id/17/70428/42997.png?access_token=pk.xxx
16
Client → DNS
CDN (Content Distribution Network)• Cloudfront: AWS CDN
• Terminate TLS
• Cache based on url & query string
https://tiles.mapbox.com/v4/map.id/17/70428/42997.png?access_token=pk.xxx
19
Client → DNS
CDN (Content Distribution Network)• find the nearest edge location
• TTL of 5 minutes
• ~35% cache hits
22
Client → DNS
CDN (Content Distribution Network)• On cache miss:
• Continue request to origin server
23
Client → DNS → CDN
DNS• Route53: Amazon DNS
• Mapbox.com serves maps from 8 regions
• Route to "best region for request based on latency"
26
Client → DNS → CDN -> DNS
Load Balancer• ELB: Amazon Elastic Load Balancer
• Terminate TLS
• Route requests to application servers
28
Client → DNS → CDN -> DNS -> Load Balancer
Application Servers• EC2: Amazon Elastic Compute Cloud
• Virtual Machines
• EC2 instances are provisioned via Auto Scaling Group
• Auto Scaling is based on instance CPU load
• Scale up/down if CPU load over/under 55%/20% for 2 minutes
29
Client → DNS → CDN -> DNS -> Load Balancer
Application Servers• Node.js/Express
• Authentication
• Determine location of tiles
• Fetch tiles and return them
30
Client → DNS → CDN -> DNS -> Load Balancer
Application ServersFetching tiles
• check simultanously in local cache (redis) and object store (s3)
• return from where is found first
• if only found in object store, update local cache
31
Client → DNS → CDN -> DNS -> Load Balancer
Application ServersCache vs. Object Store
• redis: 50% cache hits
• (60% non-cdn = 30% total requests)
• redis is used as least-recently used cache, thus popular tiles for a region are usually cached
• redis is provisioned by AWS via ElastiCache32
Deploy to many regions• constantly have around 300 EC2 instances running
• last months spike was 1000 EC2 instances (batch jobs)
• can't care for individual EC2 instances
• every developer handles deployment themselves
38
Deploying cloudformation stacks
mapbox-cli
• the tool, the infrastructure team gives to developers
• abstracts and automates common tasks
• encodes our conventions for using AWS
40
Deployment strategies• Sequential
• Parallel
• Probed
• one region first
• wait for alerts
• all other regions parallel
43
Deploys with interruptions• Take region out of Route 53
• Wait for traffic to cease
• Update stack
• Put region back into Route 53
44
• mapbox-cli is built with node.js
• mostly based around the aws-js sdk
• github.com/mapbox
• cfn-config
• cfn-stack-event-stream
• as-replace-instances
45
Future directions• deploybot
• send some traffic to staging/canary stacks
• docker for speeding up instance start time
46
Thanks
• github.com/mapbox
• cfn-config
• cfn-stack-event-stream
• as-replace-instances
48