Skip to content

Latest commit

 

History

History
70 lines (46 loc) · 1.8 KB

README.md

File metadata and controls

70 lines (46 loc) · 1.8 KB

fib

Fibonacci numbers as a service. Simple service to show ring-boost functionality.

Running

To start a web server for the application, run:

lein ring server-headless

Then make a request:

$ curl -is http://localhost:3000/fib/100

HTTP/1.1 200 OK
Date: Sat, 14 Apr 2018 10:36:46 GMT
ETag: 30647e5b994dc46db920c54bfebfe5f0
Content-Type: application/json; charset=utf-8
Content-Length: 55
Server: Jetty(7.6.13.v20130916)

{"status":"OK","pos":"100","fib":573147844013817084101}

If you want to see ring-boost debugging headers add the following request header x-cache-debug: 1

$ curl -is -H 'x-cache-debug: 1' http://localhost:3000/fib/100

HTTP/1.1 200 OK
Date: Sat, 14 Apr 2018 10:39:30 GMT
ETag: 30647e5b994dc46db920c54bfebfe5f0
X-CACHE: RING-BOOST/v0.1.3
X-RING-BOOST-CACHE: CACHE-HIT
X-RING-BOOST-CACHE-PROFILE: :fib-numbers
X-RING-BOOST-CACHE-STATS1: 11/3/0
X-RING-BOOST-CACHE-STATS2: 45/20/5
Content-Type: application/json; charset=utf-8
Content-Length: 55
Server: Jetty(7.6.13.v20130916)

{"status":"OK","pos":"100","fib":573147844013817084101}

Now try with a larger number like:

 # the first time will take a while
 curl -is -H 'x-cache-debug: 1' http://localhost:3000/fib/1000000

Running again, now it will be fetched from the cache.

Here is the latency profile for the fibonacci service with and without ring-boost

comparison

Computed via: wrk -t2 -c100 -d180s -R500 -L http://127.0.0.1:3000/fib/10000

As you can see the difference of a slow service with and without ring-boost it is huge. The slower is the service and the more intensive is the computation the bigger is the advantage of using ring-boost.

License

Copyright © 2018 Bruno Bonacci - Distributed under the Apache License v 2.0 (http://www.apache.org/licenses/LICENSE-2.0)