Skip to content

Why Firebase cloud functions are slow. 1 second to complete #682

Open
@CiprianGabor

Description

@CiprianGabor

Why my Firebase cloud functions are slow. I have tested a simple function and it takes more than 1 second every time.

this is my code in Kotlin:

coroutineScope.launch(Dispatchers.IO) {
    val timeTaken = measureTimeMillis {
        currentAndroidVersion =
            loginViewModel.repo.checkAndroidVersion(lastUpdateDate)
    }
    println("checkAndroidVersion took $timeTaken ms to execute")
}

this usually prints:

checkAndroidVersion took 1394 ms to execute

checkAndroidVersion took 1028 ms to execute

KMM repo:

val functions = Firebase.functions("europe-central2")

suspend fun checkAndroidVersion(version: String): String{
    return functions.httpsCallable("checkAndroidVersion").invoke(version).data<String>()
}

cloud function:

exports.checkAndroidVersion =
onCall({region: "europe-central2"}, (request) => {
  logger.info("current user version = "+request.data, {structuredData: true});
  const version = request.data;
  if (version != "15/10/2024") {
    return version;
  }
  return "updated";
});

these are my dependencies:

implementation("dev.gitlive:firebase-firestore:1.10.4")
implementation("dev.gitlive:firebase-common:1.10.4")
implementation("dev.gitlive:firebase-auth:1.10.4")
implementation("dev.gitlive:firebase-functions:1.10.4")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions