From 15fad6b58a1b4914ad8f4c4d561099c470bcd6e2 Mon Sep 17 00:00:00 2001 From: Frederic Charette Date: Tue, 28 May 2019 12:38:30 -0400 Subject: [PATCH] fixed readmes, local ref in bench settings --- README.md | 8 ++------ tests/profiling/README.md | 1 + tests/profiling/settings.js | 12 ++++++------ tests/profiling/worker.js | 2 +- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 1328653..326b33d 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Want to make your app faster and don't want to spend on extra infrastructure ? [ **HA-store** is a generic wrapper for your data queries, it features: - Smart TLRU cache for 'hot' information -- Request coalescing, batching and retrying +- Request coalescing and batching (solves the [Thundering Herd problem](https://en.wikipedia.org/wiki/Thundering_herd_problem)) - Insightful stats and [events](#Monitoring-and-events) - Lightweight, configurable, battle-tested @@ -56,13 +56,11 @@ Name | Required | Default | Description resolver | true | - | The method to wrap, and how to interpret the returned data. Uses the format `` responseParser | false | (system) | The method that format the results from the resolver into an indexed collection. Accepts indexed collections or arrays of objects with an `id` property. Uses the format `` uniqueParams | false | `[]` | The list of parameters that, when passed, generate unique results. Ex: 'language', 'view', 'fields', 'country'. These will generate different combinations of cache keys. -timeout | false | `null` | The maximum time allowed for the resolver to resolve. +store | false | `null` | A custom store for the data, like [ha-store-redis](https://github.com/fed135/ha-redis-adapter). cache | false |
{
  limit: 5000,
  ttl: 300000
}
| Caching options for the data - `limit` - the maximum number of records, and `ttl` - time to live for a record. batch | false |
{
  tick: 50,
  max: 100
}
| Batching options for the requests -retry | false |
{
  base: 5,
  step: 3,
  limit: 5000,
  curve: 
}
| Retry options for the requests *All options are in (ms) -*Scaling options are represented via and exponential curve with base and limit being the 2 edge values while steps is the number of events over that curve. ## Monitoring and events @@ -71,11 +69,9 @@ HA-store emits events to track cache hits, miss and outbound requests. Event | Description --- | --- cacheHit | When the requested item is present in the microcache, or is already being fetched. Prevents another request from being created. -cacheMiss | When the requested item is not present in the microcache and is not currently being fetched. A new request will be made. coalescedHit | When a record query successfully hooks to the promise of the same record in transit. query | When a batch of requests is about to be sent. queryFailed | Indicates that the batch has failed. Retry policy will dictate if it should be re-attempted. -retryCancelled | Indicates that the batch has reached the allowed number of retries and is now abandoning. querySuccess | Indicates that the batch request was successful. You may also want to track the amount of `contexts` and `records` stored via the `size` method. diff --git a/tests/profiling/README.md b/tests/profiling/README.md index 7bb0a64..e8995d0 100644 --- a/tests/profiling/README.md +++ b/tests/profiling/README.md @@ -1,6 +1,7 @@ # Benchmarking HA-store 1- You'll need to generate a sample with your desired distribution. Run this [generator](https://github.com/fed135/zipfian-generator). +The bench expectations are based on these settings: `alpha: 0.5, size: 300000`. You can find a copy [here](https://gist.github.com/fed135/56282783a4c13d87a7f89c178b5d08d7). 2- Update the [settings](https://github.com/fed135/ha-store/blob/next/tests/profiling/settings.js) for the test, making sure to update the path for the sample file. Then, adjust the assertion values for your bench test. diff --git a/tests/profiling/settings.js b/tests/profiling/settings.js index 8f13c9d..553d7ad 100644 --- a/tests/profiling/settings.js +++ b/tests/profiling/settings.js @@ -1,6 +1,5 @@ const {getAssets} = require('./dao.js'); //const redisStore = require('ha-store-redis'); -const redisStore = require('../../../ha-redis-adapter'); module.exports = { test: { @@ -15,11 +14,12 @@ module.exports = { retry: { base: 1, step: 2 }, }, assert: { - completed: [90000, 200000], - cacheHits: [20000, 70000], + completed: [300000, 300000], + coalescedHit: [8000, 15000], + cacheHits: [35000, 45000], timeouts: [0, 0], - batches: [500, 4000], - rss: [90000, 120000], - avgBatchSize: [35, 50], + batches: [4800, 5300], + rss: [50000, 80000], + avgBatchSize: [45, 50], }, } \ No newline at end of file diff --git a/tests/profiling/worker.js b/tests/profiling/worker.js index 4f03566..35ff51c 100644 --- a/tests/profiling/worker.js +++ b/tests/profiling/worker.js @@ -33,7 +33,7 @@ function handleRequest(id, language) { let finished = false; const before = Date.now(); setTimeout(() => { - if (finished === false) suite.timeouts++; + //if (finished === false) suite.timeouts++; }, 500); store.get(id, { language }, crypto.randomBytes(8).toString('hex')) .then((result) => {