Skip to content

tanguilp/plug_http_cache_demo

Repository files navigation

PlugHTTPCacheDemo

This is a demo app for plug_http_cache.

This is composed of:

  • an Elixir project that uses plug_http_cache to cache results of expensive fibonacci calculations
  • a Tsung script that sends a lot of request locally to the Elixir project
  • a docker-compose.yml file that allows launching 3 instances of the Elixir project along with a nice Grafana dashboard that shows realtime stats of the caching services

Install & launch

Requires OTP25+. The disk-backend branch requires OTP26+

Type

mix deps.get

in the shell to install dependencies.

Launch locally

Type mix phx.server (or iex -S mix phx.server to have a shell) and visit localhost:4000.

In some browsers, typing the F5 key forces a refresh of the page (that is, without caching). You better type the Enter key in the address bar to make sure cached versions are used.

It launches with the memory http_cache_store_memory by default. To use the http_cache_store_disk backend instead, switch to the disk-backend branch (files will be saved in /tmp/http_cache/).

Launch through docker

Type:

docker-compose build && docker-compose up --renew-anon-volumes

Then visit the 3 instances:

and the dashboard: http://localhost:3000. The login and password are both admin. Then click on http_cache dashboard.

Tsung stress test

Install Tsung, and type in the shell:

tsung -f load-testing.xml start

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published