사용량 추적
앱의 리소스 사용량을 실시간으로 모니터링하고 관리할 수 있습니다.
사용량 대시보드
콘솔에서 실시간 사용량을 확인할 수 있습니다.
주요 지표 (플랜 한도 기준)
- 함수 호출 (function_calls_per_month)
- DB 쿼리 (db_queries_per_month)
- 큐 메시지 (queue_messages_per_month)
- 푸시 알림 (push_notifications_per_month)
- AI 스트림 토큰 (ai_stream_tokens_per_month)
- DB / 파일 / 비디오 스토리지 (GB)
- 트래픽 송신 (traffic_egress_gb)
- WebSocket 시간 / WebRTC 분
- 동시 연결 / 최대 앱 / 앱당 멤버
사용량 조회
📌 사용량/예산/리포트 관리는 콘솔에서만 수행합니다. 콘솔 → 빌링 → 사용량 에서 다음을 확인할 수 있습니다:
- 현재 월 함수/DB/푸시/AI 토큰/스토리지 사용량
- 일자별 / 엔드포인트별 그래프
- 사용량 경고 / 한도 초과 알림 설정 (이메일, 슬랙)
- CSV / JSON 리포트 내보내기
connectbase-client SDK 에는 sdk.billing.* 모듈이 없습니다. 자체 대시보드를 만들고 싶다면 콘솔 사용자 세션으로 /v1/apps/:appID/billing/* 엔드포인트를 호출해야 합니다(SDK 가 아닌 콘솔 전용 인증).
리소스 최적화
불필요한 API 호출 줄이기
typescript
// ❌ 비효율적: 각각 호출 (N번 요청)
for (const id of ids) {
await cb.database.getDataById('tbl_items', id)
}
// ✅ 효율적: queryData 한 번 (1번 요청)
const result = await cb.database.queryData('tbl_items', {
where: { id: { $in: ids } }
})
console.log(result.data)캐싱 활용
typescript
import { QueryClient } from '@tanstack/react-query'
const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 5 * 60 * 1000, // 5분
gcTime: 30 * 60 * 1000 // 30분 (구 cacheTime)
}
}
})데이터 정리
typescript
// 오래된 데이터 삭제 (조건부 삭제)
const thirtyDaysAgo = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString()
await cb.database.deleteWhere('tbl_logs', {
created_at: { $lt: thirtyDaysAgo }
})
// 파일은 개별 ID로 삭제 (목록 조회 후 일괄)
const files = await cb.storage.getFiles('stg_temp')
await Promise.all(
files
.filter((f) => f.created_at < thirtyDaysAgo)
.map((f) => cb.storage.deleteFile('stg_temp', f.id))
)