Google は、黒人コミュニティのための人種的公平の促進に取り組んでいます。詳細をご覧ください。

Distributed Counter

Made by Firebase

Cloud Firestore への高速書き込みに対応するため、イベント カウンタを大規模に記録します。


Use this extension to add a highly scalable counter service to your app. This is ideal for applications that count viral actions or any very high-velocity action such as views, likes, or shares.

Since Cloud Firestore has a limit of one sustained write per second, per document, this extension instead shards your writes across documents in a _counter_shards_ subcollection. Each client only increments their own unique shard while the background workers (provided by this extension) monitor and aggregate these shards into a main document.

Here are some features of this extension:

  • Scales from 0 updates per second to a maximum of 10,000 per second.
  • Supports an arbitrary number of counters in your app.
  • Works offline and provides latency compensation for the main counter.

Note that this extension requires client-side logic to work. We provide a TypeScript client sample implementation and its compiled minified JavaScript . You can use this extension on other platforms if you'd like to develop your own client code based on the provided client sample.

We also provide a Node.js admin sample implementation

Additional setup

Before installing this extension, make sure that you've set up a Cloud Firestore database in your Firebase project.

After installing this extension, you'll need to:

Detailed information for these post-installation tasks are provided after you install this extension.


To install an extension, your project must be on the Blaze (pay as you go) plan

  • You will be charged a small amount (typically around $0.01/month) for the Firebase resources required by this extension (even if it is not used).
  • This extension uses other Firebase and Google Cloud Platform services, which have associated charges if you exceed the service’s free tier:
  • Cloud Firestore
  • Cloud Functions (Node.js 10+ runtime. See FAQs )


Firebase コンソールの使用

拡張機能のインストールと管理は、Firebase コンソールで行えます。


Firebase CLI の使用

拡張機能のインストールと管理は、Firebase CLI でも行えます。

ステップ 1: 以下の npm コマンドを実行して、CLI をインストールするか、最新バージョンの CLI に更新します。

npm install -g firebase-tools
正常に機能しない場合は、 Firebase CLI リファレンス を確認するか、 npm のアクセス権 を変更してください。

ステップ 2: 新しい Firebase プロジェクトのディレクトリを設定 するか、既存のプロジェクト ディレクトリに移動します

ステップ 3: 次を実行して、この拡張機能を 拡張機能のマニフェスト に追加します

firebase ext:install firebase/firestore-counter --local --project=projectId_or_alias

Step 4 (Optional): Test this extension locally with the Firebase Emulator Suite

firebase emulators:start

ステップ 5: マニフェストにある拡張機能をプロジェクトに デプロイ します

firebase deploy --only extensions --project=projectId_or_alias
Cloud Firestore