
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:
- Update your database security rules .
- Use the provided client sample , the provided Node.js admin 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 )
확장 프로그램 설치 방법
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
4단계(선택사항): Firebase 에뮬레이터 도구 모음 으로 이 확장 프로그램을 로컬에서 테스트합니다.
firebase emulators:start
5단계: 매니페스트의 확장 프로그램을 프로젝트에 배포 합니다.
firebase deploy --only extensions --project=projectId_or_alias