Firebase fan out - the most economical way?

I know that this problem may have been raised several times, but I read most of the available questions, but did not find anything that could exactly help answer my question. As suggested by the Firebase team, ventilation technology is the recommended way to provide fast data reads, but at the cost of data duplication. I know this question is subjective and application dependent, but what is the best solution in terms of cost savings ($) and reading data?

  • Output the same node into several children (save data that is read only once, but has redundancy, therefore consume more Firebase storage) (see image Firebase database - "Fan Out" technology).
  • Put only one node and another node reference by its key (not redundant and consume less Firbase storages, but you need to read twice - get the key and get the node for the key) (see image https://stackoverflow.com/a/268012/ ... )

In the context, I am creating a non-commercial application for the market, so I need to apply the best solution in terms of balancing both cost savings ($) and fast data reading.

On the other hand, read twice (bandwidth) and larger storage? Which one is more economical?

+6
source share
1 answer

I would say that ideally in Firebase you only read or sync what you need. . Thus, your database queries are linked to other filters to make the query as specific as possible. If you can nail this, then you will still create a very intelligent data structure that will be cost-effective.

Now the real discussion is Fan-Out Technology or just send a link to the nodes . As I personally prefer Fan-Out, and also use it successfully , so I will only answer this technique, which will also give you an indication of the reason why I do not want to use the link and that’s it.

  • First of all, it is the experience and performance of end users. What happens in the form of a Charge Data Chunk Sync . In general, this means that instead of downloading small pieces, you are aimed at the maximum possible to reduce the use of High Cell , High Battery Drain , High Bandwidth radio communications , and update and synchronize the application as quickly as possible .

If you are aiming for such application performance, then you clearly see that Fan-Out is a winner by a different technique for the following reasons.

  • You are loading a large block of data stored in another node, which prevents your cellular radio from staying for long.
  • When you download all the information at once, your application works better than others. Obviously, in general, I do not want you to download the complete database. All about this smart balance, which forces you to download only what is required in the first place.
  • This is not that it is the only method that will give you a faster read and better data structure. There are other methods, such as indexing, data validation, and security rules , which are equally important. Everything correctly connected to the right data structure will give you much better performance.
  • In a situation where you have only a link to other nodes, and not the actual data , you may find yourself in a situation where you actually have nothing to show to your users, Let's say your users do not get a good connection , so after one reading, which gave you only a link, the network crashes . Thus, until the network is back up , your users do not see anything and trust me that this is a very bad situation for the application. Your goal as a developer should be to reduce the chances of these situations.

So, I would recommend you switch to the FAN-OUT technique , because it is faster and more economical when you see other factors, such as data filtering, indexing and security rules, as well as strong>. Yes, this is due to the low cost of high storage utilization. But what does smaller storage mean when you don't have happy users? Nevertheless, it comes down to personal preference. But I shared my experience and thoughts, hoping that this will help you make the right decision.

I would advise you to go through this and a deeper understanding of SQL Data modeling strong>

Let me know if this information has helped you.

+8
source

All Articles