1.0.2 • Published 4 years ago

algolia-mcm-filesize v1.0.2

Weekly downloads
24
License
MIT
Repository
github
Last release
4 years ago

Algolia MCM File Size

npm node-lts JavaScript Style Guide

Important note: in Algolia's context, file size and index size are interchangeable. The index size represents the space used in RAM, whereas data size is the raw JSON data stored on disk and used as a backup for e.g. doing a full reindex.

What is it?

This package is a simple script that helps you compute the index size (per cluster and total for an app) when using Algolia's MCM architecture.

How to use it?

Regular install through npm or yarn:

npm i algolia-mcm-filesize
# or
yarn add algolia-mcm-filesize

It has been designed for manual use in a shell or to pipe it to another system, so it returns JSON instead of a pure JS object. Here is a quick usage suggestion:

index.js

const mcmFileSize = require('algolia-mcm-filesize')

mcmFileSize('APPID', 'ADMIN_APIKEY').then(res => console.log(res))

Optionally, you can pass a custom domain (default is algolia.net)

const mcmFileSize = require('algolia-mcm-filesize')

mcmFileSize('APPID', 'ADMIN_APIKEY', 'algolianet.com').then(res => console.log(res))

shell

Using jq for the sake of the example

node index.js | jq .

output

Sample output (cluster names are usually prefixed with d or v)

{
  "cluster-1": 91,
  "cluster-2": 83,
  "cluster-3": 95,
  "total": 269
}

Values are expressed in gigabyte (GB, not GiB)

Standard limit is 100 GB per cluster

Technical details

The only dependency is the JS API client (v4)

You need to use the Admin API key (required for all MCM endpoints)

Under the hood, the package uses the following endpoints:

Disclaimer

This package is not officially supported by Algolia, so it cannot be held responsible for any use in production. If you need support, use GitHub issues or the community forum, but not Algolia email support.