Skip to content

Instantly share code, notes, and snippets.

View tierra's full-sized avatar

Bryan Petty tierra

  • Salt Lake City, UT
View GitHub Profile
@tierra
tierra / gist:645a5c9d905de44f6ff0
Created November 1, 2015 06:19
Five days of wxWidgets 3.0.2 downloads off of GitHub
bryan@ibaku:~$ ruby wx-downloads.rb
changes.txt: 3, 670 KB
README.md: 16, 110 KB
wxMSW-3.0.2-Setup.exe: 834, 37 GB
wxMSW-3.0.2_gcc471TDM_Dev.7z: 9, 350 MB
wxMSW-3.0.2_gcc471TDM_ReleaseDLL.7z: 14, 82 MB
wxMSW-3.0.2_gcc471TDM_x64_Dev.7z: 13, 660 MB
wxMSW-3.0.2_gcc471TDM_x64_ReleaseDLL.7z: 7, 75 MB
wxMSW-3.0.2_gcc481TDM_Dev.7z: 25, 960 MB
wxMSW-3.0.2_gcc481TDM_ReleaseDLL.7z: 19, 110 MB
@tierra
tierra / .dockerignore
Last active February 15, 2016 05:45
Modern phpBB Docker Configuration
.dockerignore
Dockerfile
docker-compose.yml
.git
.gitignore

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.

Document Size Limits:
DynamoDB: 400 KB
Datastore: 1 MB
CosmosDB: 2 MB
MongoDB: 16 MB
CouchDB: 20 MB
Cassandra: 2 GB (roughly several MB recommended)
RethinkDB: none (16 MB recommended)
ActiveSupport::Notifications.subscribe("sql.active_record") do |_, _, _, _, details|
if details[:sql] =~ /search_path/
puts details[:sql]
puts caller.join("\n")
puts "*" * 50
end
end
10:30 -ChanServ(ChanServ@services.)- Entry Nickname/Host Flags |
10:30 -ChanServ(ChanServ@services.)- ----- ---------------------- ----- |
10:30 -ChanServ(ChanServ@services.)- 1 raboof +AFRefiorstv (founder) (#wxwidgets) [modified ? ago, on Jan 01 00:00:00 1970] |
10:30 -ChanServ(ChanServ@services.)- 2 BrianHV +AFRefiorstv (founder) (#wxwidgets) [modified 12y 26w 2d ago, on Nov 18 21:50:41 2008]
Elastic Beanstalk (2011)
- EC2 / ASG based deployments
CloudFormation (2011)
- Designed for infrastructure management, but can be used for deployments too.
OpsWorks (2013)
- Infrastructure automation
CodeDeploy (2014)
drivetemp-scsi-3-0
Adapter: SCSI adapter
temp1: +39.0°C (low = +10.0°C, high = +40.0°C)
(crit low = +5.0°C, crit = +60.0°C)
(lowest = +37.0°C, highest = +50.0°C)
drivetemp-scsi-1-0
Adapter: SCSI adapter
temp1: +37.0°C (low = +10.0°C, high = +40.0°C)
(crit low = +5.0°C, crit = +60.0°C)