diff --git a/README.md b/README.md index ea63d19..d9a25b4 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,14 @@ Lightweight URL shortener API service with minimal resource requirements. Average memory consumption is under **20MiB** and single CPU core consumption under 20%. -bit is highly performant, achieving in average **3K RPS** with a minimum latency of 56ms (100K requests using 100 connections, [benchmark](docs/SETUP.md#benchmark)). +Performance: Avg **3K reqs/sec**, latency 56ms (100K requests using 100 connections, [benchmark](docs/SETUP.md#benchmark)). Self-hosted with [Dokku](docs/SETUP.md#dokku) and [Docker Compose](docs/SETUP.md#docker-compose). Images available on [Docker Hub](https://hub.docker.com/r/sjdonado/bit/tags). ## Why bit? -It is feature-complete by design. Its strength lies in simplicity, a reliable URL shortener without unnecessary bloat. Bug fixes will continue, but new features aren't planned. +It is feature-complete by design. Its strength lies in simplicity, reliable without unnecessary bloat. Bug fixes will continue, but new features aren't planned. - Minimal tracking setup: Country, browser, os, referer. No cookies or persistent tracking mechanisms are used beyond what's available from a basic client's request. - Flexible request forwarding system passes client context to destinations via standard `X-Forwarded-For` and `User-Agent` headers, enabling advanced tracking and integration capabilities when needed. diff --git a/app/controllers/link.cr b/app/controllers/link.cr index 79ade57..98c91aa 100644 --- a/app/controllers/link.cr +++ b/app/controllers/link.cr @@ -34,6 +34,7 @@ module App::Controllers end link.clicks = [] of App::Models::Click + render_json({"data" => App::Serializers::Link.new(link)}, 201) end @@ -71,7 +72,8 @@ module App::Controllers query = query.order_by("id DESC").limit(limit + 1) links = Database.all(Link, query) - return paginated_response(links, limit) { |link| App::Serializers::Link.new(link) } + + paginated_response(links, limit) { |link| App::Serializers::Link.new(link) } end def get @@ -106,7 +108,8 @@ module App::Controllers query = query.order_by("id DESC").limit(limit + 1) clicks = Database.all(Click, query) - return paginated_response(clicks, limit) { |click| App::Serializers::Click.new(click) } + + paginated_response(clicks, limit) { |click| App::Serializers::Click.new(click) } end def update diff --git a/docs/SETUP.md b/docs/SETUP.md index 101c879..2dc2cbc 100644 --- a/docs/SETUP.md +++ b/docs/SETUP.md @@ -113,9 +113,9 @@ RAM: 1GiB CPU: Apple M3 Pro **Summary** -- Requests/secs average central tendency: (1328.47 + 1357.19 + 1407.03) / 3 + (1785.03 + 1789.06 + 1778.84) / 3 = 3148.54 reqs/sec -- Latency average central tendency: (76.19 + 74.68 + 71.85) / 3 - (29.43 + 14.50 + 9.42) / 3 = 56.4ms -- Latency for conservative capacity planning: (76.19 + 74.68 + 71.85) / 3 + (29.43 + 14.50 + 9.42) / 3 = 89.63ms +- Reqs/sec (average central tendency): (1328.47 + 1357.19 + 1407.03) / 3 + (1785.03 + 1789.06 + 1778.84) / 3 = 3148.54 reqs/sec +- Latency (average central tendency): (76.19 + 74.68 + 71.85) / 3 - (29.43 + 14.50 + 9.42) / 3 = 56.4ms +- Latency (for conservative capacity planning): (76.19 + 74.68 + 71.85) / 3 + (29.43 + 14.50 + 9.42) / 3 = 89.63ms - Best single run: 18041.44 reqs/sec ```