
Contador distribuído
Made by Firebase
Registra contadores de eventos em escala para aceitar gravações de alta velocidade no Cloud Firestore.
Como esta extensão funciona
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.
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:
- Update your database security rules.
- Use the provided client sample or your own client code to specify your document path and increment values.
Detailed information for these post-installation tasks are provided after you install this extension.
Billing
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)
Como instalar a extensão
Como usar o Console do Firebase
Para instalar e gerenciar extensões, use o Console do Firebase.
Instalar usando o consoleComo usar a Firebase CLI
Para instalar e gerenciar extensões, também é possível usar a Firebase CLI:
Etapa 1: execute o comando npm (em inglês) a seguir para instalar a CLI ou atualizá-la para a versão mais recente.
npm install -g firebase-toolsNão está funcionando? Consulte a referência da Firebase CLI ou altere suas permissões do npm (em inglês).
Etapa 2: execute o comando a seguir para instalar a extensão.
firebase ext:install firestore-counter --project=projectId_or_alias