Skip to content

Instantly share code, notes, and snippets.

@muhammadardie
Last active June 4, 2025 09:12
Show Gist options
  • Save muhammadardie/12786a02d498bbddd0f39f1c6c7c699e to your computer and use it in GitHub Desktop.
Save muhammadardie/12786a02d498bbddd0f39f1c6c7c699e to your computer and use it in GitHub Desktop.
Estimasi Biaya Firebase untuk Aplikasi Tracking Karyawan (250 Karyawan)

Estimasi Biaya Firebase untuk Aplikasi Tracking Karyawan (250 Karyawan)

Spesifikasi Aplikasi

  • Admin Dashboard: React web app untuk membuat task dan monitoring karyawan di Google Maps
  • Employee App: React Native Expo app untuk tracking lokasi setiap 5 menit
  • Total Karyawan: 250 orang
  • Frekuensi Update Lokasi: Setiap 5 menit = 12 kali per jam = 288 kali per hari

Breakdown Penggunaan Firebase

1. Firebase Firestore (Database)

Perhitungan Writes:

  • Lokasi update per karyawan: 288 writes/hari
  • Total writes per hari: 250 karyawan × 288 = 72,000 writes/hari
  • Total writes per bulan: 72,000 × 30 = 2,160,000 writes/bulan

Perhitungan Reads:

  • Admin dashboard monitoring: ~50,000 reads/bulan (estimasi)
  • Employee app reads: ~25,000 reads/bulan
  • Total reads: ~75,000 reads/bulan

Biaya Firestore:

  • Writes: 2,160,000 × $0.18 per 100K = $3.89/bulan
  • Reads: 75,000 × $0.06 per 100K = $0.05/bulan
  • Storage: ~5GB × $0.18/GB = $0.90/bulan
  • Total Firestore: ~$4.84/bulan

2. Firebase Authentication

  • 250 pengguna aktif bulanan
  • Gratis hingga 50,000 Monthly Active Users
  • Biaya Auth: $0/bulan

3. Firebase Hosting (untuk Admin Dashboard)

  • Bandwidth: ~5GB/bulan
  • Storage: ~1GB
  • Biaya Hosting: $0.15/bulan

4. Firebase Cloud Functions (opsional)

Jika menggunakan untuk processing data:

  • 1,000,000 invocations/bulan
  • Biaya Functions: ~$0.40/bulan

5. Google Maps API

Admin Dashboard:

  • Maps JavaScript API: ~50,000 requests/bulan
  • Biaya: 50,000 × $2 per 1000 = $100/bulan

Mobile App (opsional untuk display):

  • Maps SDK for Android/iOS: Gratis untuk penggunaan dasar
  • Geocoding API: ~10,000 requests/bulan = $5/bulan

Total Maps API: ~$105/bulan

Total Estimasi Biaya Bulanan

Service Biaya/Bulan (USD) Biaya/Bulan (IDR)*
Firebase Firestore $4.84 Rp 76,650
Firebase Authentication $0.00 Rp 0
Firebase Hosting $0.15 Rp 2,375
Firebase Functions $0.40 Rp 6,340
Google Maps API $105.00 Rp 1,663,500
TOTAL $110.39 Rp 1,748,865

*Estimasi konversi: 1 USD = 15,830 IDR

Rekomendasi Optimasi Biaya

1. Mengurangi Frekuensi Update

  • Ubah dari 5 menit ke 10-15 menit untuk mengurangi writes
  • Potensi penghematan: ~50% biaya Firestore

2. Implementasi Smart Tracking

  • Hanya kirim lokasi jika ada perubahan signifikan (>50 meter)
  • Gunakan geofencing untuk area tertentu
  • Potensi penghematan: ~30-40% biaya Firestore

3. Alternatif Maps API

  • Gunakan Mapbox sebagai alternatif (lebih murah)
  • Implementasi caching untuk mengurangi API calls
  • Potensi penghematan: ~40-60% biaya Maps

4. Paket Berlangganan

  • Pertimbangkan Google Cloud Platform credits
  • Nego dengan Google untuk volume besar

Proyeksi Biaya Tahunan

  • Biaya Minimum: ~$1,325 USD (~Rp 20,986,250)
  • Dengan Optimasi: ~$800 USD (~Rp 12,664,000)

Catatan Penting

  1. Biaya dapat bervariasi berdasarkan penggunaan aktual
  2. Pertimbangkan biaya infrastruktur tambahan (server, CDN)
  3. Biaya development dan maintenance tidak termasuk
  4. Monitoring penggunaan secara berkala untuk optimasi

Detail Biaya Google Maps API untuk Aplikasi Tracking Karyawan

Overview Google Maps Platform Pricing

Google Maps Platform menggunakan sistem pay-as-you-use dengan berbagai API yang berbeda-beda harganya. Setiap bulan mendapat $200 USD free credits yang bisa digunakan untuk semua layanan Google Cloud Platform.

Breakdown API Berdasarkan Spesifikasi Actual

1. Maps JavaScript API (Admin Dashboard)

Kegunaan:

  • Menampilkan peta dengan polylines untuk jalur karyawan
  • Menampilkan markers untuk posisi real-time karyawan
  • Clustering markers berdasarkan regional

Pricing:

  • $2.00 per 1,000 map loads
  • Free tier: 28,500 map loads/bulan (dari $200 credit)

Estimasi Penggunaan Real-time Dashboard:

  • Admin aktif: 5-10 orang
  • Session monitoring per hari: 8 jam × 60 refresh/jam = 480 map loads per admin
  • Total per hari: 10 × 480 = 4,800 map loads
  • Total per bulan: 144,000 map loads

Biaya:

  • Melebihi free tier: $2 × (144,000-28,500)/1,000 = $231.00/bulan

2. Directions API (untuk Polylines)

Kegunaan:

  • Membuat jalur/route dari sequence lokasi karyawan
  • Menyambungkan titik-titik koordinat menjadi polylines
  • Optimasi rute untuk tracking perjalanan

Pricing:

  • $5.00 per 1,000 requests

Estimasi Penggunaan:

  • 250 karyawan × 1 route calculation/hari = 250/hari
  • Admin view route history: 500 requests/hari
  • Total per bulan: (250+500) × 30 = 22,500 requests

Biaya: $5 × 22.5 = $112.50/bulan

3. Geocoding API (Minimal Usage)

Kegunaan: Convert koordinat ke alamat untuk display yang user-friendly

Pricing:

  • $5.00 per 1,000 requests
  • Free tier: 40,000 requests/bulan

Estimasi Penggunaan:

  • Reverse geocoding untuk marker tooltips: 5,000 requests/bulan
  • Biaya: $0/bulan (dalam free tier)

4. Mobile SDK (React Native - Minimal Usage)

Kegunaan:

  • Hanya untuk menampilkan lokasi karyawan saat ini (optional)
  • Background location service untuk tracking

Pricing:

  • Maps SDK: Gratis untuk basic usage
  • Location Services: Gratis (menggunakan native GPS)

Estimasi Penggunaan:

  • Sebagian besar karyawan tidak perlu melihat map
  • Hanya background GPS tracking
  • Biaya: $0/bulan

5. Static Maps API (untuk Reports)

Kegunaan: Screenshot/export peta untuk laporan

Pricing:

  • $2.00 per 1,000 requests

Estimasi Penggunaan:

  • Daily reports: 30 requests/bulan
  • Monthly reports: 12 requests/bulan
  • Total: 42 requests/bulan

Biaya: $0.08/bulan (minimal)

Mobile SDK (React Native)

Maps SDK for Android/iOS

Kegunaan: Display map di aplikasi mobile karyawan

Pricing:

  • Gratis untuk penggunaan dasar
  • $7.00 per 1,000 map loads jika menggunakan fitur advanced

Estimasi Penggunaan:

  • 250 karyawan × 10 map loads/hari = 2,500/hari
  • Total per bulan: 75,000 map loads
  • Jika menggunakan advanced features: $525/bulan
  • Rekomendasi: Gunakan basic version (Gratis)

Skenario Actual Berdasarkan Spesifikasi

Skenario Real-time Tracking (Recommended)

API Penggunaan/Bulan Biaya USD Biaya IDR
Maps JavaScript API 144,000 loads $231.00 Rp 3,657,030
Directions API 22,500 requests $112.50 Rp 1,781,775
Geocoding API 5,000 requests $0.00 Rp 0 (free tier)
Static Maps API 42 requests $0.08 Rp 1,266
Mobile SDK Background GPS only $0.00 Rp 0
TOTAL $343.58 Rp 5,440,071
Minus $200 Free Credit $143.58 Rp 2,274,071

Skenario Optimized (dengan Caching & Batching)

API Penggunaan/Bulan Biaya USD Biaya IDR
Maps JavaScript API 72,000 loads (50% cache hit) $87.00 Rp 1,377,210
Directions API 11,250 requests (batch processing) $56.25 Rp 890,888
Geocoding API 2,500 requests (cached) $0.00 Rp 0
Static Maps API 42 requests $0.08 Rp 1,266
TOTAL $143.33 Rp 2,269,364
Minus $200 Free Credit $0.00 Rp 0

Perbandingan dengan Alternatif

Mapbox Alternative

Feature Google Maps Cost Mapbox Cost Savings
Map Loads (144K) $231.00 $72.00 69%
Route Calculation (22.5K) $112.50 $11.25 90%
Geocoding (5K) $0.00 $2.50 -$2.50
TOTAL $343.58 $85.75 75%

Cost Analysis per Feature

Real-time Employee Tracking

  • 144,000 map loads/bulan: $231/bulan
  • Cost per employee per hari: $0.31 USD (Rp 4,900)

Route Visualization (Polylines)

  • 22,500 directions requests/bulan: $112.50/bulan
  • Cost per route: $0.005 USD (Rp 79)

Regional Markers

  • Gratis - hanya menggunakan basic markers
  • Clustering mengurangi load time dan API calls

ROI Analysis

Manfaat vs Cost:

Manfaat Bisnis:

  • Monitoring real-time 250 karyawan
  • Optimasi rute dan produktivitas
  • Automated reporting dan compliance
  • Estimated ROI: 300-500% dari cost reduction

Total Investment:

  • Maps API: $144/bulan (setelah free credit)
  • Development: $5,000-10,000 (one-time)
  • Maintenance: $500/bulan

Break-even Point: 2-3 bulan

Monitoring dan Alerts

Setup Budget Alerts

{
  "budgetAmount": 100,
  "alertThresholds": [50, 75, 90, 100],
  "notificationChannels": ["email", "slack"]
}

Usage Monitoring

  • Daily API usage tracking
  • Automated reports
  • Cost optimization recommendations

Rekomendasi Final

Untuk Startup/Budget Terbatas:

  • Skenario Minimal: $1-10/bulan
  • Manfaatkan free tiers maksimal
  • Implementasi caching agresif

Untuk Production Ready:

  • Skenario Standar: $50-100/bulan
  • Balance antara features dan cost
  • Professional monitoring

Untuk Enterprise:

  • Skenario Lengkap: $200-800/bulan
  • Full features dengan redundancy
  • Custom enterprise pricing

Cost Per Employee Analysis (Updated)

Skenario Total Cost/Bulan Cost per Employee/Bulan Cost per Employee/Hari
Real-time (Google) $144 (setelah free credit) $0.58 $0.019 (Rp 300)
Optimized (Google) $0 (dalam free credit) $0.00 $0.00
Mapbox Alternative $86 $0.34 $0.011 (Rp 175)

Rekomendasi Final Berdasarkan Spesifikasi

Untuk Production Ready (Recommended):

Google Maps dengan Optimasi:

  • Total: $0-144/bulan (tergantung optimasi)
  • Feature lengkap: Polylines, clustering, real-time tracking
  • Reliable dan enterprise-grade

Untuk Budget Conscious:

Mapbox Alternative:

  • Total: $86/bulan
  • Penghematan 75% dari Google Maps
  • Feature setara dengan performance baik

Untuk MVP/Testing:

Google Maps + Aggressive Caching:

  • Total: $0/bulan (dalam free credit)
  • Cocok untuk testing dengan < 100 concurrent users
  • Upgrade ke paid plan saat scaling

Scenario Example

  • 10 unique users per day
  • Each page displays 200 spans (meaning 200 DirectionsService.route() requests per page load)

Let's recalculate the estimated monthly cost, keeping the $200 USD free monthly credit in mind.

Monthly Usage (approximate):

  • Map Loads: 10 unique users/day * 30 days/month = 300 map loads/month
  • Directions API Requests: 200 requests/page * 10 unique users/day * 30 days/month = 60,000 Directions API requests/month

Estimated Monthly Cost (Raw - before free credit):

  1. Maps JavaScript API (Dynamic Maps):

    • Cost per 1,000 map loads: ~$7.00 USD
    • Your usage: 300 map loads / 1,000 = 0.3 units
    • Cost: 0.3 * $7.00 = $2.10 USD
  2. Directions API (Routes: Compute Routes Essentials):

    • Cost per 1,000 requests: ~$5.00 USD
    • Your usage: 60,000 requests / 1,000 = 60 units
    • Cost: 60 * $5.00 = $300.00 USD

Total Estimated Cost (Raw): $2.10 (Maps) + $300.00 (Directions) = $302.10 USD

Applying the $200 Free Monthly Credit:

  • Total Raw Cost: $302.10 USD
  • Less Free Credit: -$200.00 USD
  • Estimated Monthly Bill: $102.10 USD

Conclusion for this Scenario:

In this revised scenario, with each user viewing a page with 200 spans, your estimated monthly bill would be around $102.10 USD after applying the $200 free credit.

Important Considerations for this Scenario:

  • Directions API Dominance: The Directions API is the primary cost driver here due to the high number of span routes being calculated per page load.
  • Waypoint Limits: Remember that each DirectionsService.route() call has a limit of 25 waypoints (origin + destination + 23 intermediate). If any of your 200 spans have more than 23 track points, you'll need a more robust strategy for simplifying or breaking down those individual span routes to stay within the limit and avoid errors. The current code truncates, which might not be ideal for all scenarios.
  • Performance: Displaying 200 individual routes (each with its own DirectionsRenderer) and potentially 400 markers (initial/final for each span) on a single map can also have a significant impact on page load time and map rendering performance. This is something you'd want to test thoroughly.
  • Optimization Strategies for High Span Counts:
    • Consolidate Routes (if logical): If spans are geographically contiguous, can you combine them into fewer, larger DirectionsService requests with more waypoints (staying under 25)? (This was your initial approach, but it might not be suitable if each span needs to be distinct.)
    • Dynamic Loading/Clustering: Load and display only the spans relevant to the current map view, or use marker/route clustering techniques.
    • Manual Polylines for Tracks: For the tracks within a span, consider fetching just the raw coordinates from your backend and drawing them with google.maps.Polyline instead of relying on the DirectionsService to calculate these very short, internal segments. You'd only use DirectionsService for the initialSpan to finalSpan (or if you need turn-by-turn within a span). This would dramatically reduce Directions API calls.
    • Backend Route Calculation: For very high volume, you might consider calculating some routes on your backend and only sending the resulting polyline coordinates to the frontend to render, reducing the number of client-side Directions API calls.

Always refer to the official Google Maps Platform pricing page and use their pricing calculator for the most accurate and up-to-date estimates. Okay, let's change the scenario to:

  • 10 unique users per day
  • Each user loads a page that displays 200 spans

This new scenario significantly increases the number of Directions API calls.

Scenario:

  • Unique Users per Day: 10
  • Spans Displayed per Page Load: 200

Monthly Usage Calculation:

  • Days in a Month: Let's assume 30 days for a rough estimate.
  1. Dynamic Map Loads:

    • 10 users/day * 30 days/month = 300 map loads/month
    • Cost per 1,000 map loads: ~$7.00 USD
    • Free Tier: 10,000 map loads/month (Essentials)
  2. Directions API Requests:

    • 200 spans/page * 10 users/day * 30 days/month = 60,000 Directions API requests/month
    • Cost per 1,000 requests (Essentials): ~$5.00 USD
    • Free Tier: 10,000 requests/month (Essentials)

Estimated Monthly Cost (after free tier):

  1. Dynamic Map Loads:

    • Usage: 300 map loads
    • Since 300 is well within the 10,000 free map loads, the cost for Dynamic Maps is $0.00 USD.
  2. Directions API Requests:

    • Total requests: 60,000
    • Free tier: 10,000 requests
    • Billable requests: 60,000 - 10,000 = 50,000 requests
    • Cost: (50,000 / 1,000) * $5.00 = 50 * $5.00 = $250.00 USD

Applying the $200 Free Monthly Credit:

  • Total Raw Cost: $0.00 (Maps) + $250.00 (Directions) = $250.00 USD

  • Google's Monthly Free Credit: $200.00 USD

  • Actual Bill: $250.00 (Total Raw Cost) - $200.00 (Free Credit) = $50.00 USD

Conclusion for this Scenario:

In this scenario, with 10 unique users viewing 200 spans daily, you would likely exceed the $200 free monthly credit and incur a bill of approximately $50.00 USD per month.

  • Directions API is the dominant cost driver: With 200 spans per page, the number of Directions API calls quickly adds up, even with a relatively small number of users.
  • Monitor your usage closely: In the Google Cloud Console, set up billing alerts to notify you if your usage approaches your budget limits.
  • Consider optimizations:
    • Data simplification: Do you really need a precise route for every single span if it's very short? Could some short spans be represented by just a line between initial and final points without a Directions API call?
    • Lazy loading/pagination: Can you load only a subset of spans initially (e.g., the first 50 or those within the current viewport) and load more as the user scrolls or interacts? This drastically reduces the number of API calls on initial page load.
    • Caching: If the routes for spans don't change often, you could cache the DirectionsResult on your server or in local storage to avoid repeated API calls for the same route.
    • Alternative visualization: If you don't need turn-by-turn directions and just want to show lines, you could store the simplified LatLng arrays for your spans and draw them directly with google.maps.Polyline without using DirectionsService at all. This would eliminate the Directions API cost entirely for those segments, though you'd lose the route-snapping benefits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment