Skip to content

Instantly share code, notes, and snippets.

View djdongjin's full-sized avatar
🏠
Working from home

Jin Dong djdongjin

🏠
Working from home
View GitHub Profile

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.

@djdongjin
djdongjin / gsoc.md
Last active September 4, 2020 16:49
GSoC 2020 Summary

Google Summer of Code with TensorFlow

Mentors:

  • Elizabeth Kemp
  • Jaeyoun Kim

This is a summary of my GSoC project: New Tools for TensorFlow Hub. In this project, I extended and created tools that build models from command line directly. At the end, I reproduced a RoBERTa model using TF2.

A detailed blog post about the project can be found at TBD.