~/docs
Resonate
Resonate
1.x 1.8.1.4, current
Fledge Pulse
Toggle sidebar
Fledge Pulse
webpatser/fledge-pulse 1.8.1.4

Fledge Pulse 1.x

Reads and Cost

How the Elasticsearch driver aggregates at read time, and what that costs (plugin version 0.3.0).

This page describes webpatser/fledge-pulse-elasticsearch 0.3.0.

Upstream pre-aggregates entries into buckets on write. This driver keeps raw entries and aggregates at read time with upstream's window math, so results match DatabaseStorage. The price is that a 7-day card aggregates a week of raw entries on every read, which is heavier than upstream's bucket reads. On busy applications sample the high-volume recorders, for example the cache interactions recorder's sample_rate in config/pulse.php:

Recorders\CacheInteractions::class => [
'enabled' => env('PULSE_CACHE_INTERACTIONS_ENABLED', true),
'sample_rate' => env('PULSE_CACHE_INTERACTIONS_SAMPLE_RATE', 1),
],

Ordered key lists

Ordered key lists (aggregate(), aggregateTypes()) are exact, even though the entries of a 7-day window live in about eight backing indices, one shard each:

  1. Elasticsearch picks candidate keys with an ordered terms aggregation whose shard_size is terms_shard_size (default max(10000, limit * 50)). With no more distinct keys per backing index than that, the candidates are exact.
  2. The aggregates are recomputed for the candidates only, exactly, and the final order and limit come from those values.

Ordering by avg (and by min) cannot be expressed as one Elasticsearch metric, so those reads page through every key in the window with a composite aggregation and order in PHP. That costs more with many distinct keys; the composite page size shrinks for averages of several types so one page stays under search.max_buckets.

Nulls order as upstream does on MySQL: last on desc, first on asc, ties by key ascending. When Elasticsearch picks candidates for count or sum, a key without values ranks as 0, so with more than limit * 2 keys tied at 0 or null the cut can differ from MySQL's.