Raindrops Aggregate Aggregate::LastDataRecv Aggregate::PMQ LastDataRecv Linux ListenStats Middleware Middleware::Proxy Struct Watcher


::new #<< #aggregate #count #each #each_nonzero #flush #flush_master #master_loop #max #mean #min #outliers_high #outliers_low #std_dev #stop_master_loop #sum #to_s

class Raindrops::Aggregate::PMQ

Aggregate + POSIX message queues support for Ruby 1.9 and Linux

This class is duck-type compatible with Aggregate and allows us to aggregate and share statistics from multiple processes/threads aided POSIX message queues. This is designed to be used with the Raindrops::LastDataRecv Rack application, but can be used independently on compatible Runtimes.

Unlike the core of raindrops, this is only supported on Ruby 1.9 and Linux 2.6. Using this class requires the following additional RubyGems or libraries:


There is one master thread which aggregates statistics. Individual worker processes or threads will write to a shared POSIX message queue (default: "/raindrops") that the master reads from. At a predefined interval, the master thread will write out to a shared, anonymous temporary file that workers may read from

Setting :worker_interval and :master_interval to 1 will result in perfect accuracy but at the cost of a high synchronization overhead. Larger intervals mean less frequent messaging for higher performance but lower accuracy.


nr_dropped [R]

returns the number of dropped messages sent to a POSIX message queue if non-blocking operation was desired with :lossy

Public Class Methods

new (params = {}) source

Creates a new Raindrops::Aggregate::PMQ object = {})  -> aggregate

options is a hash that accepts the following keys:

Public Instance Methods

<< (val) source

adds a sample to the underlying Aggregate object

aggregate () source

Loads the last shared Aggregate from the master thread/process

count () source

proxy for Aggregate#count

each () { |*args| ... } source

proxy for Aggregate#each

each_nonzero () { |*args| ... } source

proxy for Aggregate#each_nonzero

flush () source

flushes the local queue of the worker process, sending all pending data to the master. There is no need to call this explicitly as :worker_interval defines how frequently your queue will be flushed

flush_master () source

Flushes the currently aggregate statistics to a temporary file. There is no need to call this explicitly as :worker_interval defines how frequently your data will be flushed for workers to read.

master_loop () source

Starts running a master loop, usually in a dedicated thread or process: { agg.master_loop }

Any worker can call agg.stop_master_loop to stop the master loop (possibly causing the thread or process to exit)

max () source

proxy for Aggregate#max

mean () source

proxy for Aggregate#mean

min () source

proxy for Aggregate#min

outliers_high () source

proxy for Aggregate#outliers_high

outliers_low () source

proxy for Aggregate#outliers_low

std_dev () source

proxy for Aggregate#std_dev

stop_master_loop () source

stops the currently running master loop, may be called from any worker thread or process

sum () source

proxy for Aggregate#sum

to_s (*args) source

proxy for Aggregate#to_s

Pages Classes Methods
mail archives:
public: / private:
source code: git clone git://
	git clone