I beleive the stub module gives the number of requests since nginx was
last reloaded (or started). To get the number of rps, you have to query
the stub module each second and substract the old value from the current
value.
If you’ve logging enabled in some sort, you could use a Visual Log
Analyzer, I know some of them work for Apache-style logs, but it
requires the overhead of having logging enabled for your webserver.
Such log-analysers don’t need many resources, as they don’t require any
interaction with requests served by nginx, they just read the logs nginx
produces every x seconds.
Please remember that what you are looking for is a “human” value, as
opposed to the snapshot type of values the server can reliably provide.
The reason why nginx does not provide what you are looking for may be
that the server would have to provide several intervals to satisfy
everyone (second, millisecond, minute, hour, etc.), and that is neither
practical nor reliable. Such data could also be misleading, depending on
your use case. From a server point of view, the best thing to do was to
give a total number of requests served and let the admins do the math as
they see fit.
However, the stub status module provides easy-to-read data that you can
parse with a script in a loop, or such a script could dump the stats in
a database and you could then read that. That is the best long-term
solution to your problem. Please remember too that this database does
not need to be SQL, it could be RRD-based for example, or just plain
files, whatever suits you best.
If you are just interested in knowing Request per second and if you have
logging enabled then I would suggest using netcat. you just need to tail
the log file and then use the netcat to count the lines and it would
give you the details you need. Since the tail by default updates every 1
second you will get what you need.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.