Skip to content

Commit

Permalink
fixed readmes, local ref in bench settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Charette committed May 28, 2019
1 parent 94d0af7 commit 15fad6b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -56,13 +56,11 @@ Name | Required | Default | Description
resolver | true | - | The method to wrap, and how to interpret the returned data. Uses the format `<function(ids, params)>`
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 `<function(response, requestedIds, params)>`
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 | <pre>{&#13;&#10;&nbsp;&nbsp;limit: 5000,&#13;&#10;&nbsp;&nbsp;ttl: 300000&#13;&#10;}</pre> | Caching options for the data - `limit` - the maximum number of records, and `ttl` - time to live for a record.
batch | false | <pre>{&#13;&#10;&nbsp;&nbsp;tick: 50,&#13;&#10;&nbsp;&nbsp;max: 100&#13;&#10;}</pre> | Batching options for the requests
retry | false | <pre>{&#13;&#10;&nbsp;&nbsp;base: 5,&#13;&#10;&nbsp;&nbsp;step: 3,&#13;&#10;&nbsp;&nbsp;limit: 5000,&#13;&#10;&nbsp;&nbsp;curve: <function(progress, start, end)>&#13;&#10;}</pre> | 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

Expand All @@ -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.
Expand Down
1 change: 1 addition & 0 deletions tests/profiling/README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
12 changes: 6 additions & 6 deletions tests/profiling/settings.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const {getAssets} = require('./dao.js');
//const redisStore = require('ha-store-redis');
const redisStore = require('../../../ha-redis-adapter');

module.exports = {
test: {
Expand All @@ -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],
},
}
2 changes: 1 addition & 1 deletion tests/profiling/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 15fad6b

Please sign in to comment.