SlideShare une entreprise Scribd logo
1  sur  46
Boston.rb
April 11, 2017
____________________________________________________
© 2017 ezCater, Inc. 1
Welcome to ezCater!
++
+
Welcome to ezCater!
++
+
engineering.ezcater.com
Who am I?
http://twitter.com/jdwyahJeff Dwyer
Who am I?
Who am I?
Who am I?
Who am I?
TONIGHT
• Why do I think RateLimits are amazing?
• The RateLim.it Architecture
• DIY Heroku with Amazon ECS & Terraform
• Big Data for Cheap: AWS Athena
RateLimits!
RateLimits!
RateLim.it Architecture
RateLim.it Architecture
RateLim.it Architecture
RateLim.it Architecture
RateLim.it Architecture
RateLim.it Architecture
Amazon EC2 Container Service (ECS)
Amazon EC2 Container Service (ECS)
RateLim.it Architecture
RateLim.it Architecture
RateLim.it Architecture
RateLim.it Architecture
RateLimits!
DIY Heroku with Amazon ECS & Terraform
So how do I actually deploy?
1) Build a Docker Image and push it to your docker repository
1) docker tag whatsize_ecr:36ba45
2) Create a new ECS “Task” that points to 36ba45
3) Tell the ECS Service to start running 36ba45 instead.
4) Sit back and watch the Magic!
Why ECS?
• Frankly it’s easier than the alternatives
• Runs anything that you can Docker
• Blue/Green Deployments out of the box
• Decent UI
• Deep understanding of autoscaling
• Very cost efficient. Bin Packing.
How do I start ECS?
API Usage Logging
API Usage Logging
API Usage Logging
AWS Athena
Wrap?
– ECS is awesome!! You may really like it.
– https://github.com/jdwyah/rails-docker-ecs-datadog-traceview-terraform
– Need RateLimits or featureflags? Try https://www.ratelim.it
• Ruby Library https://github.com/jdwyah/ratelimit-ruby
• Java library https://github.com/jdwyah/ratelimit-java
– Subscribe to http://engineering.ezcater.com
– https://twitter.com/jdwyah
– Questions?

Contenu connexe

Tendances

Tendances (8)

Keyracer
KeyracerKeyracer
Keyracer
 
Amplify console
Amplify consoleAmplify console
Amplify console
 
The ultimate dilemma of choosing container environment on AWS: ECS, EKS or Fa...
The ultimate dilemma of choosing container environment on AWS: ECS, EKS or Fa...The ultimate dilemma of choosing container environment on AWS: ECS, EKS or Fa...
The ultimate dilemma of choosing container environment on AWS: ECS, EKS or Fa...
 
Working with Azure Cosmos DB in Azure Functions
Working with Azure Cosmos DB in Azure FunctionsWorking with Azure Cosmos DB in Azure Functions
Working with Azure Cosmos DB in Azure Functions
 
Send Balls Into Orbit with Python3, AsyncIO, WebSockets and React
Send Balls Into Orbit with Python3, AsyncIO, WebSockets and ReactSend Balls Into Orbit with Python3, AsyncIO, WebSockets and React
Send Balls Into Orbit with Python3, AsyncIO, WebSockets and React
 
Moving your share point development to azure
Moving your share point development to azureMoving your share point development to azure
Moving your share point development to azure
 
Free Your On-Premises Data
Free Your On-Premises DataFree Your On-Premises Data
Free Your On-Premises Data
 
Lap around ASP.NET 5 - Dayton UG
Lap around ASP.NET 5 - Dayton UGLap around ASP.NET 5 - Dayton UG
Lap around ASP.NET 5 - Dayton UG
 

Similaire à DIY Heroku using Amazon ECS and Terraform

Live Content: Finding new ways to publish
Live Content: Finding new ways to publishLive Content: Finding new ways to publish
Live Content: Finding new ways to publish
ckimrie
 

Similaire à DIY Heroku using Amazon ECS and Terraform (20)

ARC205_Born in the Cloud
ARC205_Born in the CloudARC205_Born in the Cloud
ARC205_Born in the Cloud
 
Managing Container Images with Amazon ECR - AWS Online Tech Talks
Managing Container Images with Amazon ECR - AWS Online Tech TalksManaging Container Images with Amazon ECR - AWS Online Tech Talks
Managing Container Images with Amazon ECR - AWS Online Tech Talks
 
Scaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million UsersScaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million Users
 
Developing with .NET Core on AWS: What's New (DEV318-R1) - AWS re:Invent 2018
Developing with .NET Core on AWS: What's New (DEV318-R1) - AWS re:Invent 2018Developing with .NET Core on AWS: What's New (DEV318-R1) - AWS re:Invent 2018
Developing with .NET Core on AWS: What's New (DEV318-R1) - AWS re:Invent 2018
 
ARC201_Scaling Up to Your First 10 Million Users
ARC201_Scaling Up to Your First 10 Million UsersARC201_Scaling Up to Your First 10 Million Users
ARC201_Scaling Up to Your First 10 Million Users
 
Design, Build, and Modernize Your Web Applications with AWS
 Design, Build, and Modernize Your Web Applications with AWS Design, Build, and Modernize Your Web Applications with AWS
Design, Build, and Modernize Your Web Applications with AWS
 
AWS Cloud Technology And Future of Faster Modern Architecture
AWS Cloud Technology And Future of Faster Modern ArchitectureAWS Cloud Technology And Future of Faster Modern Architecture
AWS Cloud Technology And Future of Faster Modern Architecture
 
Moving to Amazon ECS – the Not-So-Obvious Benefits - CON356 - re:Invent 2017
Moving to Amazon ECS – the Not-So-Obvious Benefits - CON356 - re:Invent 2017Moving to Amazon ECS – the Not-So-Obvious Benefits - CON356 - re:Invent 2017
Moving to Amazon ECS – the Not-So-Obvious Benefits - CON356 - re:Invent 2017
 
Case Study: Sprinklr Uses Amazon EBS to Maximize Its NoSQL Deployment - DAT33...
Case Study: Sprinklr Uses Amazon EBS to Maximize Its NoSQL Deployment - DAT33...Case Study: Sprinklr Uses Amazon EBS to Maximize Its NoSQL Deployment - DAT33...
Case Study: Sprinklr Uses Amazon EBS to Maximize Its NoSQL Deployment - DAT33...
 
Live Content: Finding new ways to publish
Live Content: Finding new ways to publishLive Content: Finding new ways to publish
Live Content: Finding new ways to publish
 
Innovations fueled by IoT and the Cloud
Innovations fueled by IoT and the CloudInnovations fueled by IoT and the Cloud
Innovations fueled by IoT and the Cloud
 
Kubernetes for Docker Users
Kubernetes for Docker UsersKubernetes for Docker Users
Kubernetes for Docker Users
 
21st Century Analytics with Zopa
21st Century Analytics with Zopa21st Century Analytics with Zopa
21st Century Analytics with Zopa
 
Designing Well-Architected Microsoft Workloads in AWS (WIN333) - AWS re:Inven...
Designing Well-Architected Microsoft Workloads in AWS (WIN333) - AWS re:Inven...Designing Well-Architected Microsoft Workloads in AWS (WIN333) - AWS re:Inven...
Designing Well-Architected Microsoft Workloads in AWS (WIN333) - AWS re:Inven...
 
Zestimate Lambda Architecture
Zestimate Lambda ArchitectureZestimate Lambda Architecture
Zestimate Lambda Architecture
 
Kubernetes on AWS with Amazon EKS
Kubernetes on AWS with Amazon EKSKubernetes on AWS with Amazon EKS
Kubernetes on AWS with Amazon EKS
 
Navigating Microservice Architecture with AWS - AWS Public Sector Summit Sing...
Navigating Microservice Architecture with AWS - AWS Public Sector Summit Sing...Navigating Microservice Architecture with AWS - AWS Public Sector Summit Sing...
Navigating Microservice Architecture with AWS - AWS Public Sector Summit Sing...
 
STG401_This Is My Architecture
STG401_This Is My ArchitectureSTG401_This Is My Architecture
STG401_This Is My Architecture
 
Mongo DB at Community Engine
Mongo DB at Community EngineMongo DB at Community Engine
Mongo DB at Community Engine
 
MongoDB at community engine
MongoDB at community engineMongoDB at community engine
MongoDB at community engine
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

DIY Heroku using Amazon ECS and Terraform

Notes de l'éditeur

  1. Welcome to ezCater. Since we’re giving you pizza I get to pitch you on workign here! Do you like: Tacos, Ruby, Graphs that go up and to the right & 100% Nice People?
  2. Then you’ll love working at ezCater! Check us out https://www.ezcater.com/company/careers/ Seriously though, great things are happening here and we are growing > 2x year over year. It’s fun.
  3. Check out our new engineering blog https://engineering.ezcater.com/ab-testing-at-ezcater-part-2-tracking-experiments-the-exposure-event
  4. So who am I? Jeff Dwyer http://twitter.com/jdwyah Http://blog.jdwyah.com I’ve worked at PatientsLikeMe, HubSpot and now ezCater
  5. But like lots of you I have side projects too! Like http://forcerank.it The best way to prioritize your trello backlog as a team!
  6. Like http://whatsize.is The best way to know that 24 Months in Carters is 2T June & January, but 90mm in Hannah Anderson and 12-18 months in H&M
  7. Like http://ratelim.it The best way to get a distributed rate limiter in the cloud.
  8. So like most of you, I rely heavily on Heroku for all these side project. All fun and games, because it’s free, and the only cost is that all your app ideas take a full minute or so to boot on the first request.
  9. Tonight’s agenda
  10. When I worked at HubSpot I had access to a really powerful distributed rate limiter that could handle millions and millions of individual limits, and would persist the limits / token buckets forever. This was AMAZING because it meant I could use these limits to save tons of money on our UsageTracking bill, but also I could use it for Idempotency enforcement by having “infinite” limits. I used this to great effect to save money in lots of fun places. It’s an amazing hammer.
  11. So I left HubSpot and of course didn’t have access to my favorite tool. I needed to build a new one for myself. So what is rate limiting? Here’s the basic API I wanted to support.
  12. Most people think of Redis or Memcached for rate limits and those are very good for many limits, but the “eternal” rate limits I want to support are not well suited to Redis. Dynamo is a better solution for long term storage.
  13. But Redis is still great and sometimes rate limits are going to get pounded, so we should front Dynamo with Redis
  14. Fronting Dynamo with Redis means you still need to write to the backing store. The solid way to do this is a Queue and Writer. (You’ll notice we’re up to 2 services now)
  15. Of course I want http://ratelim.it to be a little SaaS. I’m not crazy so I’m not going to write a CRUD app in Java, so we have a Ruby on Rails app too.
  16. One thing that is a trick with Dynamo is that it doesn’t autoscale. But you’re going to have bursty traffic, so you’ll need to have something autoscale for you.
  17. They best option is a long running python project that polls your dynamo tables and scales them when they get close. (So now we’ve got 4 services)
  18. So how in the heck am I going to run all these things? My heroku bill is going to start to be problematic and these services are things that I really want to be “cheap to run & scale” since we’re planning to charge 5 millionths of a penny. There’s not room for much overhead. Amazon ECS says it will do all this….
  19. And their video is cute…
  20. So here’s the basic architecture of the AWS services I want.
  21. I deem this “do-able” even with my not-so-great understanding of AWS.
  22. Oops, forgot Application Load Balancers.
  23. Oops and IAM Roles, RolePolicies, AutoScalingGroups. SecurityGroups, VPCs, LaunchConfigurations, aws_acm_certificate, ECR repositories…
  24. Here’s ¼ of the end result of how many resources I’ve got.
  25. Let’s pause here and say that before this endeavor I had just about no idea what all this AWS infrastructure really was.
  26. I just wanted to declare what resources I wanted and then let something figure it out. Isn’t there anything that does that? Luckily there is! https://www.terraform.io
  27. So, what does Terraform look like? Well it’s pretty amazingly just-what-you-hoped-it-would-look-like. Here are the ECS Services and Tasks
  28. You can see that each task defines how much memory and cpu it needs
  29. You can see that we’re able to avoid checking secrets into terraform by using template files.
  30. For a Rails app, you probably have at least 2 tasks. The task for the server which will be run in a service. And then a separate task that runs db:migrate. That you can just run ad-hoc.
  31. Here’s building a docker image
  32. And pushing docker image to ECR
  33. Here’s terraform plan, which tells you what it is going to do.
  34. Then terraform apply which actually tells ECS to swap which task the service is running.
  35. Within ECS you can see that it starts the new task, hits the health check. Once that’s good it registers it in the ALB. And starts draining connections to the old task. Then removes the old task and reaches steady state.
  36. ECS is really easy to set up to pipe logs to cloudwatch
  37. Running a https://www.datadoghq.com agent in ECS is totally doable and means you get great dashboards about what is happening in your cluster right out of the box.
  38. So why consider ECS to run your Docker images?
  39. http://blog.jdwyah.com/2016/02/ruby-on-rails-on-docker-on-amazon-ecs-w.html and https://github.com/jdwyah/rails-docker-ecs-datadog-traceview-terraform have links to some basic terraform files that will point you in the right direction.
  40. The last hurdle for RateLim.it was figuring out how to actually log & process everyone’s API usage efficiently. Remember we have to serve the request in less than .000005 dollars for there’s not a lot of room.
  41. Amazon API Gateway was just going to be too expensive at these margins.
  42. Instead Kinesis Firehose pointed to S3 and queried with https://aws.amazon.com/athena/ has proved to be a really delightful option. If you have a lot of data in S3 that you need to query with irregular ad-hoc queries you’ve got to check out Athena.
  43. Here’s what Athena looks like.
  44. Wrap up!