-
-
Notifications
You must be signed in to change notification settings - Fork 8
Home
ha-store
, or High-Availability store, is wrapper to abstract common optimization and security patterns for data fetching.
It's goals are to
- Decouple performance, security and degradation fallback concerns from the rest of the application logic.
- Provide an extensible interface to control caching, batching, retrying and circuit-breaking.
- Reduce the infrastructure-related costs of orchestration-type applications with smart micro-caching.
Facebook's dataloader is a close competitor, but it lacks a few key features.
dataloader
's documentation suggests implementing a new instance on each request, only coalescing data queries within the scope of that request- with a batching frequency that runs on node's event-loop (nextTick). This approach fits their caching strategy, since they do not have micro-caching, they are forced to make their entire stores short-lived so that they do not cause memory concerns.
ha-store
, on the other end prefers global, permanent stores. This means that data query coalescing is application-wide, with the batching tick rate customizable- to allow users to really optimize roundtrips.
Here'S a schema showing an application accepting requests and forwarding them to various services. Here are some optimization patterns HA-store implements to make that flow more efficient.
Coalescing is an optimization strategy that consists in detecting duplicated requests and picking up transit handles. In the case of ha-store, this consists in detecting if a data-source request is sent for a given entity, and in such cases, returns the Promise handle of the original request instead of creating a new one.
Batching is a blocking protocol. It involves adding a buffer of a given duration for incoming requests. This buffer allows the application to better understand an bundle requests. HA-store implements this with a tick value, that controls the amount of time between batches to a specific data-source. Another option, max
controls the maximum allowed number of distinct records in a batch.
When combating frail network or glitches, the ability to retry queries can be a powerful tool. Under HA-store, it also acts as a trigger system for the circuit breaker.
This system has many functions. Circuit breaking is a system that detects data-source problems and prevents requests from being made to a degraded system. It acts as a safeguard for that system, to allow to restart...
Includes all of the ha-store features (retry, circuit-breaker, batching, coalescing, caching) in this very classical Express+Mongo application: Gist