ruby.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
If you are interested in the Ruby programming language, come join us! Tell us about yourself when signing up. If you just want to join Mastodon, another server will be a better place for you.

Administered by:

Server stats:

1.1K
active users

postmodern

Lazy Rack: is there a rack middleware that will print stats like how many requests per second? Need to test some async HTTP code that sends lots of requests.

@postmodern would Rack calculate that… per thread? Or a shared process-wide calculation? Either way, you’d need to roll-up across all processes and nodes, yeah?

@postmodern I wrote up a quick gist you can use directly in your Gemfile or modify however you like

```
gem "rack-request_stats", gist: "jgaskins/8fa816a78dc15b7c210fb0503b9ab1ff"
```

```
require "bundler/setup"
require "rack-request_stats"

class App
def call(env)
[200, {"content-type" => "text/plain"}, ["hello"].freeze]
end
end

use Rack::RequestStats
run App.new
```

gist.github.com/jgaskins/8fa81

GistRack request statsRack request stats. GitHub Gist: instantly share code, notes, and snippets.

@postmodern It outputs like this:

```
➜ rack_stats ruby --yjit -S rackup -q
------8<-------
I, [2024-05-10T20:28:48.584115 #50773] INFO -- : #<struct Rack::RequestStats::Stats count=35, requests_per_sec=34.79222085858553, concurrent=0>
I, [2024-05-10T20:28:49.589550 #50773] INFO -- : #<struct Rack::RequestStats::Stats count=7770, requests_per_sec=7727.752377226935, concurrent=0>
````

@jamie nice and thank you!

Appears that using puma and YJIT, there's no real difference between 10 async fibers vs. 100 async fibers. Each averages at ~1k requests per second. Which at least tells me I can bruteforce ~1k directories per second.