Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
Is it better to make 2 API calls and discard 1, or call one at a time when inside cloud functions?

I know that cloud functions charge money based on execution time and network costs.

I am writing a cloud function that calls 2 external APIs to authenticate a user. Both external APIs just return a single boolean and therefore don't send much info.

Which technique is better overall?

  1. Make both external API calls using fetch() at the same time knowing that 1 may be useless half the time.

  2. Make the external API call one after the other, and not make the second one if not needed.

I'm thinking doing #1 will shorten the "wall time" of my cloud function and therefore may be cheaper? But I make more external calls which may be expensive?

But doing #2 will make the cloud function stay in memory for longer and therefore more "wall time".

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Method 1 results in more complex code as you will need to wait for both fetches to complete unless you like container crashes to debug.

Method 2 is simpler to implement and debug but could result in longer wall clock time.

You will need to decide which method is better when you factor development time, debugging time, analyzing errors in logfiles, and execution time.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda