On Wed, Sep 2, 2015 at 5:49 PM, Christian Pedersen
<[email protected]> wrote:
> Hi!
>
> Is it possible to query the number of busy/idle unicorn workers? For
> scaling purposes, I would like to be able to see the utilisation of
> the unicorn workers, so I will know if I need to deploy more servers
> in peak hours or not. Currently the only measure I have is when
> machines top out and start serving 502's. I am not interested in
> queueing up requests, as the approach is to instead spin up additional
> capacity when needed.
>
> I notice on http://demo.nginx.com/status.html that one of the metrics
> under 'demoupstreams' is the number of active connections. I wonder if
> that metric is exposed by nginx somehow, or if this is something only
> available in nginx plus. Suggestions for alternative approaches to
> this is appreciated. Ideally, I would like a metric that I can consume
> and pump into our monitoring tools with a fairly high resolution.
>
> Cheers,
> Christian

Assuming you are proxying via domain socket, raindrops includes a
parser to extract the socket's active and queued connections.  We use
a script that publishes the following to our monitoring tools:

    Raindrops::Linux.unix_listener_stats(["/path/to/socket"])[0]
    # => #<struct Raindrops::ListenStats active=6, queued=0>

If you want to call this repeatedly without a process supervisor, you
can use bash scripts embedded in cron to get arbitrary granularity:

    SHELL=bash
    * * * * * for ((n=0;n<12;n++)); do /bin/publish_stats; sleep 5; done

Carl

Reply via email to