Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
CiprianGabor opened this issue Dec 9, 2024 · 1 comment
Open

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

CiprianGabor opened this issue Dec 9, 2024 · 1 comment

Comments

@CiprianGabor
Copy link

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")
@CiprianGabor
Copy link
Author

@Daeda88

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant