Hi all, Why my Firebase cloud functions are slow ...
# firebase
d
Hi all, Why my Firebase cloud functions are slow even if I put minInstances to 1. I have tested a simple function and it takes more than 1 second every time. If I call the same function 2 times, the second run is way faster, that is why I put minInstances to 1. Shouldn't the function run every time faster? this is my code in Kotlin:
Copy code
coroutineScope.launch(<http://Dispatchers.IO|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:
Copy code
val functions = Firebase.functions("europe-central2")

suspend fun checkAndroidVersion(version: String): String{
    return functions.httpsCallable("checkAndroidVersion").invoke(version).data<String>()
}
cloud function:
Copy code
exports.checkAndroidVersion =
onCall({region: "europe-central2", minInstances: 1}, (request) => {
  <http://logger.info|logger.info>("current user version = "+request.data, {structuredData: true});
  const version = request.data;
  if (version != "15/10/2024") {
    return version;
  }
  return "updated";
});
Keep in mind that I using Firebase Kotlin SDK since I have a KMM app.