Skip to content

Instantly share code, notes, and snippets.

View praagyajoshi's full-sized avatar
🌴
Summertime madness

Praagya Joshi praagyajoshi

🌴
Summertime madness
View GitHub Profile
@praagyajoshi
praagyajoshi / application.php
Created June 18, 2017 11:14
Config file for Kayako Twitter App
<?php
// App secrets and other constants
$ENV = [];
$ENV['TWITTER_CONSUMER_KEY'] = '-- snipped --';
$ENV['TWITTER_CONSUMER_SECRET'] = '-- snipped --';
// Autoloader
function twitterAppAutoloader($class) {

Technical test

The goal of this test is to evaluate your ability to architecture a small back-end service.
The service should expose a REST API endpoint and extract, transform and load a list of movies received via this endpoint in to Algolia.

Instructions

Expose a REST API endpoint

  • POST /1/load

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.