Yelp's internal caching proxy, powered by Nginx and OpenResty at its core
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
api_docs Opensources Casper. Feb 14, 2018
bin Opensources Casper. Feb 14, 2018
config Adding option to disable stdout logs Feb 6, 2019
itest Revert "Merge pull request #49 from Yelp/CORESERV-7327_casper_sets_x-… Feb 8, 2019
lua Revert "Merge pull request #49 from Yelp/CORESERV-7327_casper_sets_x-… Feb 8, 2019
tests Revert "Merge pull request #49 from Yelp/CORESERV-7327_casper_sets_x-… Feb 8, 2019
.busted Opensources Casper. Feb 14, 2018
.dockerignore Remove tox dependency and download docker-compose with curl Feb 21, 2018
.gitignore Remove tox dependency and download docker-compose with curl Feb 21, 2018
.luacheckrc Opensources Casper. Feb 14, 2018
.luacov Opensources Casper. Feb 14, 2018
.travis.yml Make itests travis compatible Feb 22, 2018
Dockerfile.opensource Update openresty version Aug 6, 2018
LICENSE
Makefile
README.md Removes TODOs from README. Feb 28, 2018
lua-cassandra-dev-0.rockspec Revert "Use kaisen's lua-cassandra to debug how often responses are h… Aug 24, 2018
start.sh Comment to explain the sed Feb 7, 2019

README.md

Casper (a friendly Spectre)

Build Status

This repo contains Casper, a caching proxy internal to Yelp. It is built with Nginx and Openresty at its core and contains some logic in Lua to fit in our ecosystem.

Important note about naming: Casper was initially baptized "Spectre" internally. It's only after the Spectre/Meltdown vulnerabilities were published that we decided to change the name to "Casper", a more friendly and less confusing name for the outside world. If you see remnants of "Spectre" in the code, that's why!

Requirements

  • docker: make sure it's installed on your system by following the instruction for your platform here.
  • make: ensure you can run make targets with your OS (on Windows, use nmake.)

Building locally

To start Casper, run

$ make dev

To make sure it's up (change the port accordingly if you change the default):

$ curl -v localhost:32927/status

For basic debugging (is it missing/hitting the cache? Am I being correctly proxied? etc), curl, and pay attention to the "Spectre-Cache-Status" header:

$ curl -o /dev/null -iv -H 'X-Source-Id: test' -H 'X-Smartstack-Destination: yelp-main.internalapi' -H 'X-Smartstack-Source: spectre.main' -H 'Host: internalapi' 'localhost:32927/category_yelp/?locale=en_US' 2>&1 | grep 'Spectre-Cache-Status'
< Spectre-Cache-Status: hit

To debug deeper it's highly recommended that you hop in the docker container in which nginx/lua are running with:

$ make inspect

It can help, to get as much information as possible, to set nginx logging to debug granularity. In nginx.conf, replace the error_log directive by:

error_log /var/log/nginx.debug.log debug;

Running Tests

To run unit tests:

$ make test

To run integration tests:

$ make itest

Contributors

Casper was built and developed internally for about a year before being opensourced. In addition to the contributors listed on Github, here is a list of people who contributed to Casper before its public life:

Contributing

We welcome contributions to Casper, but keep in mind that this is a production system run inside of Yelp's infrastructure. Please get in touch with us to discuss your feature request, bug fix or enhancement by opening a Github issue.