Cheatsheet

  • The absolute most optimal pairing is Firebase us-east4 (Northern Virginia) matched with AWS us-east-1 (US East - N. Virginia).
  • Create your Firebase project and select us-east4 as your Cloud Firestore location. (Note: Avoid choosing the nam5 multi-region tag, as that defaults back to Iowa and breaks this optimization).

AWS

  • To achieve the lowest possible latency and minimum data transfer overhead when replicating your Firestore data to Amazon Web Services (AWS), the absolute best locations are the officially paired, collocated regions supported by AWS Interconnect - Multicloud. Because AWS and Google Cloud maintain physical private network links between specific data centers, choosing matching regions allows your Firebase Cloud Functions to update your AWS-hosted Meilisearch instance over a private backbone rather than the messy public internet.

The Best AWS Locations (Paired with Google)

  • Depending on where your Firebase data currently lives, select the exact corresponding AWS region:
If your Firebase/GCP Region isYour Best AWS Location isNetwork Connection Type
us-east4 (Northern Virginia)us-east-1 (US East - N. Virginia)Direct Co-location Hub
us-west1 (Oregon)us-west-2 (US West - Oregon)Direct Co-location Hub
us-west2 (Los Angeles)us-west-1 (US West - N. California)Direct Co-location Hub
europe-west3 (Frankfurt)eu-central-1 (Europe - Frankfurt)Direct Co-location Hub
europe-west2 (London)eu-west-2 (Europe - London)Direct Co-location Hub

Why N. Virginia or Oregon are the Preferred Choices

  • If you haven’t locked down your Firebase database region yet, deploying across Firebase us-east4 and AWS us-east-1 (N. Virginia) is the industry-standard recommendation.
  • These two specific hubs have the highest density of cross-cloud fiber connections, ensuring sub-5 millisecond round-trip times between your database updates and your Meilisearch index.

⚠️ What if my Firebase is in us-central1 (Iowa)?

  • Many developers provision their Firebase projects in us-central1 because it is Google’s default, feature-rich region. However, AWS does not have a major physical presence in Iowa.
  • If your data is stuck in us-central1, the closest geographical AWS data center is us-east-2 (Ohio).
  • Because they are not directly collocated, data must jump across the public internet or a shared network fabric, adding roughly 10–20ms of background sync latency.

💡 Two Crucial Rules for Setting Up AWS for Meilisearch

  1. Match the Cloud Function Region: When you install the Firebase Meilisearch extension, it will ask you where to deploy the background sync Cloud Function.
    • Do not leave it on default.
    • Force the Cloud Function to deploy in the exact same region as your Firestore database to prevent internal Google network routing charges.
  2. Leverage AWS “Lightsail” for Flat-Rate Pricing: Instead of buying an expensive, unbundled AWS EC2 instance, look at AWS Lightsail.
    • Lightsail mimics alternative cloud providers by bundling 2 vCPUs, 8 GB RAM, an SSD, and free outbound data allowances into a fixed price (around $40/month), giving you the price-predictability of Hetzner while remaining inside the high-speed AWS global network ecosystem.

Setup

1. Set the Location for Cloud Firestore

  • NOTE: Once set, the location can’t be changed.
  • Firestore is usually the main data anchor for an app. Setting its region establishes the baseline location for your project resources.
    1. Open your new project in the Firebase Console.
    2. On the left sidebar menu, click Firestore Database (under the “Build” section).
    3. Click Create database.
    4. During this prompt, you will be required to select your Database Location/Region (e.g., us-central1, europe-west1, etc.).
    5. Warning: Choose carefully, as the location for a Firestore database cannot be changed once it is created.

2. Set the Location for Cloud Storage

If you use Appspot or Firebase Storage buckets, you configure their location separately.

  1. On the left sidebar menu, click Storage.
  2. Click Get started.
  3. You will be prompted with a wizard to select your Cloud Storage location.
    • If you have already initialized Firestore, it will often default to the same region or give you a selection menu.

3. Set the Location for Cloud Functions (Code Deployment)

  • Cloud Functions do not inherit a project-wide default location configuration.
  • If you do not specify a location in your backend code, they default to us-central1.
  • To force them into a specific location, you must explicitly declare the region inside your deployment code:
from firebase_functions.firestore_fn import (
  on_document_created,
  Event,
  DocumentSnapshot
)

# Syncs data within the same region to avoid egress fees
@on_document_created(document="products/{productId}", region="australia-southeast1")
def sync_to_meilisearch(event: Event[DocumentSnapshot]) -> None:
    # Your Meilisearch synchronization logic here
    pass

@https_fn.on_call(region="australia-southeast1")
def my_callable_function(req: https_fn.CallableRequest) -> dict:
    return {"status": "success"}

4. Update the App


import 'package:cloud_functions/cloud_functions.dart';

// 1. Initialise the functions service with your specific region
FirebaseFunctions functions = FirebaseFunctions.instanceFor(
  region: 'australia-southeast1', // Must match your Python decorator region
);

// 2. Call your function as normal using this instance
try {
  HttpsCallable callable = functions.httpsCallable('my_callable_function');
  final result = await callable.call();
  print(result.data);
} on FirebaseFunctionsException catch (e) {
  print(e.code);
  print(e.message);
}