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

147
Visualizações
Saving post likes in Firebase

I'm making a social-media like websites where users can post text/images and like them, but I've ran into a problem. I know that I will store posts in Firestore, but where should I store likes? I can't store them in Firestore, because liking/disliking a post will waste 1 write operation(there is 600k write operations in the pay-as-you go tier). Should I store likes in Realtime database?

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

0

liking/disliking a post will waste 1 write operation(there is 600k write operations in the pay-as-you go tier).

The free tier (Spark plan) includes 20k writes per day (roughly 600k per month), and after that it will cost approximately $0.18 per 100k writes per month depending on your region Writes Pricing.

Personally, I wouldn't worry too much about the cost of writes in this scenario because if you have enough users on your app to be making 600k likes in a month, then your app (hopefully) has some revenue coming in.

The main issue is that a single Firestore document can only handle 1 write per second (can exceed in short term bursts). This is only an issue for you if you're storing all of those likes on a single document, which I assume you are as it makes sense to reduce reads. As Frank mentioned, to get around this issue you can look into distributed counters here.

Another option as you mentioned is to store likes in RTDB. RTDB and Firestore work well together, as long as you're properly managing the data in both places. If you choose to store likes in RTDB beware of the following which may be relevant for your use case:

  • RTDB can only have 100 concurrent connections on the Spark plan, and 200k on the Blaze plan. To scale past that (on the Blaze plan) you'll need to shard your data across multiple databases

  • A single RTDB database has a current limit of 1k writes per second

  • You can't perform batch writes across multiple Firebase services. For example, if you need to update a Firestore document at the same time as write to RTDB and want to make sure they succeed or fail as a group

You won't find a definite "yes" or "no" to your question. I've seen it implemented both ways, and they both work equally as well.

As Frank mentioned, you should look here Firestore vs RTDB to pick which is best for you

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