ไม่สามารถเล่นวิดีโอนี้
ขออภัยในความไม่สะดวก

How to NOT get a 30K Firebase Bill

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ส.ค. 2018
  • Learn how to manage costs in Firebase with both clientside and serverside optimizations. angularfirebase.com/lessons/m...
    Source Article hackernoon.com/how-we-spent-3...
    Firebase Pricing firebase.google.com/pricing/

ความคิดเห็น • 242

  • @MrJaminbrad
    @MrJaminbrad 6 ปีที่แล้ว +210

    Your content is great as always. Mini case-studies like this are a fantastic way to implement several little features of angular, rxjs, & firestore into the bigger picture of a more thoughtful app architecture. For angular newbies like me, this is gold. You've outdone yourself on this one.

    • @Fireship
      @Fireship  6 ปีที่แล้ว +18

      Thank you! This is actually the first "case study" style video I've done. Appreciate the feedback :)

    • @rick_from_yr
      @rick_from_yr ปีที่แล้ว

      Right now it has already been implemented. Now you can set a maximum amount, and an amount to send you an alert

  • @Fireship
    @Fireship  6 ปีที่แล้ว +10

    Have you experienced sticker shock in the cloud? If so, would love to hear about your story with comment :)

    • @steffennilsen2132
      @steffennilsen2132 6 ปีที่แล้ว +3

      I watched a presentation th-cam.com/video/Q2g9d29UIzk/w-d-xo.html where the presenter had decided to 'solve' pokemon blue, with a regex statement... yeah. He ran it on aws and was billed ~9500 USD

  • @danilofuchs1234
    @danilofuchs1234 6 ปีที่แล้ว +138

    Instead of using "get" and "set" inside your cloud function, you should use transactions, to allow multiple users to upload at the same time

    • @cristianscript5649
      @cristianscript5649 3 ปีที่แล้ว +7

      wow

    • @Rhidayah
      @Rhidayah ปีที่แล้ว +2

      The question is why Firebase not have features to stop project while get maximum bills

    • @AgentMassiveWizard
      @AgentMassiveWizard 10 หลายเดือนก่อน

      ​@@Rhidayahdo you want to completely stop your app just because you can't pay a single more dollar

    • @TheCollectiveYoutube
      @TheCollectiveYoutube 4 หลายเดือนก่อน

      It would be nice too be able to set a limit. Id day free jumping to $5k is good reason to shut it down @AgentMassiveWizard

  • @narcodico
    @narcodico 6 ปีที่แล้ว +255

    I'm pretty sure Firebase team should have tools in place to detect this kind of behavior and notify the user. Would be fair to say the least.

    • @Fireship
      @Fireship  6 ปีที่แล้ว +110

      I agree. It's possible to create an infinite loop with cloud functions and have no idea. The good news is that Google is usually forgiving on pricing in these situations.

    • @roytouw152
      @roytouw152 6 ปีที่แล้ว +2

      In this case as well?

    • @videoguy640
      @videoguy640 6 ปีที่แล้ว +3

      You can stop all requests to db after a certain monetary amount iirc

    • @zdream720
      @zdream720 6 ปีที่แล้ว +11

      Why is it their job to design your code? I disagree. Understand what you're doing if it could cost money. Simple as that.

    • @narcodico
      @narcodico 6 ปีที่แล้ว +74

      Considering they are offering a paid platform for people to use, their focus should be on helping out their customers and making their development life easier. After all, customers are bringing in the money. I'm pretty sure firebase has a lot of users/customers who don't fully understand how this product really works. I'm sure you weren't an expert in firebase just out of the box, it takes time to develop the skills. Also, anyone could make a mistake, no matter how good you are. I'm sure paying a large bill for a mistake is not something people would find helpful in becoming better developers or encouraging to stick with a certain product. Understanding what you are doing is one thing, making a mistake is completely different story.

  • @bstrnx
    @bstrnx 6 ปีที่แล้ว +5

    This video is pure gold! Thank you for making it. I think it would also be useful to learn what other operations you can use as triggers for cloud functions (other than DB writes/reads) and with which other Firebase technologies you can integrate those cloud functions (like FCM).

  • @mrsneed420
    @mrsneed420 ปีที่แล้ว +18

    the show must go on #fishtanklive

  • @SquishySquid88
    @SquishySquid88 ปีที่แล้ว +13

    you have to help out our man jason goldshriker

  • @rushnerd
    @rushnerd ปีที่แล้ว +11

    How have we come to this lol. Josie must be saved...

  • @SteveDaBartender
    @SteveDaBartender ปีที่แล้ว +16

    i miss them

  • @esstetico
    @esstetico ปีที่แล้ว +13

    Fishtank should've watch it before!!

  • @DylanHart8
    @DylanHart8 ปีที่แล้ว +21

    @wigger

  • @toolavish
    @toolavish ปีที่แล้ว +10

    Reminds me of days when cellphone mobile minute plans got people paying 1k mobile bills

  • @user-vy8ej1cg8x
    @user-vy8ej1cg8x ปีที่แล้ว +19

    Josie...

  • @thelastshartbender758
    @thelastshartbender758 ปีที่แล้ว +18

    Sam Hydesisters what is this.......

  • @carltongordon
    @carltongordon 6 ปีที่แล้ว +3

    This is amazing man! thank you for the heads up

  • @AnimeProfilePictureShitposter
    @AnimeProfilePictureShitposter ปีที่แล้ว +10

    Someone send this to Jason Goldstriker QUICK!!1

  • @Rassy_
    @Rassy_ 4 ปีที่แล้ว +52

    Recently firebase removed the Flame Plan, paying 25$ per month, now developers only have 2 options: free version or pay as you go which sounds very intimidating.

    • @BrandonBaunach
      @BrandonBaunach 3 ปีที่แล้ว +1

      Why is pay as you go intimidating?

    • @Rassy_
      @Rassy_ 3 ปีที่แล้ว +6

      @@BrandonBaunach because you might end up getting a 30k bill if you're not careful or experienced enough with it

    • @BrandonBaunach
      @BrandonBaunach 3 ปีที่แล้ว

      @@Rassy_ but wasn’t this video made during a time when it wasn’t pay as you go? And they still got a 30k bill?

    • @Rassy_
      @Rassy_ 3 ปีที่แล้ว +3

      @@BrandonBaunach no pay as you go was always there from the start and that's what they chose, if they used any other billing plan, it's only their services that would be limited but they wouldn't incur such a bill

  • @ilhamefendy9868
    @ilhamefendy9868 6 ปีที่แล้ว

    thank's for your great video, as a very newbie in learning firestore, it's a scary fact if I face the same problem. thanks for the solution you shared before I make the same mistake

  • @diznyland6214
    @diznyland6214 ปีที่แล้ว +5

    It's just not the same without them.

  • @aerivera
    @aerivera 6 ปีที่แล้ว +8

    From a point of view of someone that has the "intention" to learn Angular, this video is pure gold!. Practical analysis and resolution to a REAL issue.
    I always say to myself that I will buy your Angular course, but I've been so lazy lately and putting excuses like "My JavaScript still not good enough"... time to do some real decision and commiment hehehehe.

    • @Fireship
      @Fireship  6 ปีที่แล้ว +1

      Thanks Angel! I really try to keep things as practical as possible because it's the best way to learn IMO.

  • @harpymaslow
    @harpymaslow 6 ปีที่แล้ว +12

    Great. As usual

  • @TheDerpyWhaleYT
    @TheDerpyWhaleYT 5 ปีที่แล้ว +1

    For the free plan, it just shuts down your app right? no bills?

  • @TheDerpyWhaleYT
    @TheDerpyWhaleYT 4 ปีที่แล้ว

    is there a cap on how much you can pay? not just a threshold alerting you X amount?

  • @kiontupper
    @kiontupper 6 ปีที่แล้ว +14

    This is actually why I went full REST (I chose *not* to use any SDKs for Firestore/cloud storage). I scanned the entire documentation and realized that by using the SDK, I'd have no idea what it would cache or refresh or how it would handle offline persistence (vital for mobile). Therefore my app doesn't even load the SDK, and all authentication, cloud functions, firestore requests, etc are handled directly through REST and cached on my own.

    • @beneditomauroo
      @beneditomauroo 5 ปีที่แล้ว +4

      Kion Tupper could you expand a little?

    • @worldwide6626
      @worldwide6626 6 หลายเดือนก่อน +3

      @@beneditomauroo he isn’t going to I think

    • @ribbonmusha
      @ribbonmusha 3 หลายเดือนก่อน

      ​@@beneditomauroo yeah, he wouldn't

  • @andenetalexander5244
    @andenetalexander5244 3 ปีที่แล้ว

    You always make a great contents in such short amount of time. You're the best! Can you pleas make same video for this use case using flutter b/c i don't really know much about angular to get most out of it. Thanks in advance.

  • @oo.lwinpaing1609
    @oo.lwinpaing1609 15 วันที่ผ่านมา

    This video is gold, absolute gem :3

  • @RickyNoelDiancin
    @RickyNoelDiancin 6 ปีที่แล้ว +3

    Thank you, this is very helpful!

    • @Fireship
      @Fireship  6 ปีที่แล้ว +1

      Glad to hear that. Optimizing for the cloud's cost structure can be very important.

  • @punyaslokdutta4362
    @punyaslokdutta4362 4 ปีที่แล้ว +3

    1. Make another document where every time a document added,It updates both the documents . You make two writes.

  • @andremariano3347
    @andremariano3347 4 ปีที่แล้ว +17

    You have to create a flutter version of this!!!!

  • @sleeplessdev7204
    @sleeplessdev7204 5 ปีที่แล้ว +1

    Awesome tip, thanks!

  • @pdela72
    @pdela72 6 ปีที่แล้ว +3

    Amazing content as always. Just made myself an aggregation in firestore for my project, and, I'm sure you know better than me, but be sure to use transaction instead of get/set pattern not to have mistakes in calculation if multiple donations happen concurrently.

    • @wacalu
      @wacalu 6 ปีที่แล้ว

      I would do a transaction in that case to avoid race conditions

  • @shripadashtekar7
    @shripadashtekar7 5 ปีที่แล้ว +3

    Hi
    Could you please help me with the firestore storage billing for images? I am new to it and I want to know how it is charged. If I upload a 10 MB image and 10 users are downloading it, Will I be charged for 10MB upload and 10*10 MBs of download (which is GB Transferred)? Or will I be charged, just for upload and download operations?

  • @Theyssen
    @Theyssen 6 ปีที่แล้ว +1

    Very interesting and great as always! Could you expand on this topic with transactions?

    • @Fireship
      @Fireship  6 ปีที่แล้ว +2

      Transactions and batches would make a good mini-video for the future.

    • @Theyssen
      @Theyssen 6 ปีที่แล้ว

      Sounds good. I will be watching.

  • @jopadjr
    @jopadjr 6 ปีที่แล้ว

    Great Video mate....Amazing...

  • @electrolyteorb
    @electrolyteorb 3 หลายเดือนก่อน

    Miss these types of videos

  • @mahathirmohammad8635
    @mahathirmohammad8635 4 ปีที่แล้ว +4

    I always try to write cost-efficient code. Sometimes it takes more time in comparison to writing expensive code.

    • @couchman-sw6jy
      @couchman-sw6jy 8 หลายเดือนก่อน +1

      But it saves your ass in the long run. I’m doing the same right now

  • @dr.z7958
    @dr.z7958 6 ปีที่แล้ว +16

    Are you considering some contents about Flutter? it seems the current trend since it also very compatible with Firebase?

    • @OM-bs7of
      @OM-bs7of 3 ปีที่แล้ว +1

      Flutter is for babies, jk

  • @brianevans4
    @brianevans4 3 ปีที่แล้ว +10

    Amazing how much has changed in just two years

    • @dankoller246
      @dankoller246 3 ปีที่แล้ว

      @Vivek Sharma The intro lol

    • @Dance3run
      @Dance3run 2 ปีที่แล้ว +1

      What do you mean? Is this video still relevant?

  • @rlaracue
    @rlaracue 4 ปีที่แล้ว

    Great video. I could use your help on this topic because my firm is building a social chat app with Flutter front end. We are debating on using Firebase or go with a traditional database model (MariaDB) on a bare metal server. Is there way to manage costs effectively with FIrebase for a user base of 500K users with 10-15K DAUs to start? This app could grow to 5 mm users with 1 mm DAUs. We would be using SMS authentication as part of the design. Thanks!

  • @MercyFromOverwatch2
    @MercyFromOverwatch2 2 ปีที่แล้ว

    Jeff is my favourite tech youtuber!

  • @kim15742
    @kim15742 3 ปีที่แล้ว +3

    Here is something I don't get: with traditional relational databases the consensus was to never ever access the DB from the frontend. But it seems like this is exactly what we are doing here. Isn't this a major security hole that allows users to write arbitrary data to the DB?

    • @DeroInvisible
      @DeroInvisible 2 ปีที่แล้ว +2

      I am asking myself the same thing, because the only thing i found for preventing access to all users is setting the firestore security rules. But if I do it the way like in the video at 5:30, I just have to allow all users to modify that "donations" document but doing so, someone can use Cloud firestore REST API and update it to some random values.. which would break the app

  • @alishibli4720
    @alishibli4720 6 ปีที่แล้ว

    Can you please share details about this startup or the articles you read?

  • @PacifiqueStormz
    @PacifiqueStormz 4 ปีที่แล้ว

    those animations tho ,AMAZING!!!

  •  4 ปีที่แล้ว +2

    can you make a flutter version of this video mr fireship sir? :D
    I have multiple users that can add items to their own list (items from that list are identified by userID, not an actualList. i read all and filter the ones for that user with .where(). is there a better away?)

  • @mathijswy
    @mathijswy 6 ปีที่แล้ว +1

    Is your course heavily focussed on firebase or more Angular focussed?

    • @Fireship
      @Fireship  6 ปีที่แล้ว +2

      The pro membership has a variety of topics, some 100% firebase, some 100% angular, and others a mix of both. Later this week I am releasing a new course focused on cloud functions that is framework agnostic.

  • @libertyIsAll132
    @libertyIsAll132 6 ปีที่แล้ว

    why was this ?
    the client was downloading on every update all the collection to calculate the average , instead of adding new value to average ?

  • @TheRanguna
    @TheRanguna 4 ปีที่แล้ว

    You are decoupling the code that adds a donation with the code that updates the aggregation. This is bad because your database will be in an inconsistent state until the cloud function runs.
    Probably, the best way to go about this would be to run the donation function in a transaction that both inserts a new donation and updates the aggregation document. This way, your database will always be in a consistent state.

  • @md.mehrabhaque2223
    @md.mehrabhaque2223 4 ปีที่แล้ว

    There's more efficient and easy solution, there's no need of firebase-functions, you can achieve this on client side, on firestore, at first create a doc having the total donated amount and number of donors, on client side, set a listener to that doc and also while writing new donation entry, just increment that doc using FieldValue.increment. As a result, it avoids extra reads by firebase function and also the changes in total and avg donation become almost simultaneous. And for the last 5 entries just use realtime db.

  • @marvinbuth9310
    @marvinbuth9310 3 ปีที่แล้ว

    I know this video is kind of old but what about implementing serverside rendering with for example NodeJS and just updating the value only once maybe every 10 seconds and then caching it. Maybe I'm missing something but shouldn't that also reduce the amount of calls to the database significantly? Because the server only needs to do one call to the database every 10 seconds and render the front end view with this information for the user.

  • @jayanayana
    @jayanayana 4 ปีที่แล้ว

    I got a doubt If they would have used the Realtime database instead of firestore will that fix issues. As it's just based on storage

  • @ameerattaa2250
    @ameerattaa2250 6 ปีที่แล้ว +3

    can i download a collection and filter it in the client side according to the user request ?

    • @Fireship
      @Fireship  6 ปีที่แล้ว +3

      Yes, you'll be billed for the full collection query, but that is definitely possible

  • @itssidhere
    @itssidhere 4 ปีที่แล้ว

    Dear sir , Please help me I cant disable persistance in cloud firestore for flutter

  • @FarryEntertainment
    @FarryEntertainment 4 ปีที่แล้ว +1

    So how does a chatting work through Firebase?

  • @tonestrada2000
    @tonestrada2000 5 ปีที่แล้ว

    hi is it good to store images on firebase? any cheap alternative for it?

  • @DeroInvisible
    @DeroInvisible 2 ปีที่แล้ว

    I am wondering how to implement a "aggregation" (like in 5:50) in production. If I do it like in the video I have to set the security rules to allow all users to update the "donations" document. Then someone can use firestore rest api and update it to a random values and potentially breaking my app. Is there a way to still track it like in the video and set good security rules?

  • @Nek208
    @Nek208 3 ปีที่แล้ว

    Hey @fireship do you have any video for „like a post/tweet“ with cloud functions?

  • @raulchavan007
    @raulchavan007 4 ปีที่แล้ว

    This was really helpful. I had one question though. If I have a startup that is similar to Uber type of business? And I run my backend on firebase? How much do you think will be my yearly cost for running the app on firebase?

    • @taniasiregar653
      @taniasiregar653 4 ปีที่แล้ว +2

      rahul chavan Build your own server or rent dedicated server for a year. Its safe for this type of business because we don’t know if our app will growing fast or slowly.

  • @KochharAmandeep
    @KochharAmandeep 6 ปีที่แล้ว +1

    I like your channel but I want to know why you named it Angular Firebase? Doesn't React work with Firebase too?

    • @Fireship
      @Fireship  6 ปีที่แล้ว +1

      I did not expect this channel to be more than a few videos. I might rename it in the next few months.

    • @KochharAmandeep
      @KochharAmandeep 6 ปีที่แล้ว

      Angular Firebase keep uploading content mate. You are really helpful

  • @weho_brian
    @weho_brian 5 ปีที่แล้ว

    is there something else i should use besides firebaes?

  • @RyanHaydenMattoon
    @RyanHaydenMattoon 6 ปีที่แล้ว

    Maybe an odd question, but I’ve built a firestore based template website solution that I haven’t launched yet. These videos have me pretty scared that I’m going to be hit with a huge unexpected bill once these things start scaling.
    I was considering making a static site generator that runs on a firestore function and pushes to a CDN whenever there is a write. That way each site can have a bunch of reads that happen only once and the sites can scale like crazy without extra reads. Is this a bad idea? Any other solutions you can think of?

    • @Fireship
      @Fireship  6 ปีที่แล้ว

      That is actually a cool idea and I've seen it done before called "event-driven prerendering". But keep in mind, it takes hundreds of millions of reads before you start seeing a significant firebase bill. It's often a mistake to focus too much on optimization in the early stages. Most apps aren't viral like this, so there is time to optimize as you grow.

  • @KamelJabber1
    @KamelJabber1 6 ปีที่แล้ว

    awesome, thanks!

  • @toolavish
    @toolavish ปีที่แล้ว +16

    Sam hyde should have watched this @perfectguylife

  • @Kareszrk
    @Kareszrk 2 ปีที่แล้ว

    Isn't there any auto block for new requests to FireBase when my app reaches what's included in the free plan?

  • @3nscherzl
    @3nscherzl 3 ปีที่แล้ว

    isn't possible to store a posgresql database with apache server on a common host server and synchronize it with flutter ?

  • @jehanmuse330
    @jehanmuse330 5 ปีที่แล้ว

    Hi sir , may i know why you use firebase cloud function to update database ?
    just wondering what is the advantage .

    • @IshanKBG
      @IshanKBG 3 ปีที่แล้ว

      Cloud functions lets you run backend code for the website

  • @usamajamil738
    @usamajamil738 5 ปีที่แล้ว +1

    Recommend a channel for react firebase.

  • @Reddrik
    @Reddrik ปีที่แล้ว +3

    A cautionary tale.

  • @MuhammadAmir-mf9xt
    @MuhammadAmir-mf9xt 4 ปีที่แล้ว

    This is amazing ❤👍👍👍

  • @xylvnking
    @xylvnking ปีที่แล้ว +1

    Anybody know if there's a way to set a spending limit by now? New dev here, spooked tf out about a big bill. I don't understand how I can protect myself?

  • @carrillocarlosce
    @carrillocarlosce 6 ปีที่แล้ว +2

    I had a similar problem by writing the user locations coordenates to firestore, thank that i was in spark plan this didn't affect, do you know how can I update a user location for realtime track

    • @Fireship
      @Fireship  6 ปีที่แล้ว +3

      Generally, this is something you debounce in the client. So you might have a GPS update every 500ms, but you only actually write to the DB every 10 seconds. There are other strategies as well depending on how your UI needs to present the data.

    • @mateja176
      @mateja176 6 ปีที่แล้ว +2

      Exactly! Perhaps write to the DB only if the distance increases by more than 10 Km compared to the last Geo-point stored.

    • @carrillocarlosce
      @carrillocarlosce 6 ปีที่แล้ว

      Mmm right, this is something that i definetly gonna take care, thanks.

  • @jatinrewri3163
    @jatinrewri3163 4 ปีที่แล้ว

    Plz a tutorial on arrays and map for flutter to save money on this topic!!!

  • @alytechnology
    @alytechnology 2 ปีที่แล้ว

    There is a big mistake here the max size for a doc is 1 mb so u cant put millions in that array but maybe a thousand or something like that

  • @VALOFLICKS
    @VALOFLICKS 3 ปีที่แล้ว

    This is not gonna work, if you have 5-10 concurrent request your data will be messed up.
    And if you wrap it inside transaction you will likely get "contention" error because of concurrent read/write request on a single document.

  • @vinayc
    @vinayc 4 ปีที่แล้ว

    Can you make a video on how to do in vuefire?

  • @mahmoudnassif9339
    @mahmoudnassif9339 3 ปีที่แล้ว +1

    I got 277k $ bill what should I do?

  • @wahabrehman6848
    @wahabrehman6848 3 ปีที่แล้ว +1

    Does anyone else get random reads from the firestore?

  • @Unc3
    @Unc3 3 ปีที่แล้ว +1

    Took me 2 hours to build a similar app and 4 days to troubleshoot firebase.

  • @Ragnarok540
    @Ragnarok540 4 ปีที่แล้ว

    Technical debt, right?

  • @levihalperin7649
    @levihalperin7649 2 ปีที่แล้ว +1

    Would it be possible for someone to make some bots that create users to request and send requests and thus run up your bill?

    • @J70istooshort
      @J70istooshort 8 หลายเดือนก่อน

      yup, and its still not fixed!

  • @tejedaAlex
    @tejedaAlex 6 ปีที่แล้ว

    are the firebase aggregations charged per read and write? I mean, if X times the aggregation is triggered because there was X operations trigger it, would be an extra charge?

    • @Fireship
      @Fireship  6 ปีที่แล้ว

      You have 1 extra read and 1 extra write and 1 cloud function call per data change. If the data is read heavy, this is usually a very good tradeoff.

    • @keep
      @keep 6 ปีที่แล้ว

      @@Fireship when you choose a Firebase plan, once the cap is reached isn't the dB supposed to stop working? Or in this case it continued to work and charged extra for the usage after the cap.

  • @silentkiller4091
    @silentkiller4091 2 ปีที่แล้ว +1

    So google with all its power of AI can't detect this unusually high requests and alert the user?

  • @MatthiasWiemann1
    @MatthiasWiemann1 3 ปีที่แล้ว +2

    Solution is wrong because it creates a incorrect sum if trigger onCreate is executed multiple times. See firebase.google.com/docs/functions/firestore-events?hl=en “Events are delivered at least once, but a single event may result in multiple function invocations. Avoid depending on exactly-once mechanics, and write idempotent functions.”

  • @piotrbukowski5703
    @piotrbukowski5703 6 ปีที่แล้ว +1

    Angular Fire's observables are hot so many subscriptions to the same collection shouldn't cause more than 1 read operation of entire collection. Am I wrong?

    • @Fireship
      @Fireship  6 ปีที่แล้ว

      Yes, but it depends on how you create them. Because I was creating a new reference for each obs, it would be a unique read. A benefit of shareReplay is that it allows late subscribers to get the last value, otherwise they would get nothing or have to initiate a new read.

    • @piotrbukowski5703
      @piotrbukowski5703 6 ปีที่แล้ว +1

      Recently I made some tests about this case. It turned out that if you subscribe collection with the same path (even creating new reference to it) many times and while at least one subscription is active you don't make additional requests.

    • @narcodico
      @narcodico 6 ปีที่แล้ว

      True, shareReplay is basically a behaviorSubject which doesn't take an initial value since it will start emitting last value to it's late subscribers only after the first call to next has been made. This will ensure latest value consumption in different components without extra reads, as long as there is at least one active subscriber...when last subscriber unsubscribes it will tear down the whole chain. After this point, a new subscribe will result in reading from firestore again...am I getting this right ?

    • @piotrbukowski5703
      @piotrbukowski5703 6 ปีที่แล้ว

      Rolly Peres Yes, but I related to case without using shareReplay, just plain valueChanges observable.

    • @narcodico
      @narcodico 6 ปีที่แล้ว

      That's not gonna cache the values, but read them every time you subscribe to it.

  • @KyoKurosagi
    @KyoKurosagi 6 ปีที่แล้ว

    isn't there is a limit of document size? we can't just store all thing into a document. it will blow once over the document size limit.

    • @Fireship
      @Fireship  6 ปีที่แล้ว

      Yes, 1MB. That's why I only aggregate the last 5 records so it will always stay super small.

  • @FrankLloydTeh
    @FrankLloydTeh 6 ปีที่แล้ว

    Will this not run into race conditions? Where aggData.total is not updated and two create events fire so one overrides the other?

    • @Fireship
      @Fireship  6 ปีที่แล้ว

      That is an important consideration. A less efficient approach, but safer, is to read the entire collection on every update in the function. This will reconcile the true total value on every update, but requires more reads. If a race condition occurred on the last transaction, it will be fixed on the next one or could be verified with a regular cron job. Also puf has some thoughts about that as well stackoverflow.com/questions/49290380/how-do-you-avoid-a-possible-race-condition-with-firebase-cloud-functions

    • @cbro_
      @cbro_ 6 ปีที่แล้ว

      yes, it will. try using Firestore with transactions.

  • @tsortanidischristos412
    @tsortanidischristos412 5 ปีที่แล้ว +1

    Is firebase charging even the reads from persisted data that's coming from the local cache?

    • @Fireship
      @Fireship  5 ปีที่แล้ว +2

      No, this video is actually a bit over-optimized. Firebase does not charge for the cached results on a listener firebase.google.com/docs/firestore/pricing

    • @tsortanidischristos412
      @tsortanidischristos412 5 ปีที่แล้ว

      @@Fireship you said 'does'?

    • @Fireship
      @Fireship  5 ปีที่แล้ว

      @@tsortanidischristos412 Oops, that was a mistake. I meant 'does not'

    • @tsortanidischristos412
      @tsortanidischristos412 5 ปีที่แล้ว

      Oh haha still thanks :)

  • @testg4andmmm129
    @testg4andmmm129 4 ปีที่แล้ว

    Yea thats the problem of reactive subscribe thing. Its hard to understand. Easy way is to not use reactive . Do normal way...

  • @poimsm
    @poimsm 6 ปีที่แล้ว

    What is a tab operator?

    • @eus9
      @eus9 6 ปีที่แล้ว

      poimsm It's the *tap* (with a 'p') operator from rxjs, it allows you to carry out side effects while having access to the observable data without modifying it. Example shown in the video is perfect: you want to log out what was piped through, but not change it.

  • @elanza48
    @elanza48 4 ปีที่แล้ว +2

    I will never use firebase again !

  • @averageconsumer5374
    @averageconsumer5374 4 ปีที่แล้ว +1

    I don't understand anything 😔

  • @PutraSurya-78
    @PutraSurya-78 5 ปีที่แล้ว

    don't do this if you have large of data, document in firestore maximum size is only 1MB

    • @JohnDoe-zc4mu
      @JohnDoe-zc4mu 5 ปีที่แล้ว +2

      I don't see any drawback here... the aggregated document has 3 fields: the total of money, the number of donations and the last 5 donations. As you can see, you'll still have 3 fields with max 5 donations object no matter on how your application scales, so you'll have a full control on that and never break the 1MB size limit.

  • @unicornpoo7441
    @unicornpoo7441 ปีที่แล้ว

    Jethro Neptull shoulda given this a look

  • @Max-cr3dz
    @Max-cr3dz 6 ปีที่แล้ว +8

    Somebody needs to create plugin/package that will console log number of all read/writes requests to firestore... (in dev mode)

  • @osquigene
    @osquigene 6 หลายเดือนก่อน +1

    That all look very complex for such a simple thing, why not just have a cache in your backend endpoint? You don't even need to optimize and can have 3 separate endpoints (sum/average/list). If you have non-stop users for the whole day and set an expiration of 1s, you would only get 86 400 requests a day for these 3 pieces of data. The good part is its independant from the number of users and people would just hit the cache (your RAM most likely in a case like this).
    I mean, that data is independant from the user's watching it so it shouldn't require anything too fancy.
    I had no idea Firebase could be used as a real database, I though this was only made for (mobile) app settings (tokens/urls/passwords/etc.). What is the idea behind using Firebase as a database instead of a classical managed PostgreSQL database (like the one your favorite cloud provider offers)?

  • @GwidazMan
    @GwidazMan 6 ปีที่แล้ว +13

    Use firebase database which is not charging you by read/write but by the space used..

    • @Radial9Gaming
      @Radial9Gaming 5 ปีที่แล้ว +4

      Also charging you bandwidth. Both of these are more expensive than the charges made from Firestore.

  • @yourasa1213
    @yourasa1213 3 ปีที่แล้ว

    Can you do this example in Flutter? I will buy you a coffee. Three coffees, at least.

  • @LoganDark4357
    @LoganDark4357 6 ปีที่แล้ว +13

    Atom is the slowest text editor I've ever used, much slower as a code editor too.

    • @blizzard182
      @blizzard182 5 ปีที่แล้ว +4

      LoganDark visual code ftw. And it is based in atom which is amazing

    • @LoganDark4357
      @LoganDark4357 5 ปีที่แล้ว +2

      LOL VS sucks

    • @Erraticfox
      @Erraticfox 5 ปีที่แล้ว +13

      @@LoganDark4357 VSCode is easily the fastest feature full IDE, kid.

    • @LoganDark4357
      @LoganDark4357 5 ปีที่แล้ว +2

      VSCode isn't an IDE. It's a text editor, like Atom or Sublime. The plugins make it what it is.

    • @Erraticfox
      @Erraticfox 5 ปีที่แล้ว +9

      It's not a text editor, it's a source code editor, if you wanna split hairs.

  • @Bangy
    @Bangy 3 ปีที่แล้ว

    I got pranked on by a former friend who ran Apache Benchmark on my Compute Engine web server. Ended up setting me back $5,000 of bandwidth fees.
    Never using Google cloud again after that.

  • @joeldaros
    @joeldaros 6 ปีที่แล้ว

    That’s a great topic. It’s like some when you start learning and make a cloud function update yourself and the function enter in infinite loop. That’s funny.

    • @Fireship
      @Fireship  6 ปีที่แล้ว

      I almost included that infinite loops in this video, that's another common source of surprise costs.

  • @YousefSh
    @YousefSh 6 ปีที่แล้ว

    Can you share the heckernoon article?

    • @YousefSh
      @YousefSh 6 ปีที่แล้ว

      Nevermind I found it: hackernoon.com/how-we-spent-30k-usd-in-firebase-in-less-than-72-hours-307490bd24d

    • @Fireship
      @Fireship  6 ปีที่แล้ว

      Yes, it's in the description

    • @Fireship
      @Fireship  6 ปีที่แล้ว

      I pasted the wrong link in the description, thanks for catching that

    • @YousefSh
      @YousefSh 6 ปีที่แล้ว

      Haha. Ok I was super confused. Thanks!