Skip to content

Instantly share code, notes, and snippets.

View saga420's full-sized avatar
😀
Working from home

saga420 saga420

😀
Working from home
  • HOOLI XYZ
  • Making the world a better place
View GitHub Profile
@saga420
saga420 / aws_delete-default-vpc.sh
Created March 27, 2021 11:43 — forked from jokeru/aws_delete-default-vpc.sh
Script to delete all AWS default VPCs from all regions using AWS CLI
#!/usr/bin/env bash
if [ "$AWS_PROFILE" = "" ]; then
  echo "No AWS_PROFILE set"
  exit 1
fi
for region in $(aws ec2 describe-regions --region eu-west-1 | jq -r .Regions[].RegionName); do
@saga420
saga420 / Effectively using AWS Reserved Instances.md
Last active December 8, 2018 23:45
Effectively using AWS Reserved Instances

Effectively using AWS Reserved Instances

Learn how Stripe uses AWS Reserved Instances and capacity planning to effectively manage a dynamic, scalable cloud infrastructure: https://stripe.com/blog/aws-reserved-instances

Usage

Included are three files:

  • Makefile: This generates our Python environment for running the ETL.

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.