1

I am writing a telegram bot (using webhooks) that sequentially reads smalls nodes (stored as json files) and now I'm in front of a crossroad: monolitic vs modular approach

The case:

The basic structure is a tree, made of several nodes: each node has just a text-property and a link to his son (a pointer to his next) and every tree will be located in a single folder.

The question is :

Should I use one (json) file per tree that contains all the nodes or should I use several (json) files per node? I want to achieve the best reliability of my service.

One File:

  • pro: Easy to refactor, just one source to read
  • cons: Costant "big" (around 100-200kb) read the whole file for a single node

Multiple files:

  • pro: Costant small reads (1-3kb) on demand
  • cons: Harder to refactor (not the hardest), redundancy over each node file, file-swarm

Am I missing Something?

I think that the multiple file approach is the best choiche to avoid concurrency between the request made by the users (tell me if I am wrong), keeping the read time as reduced as possible. The thing that scares me is that these node will be written by people that are not really into computing stuff, and (I hope not) refactoring could always be right around the corner.

ArchGeko
  • 11
  • 3
  • I would argue, at least from a time point, single would be better as you only need to do the *connection* once. Yes downloading a 3kb file is quick but I'd wager it's not *that much* quicker than the 200kb as at this size most of the time is the connection. And with the big file, you've got it all there. Shove it in a class and you're gravy. – Joshua Oct 05 '18 at 02:37
  • All requests are on demand: everytime a user taps on a button I need to load another node and by using webhooks there is no active process in polling (that can keep these information up in memory) – ArchGeko Oct 05 '18 at 02:48

0 Answers0