CRC-Blogs

Performance Comparison of MongoDB and Text File for Rule Matching

1. Introduction:

Generally, text file is a kind of computer file that is structured as a sequence of lines of electronic text. A text file exists stored as data within a computer file system. A term named as database is an organized collection of data, usually stored and accessed electronically from a computer system. Considering three parameters i.e., consistency, availability and partition tolerance of CAP theorem, MongoDB is one of the choice among several other databases due to provision of higher availability and partition tolerance. 

2. Description:

Use of text files to store data provides several advantages to the users. However, the most important is the simplicity of plain text formats. For example: we do not require complex software’s to create a text file, we do not need hard/mysterious skills beyond being able to type on a keyboard and it is easy for users to view and modify the store data. Similarly, use of databases instead of text files provide: reduced data redundancy, reduced updating errors and increased consistency, greater data integrity and independence from applications programs, improved data access to users through use of host and query languages, improved data security and reduced data entry, storage, and retrieval costs. In addition to the aforementioned advantages related to the database, applications developed for database allow users to gain access to the data they require. More importantly, they filter out any unnecessary data, permitting users to only have access to the records that they need. Moreover, they keep data safe, while allowing multiple users to access data in a streamlined fashion.

3. Experiment:

In order to conduct an experiment, we have generated 10 million rules using python script in the first step. After that we have stored the generated rules in the text file and MongoDB. Thereafter, we have considered three scenarios i.e., best, average and worst.

  • Best case scenario: In the best case scenario, we have selected the first one rule in the text file and performed matching. Similarly, we have performed the matching of selected rule with the MongoDB. In both the cases we have noted the time required to match the rule. The time required to match from text file is 0.001s while the 0.026s is required to match using MongoDB.
  • Average case scenario: In the average case scenario, we have selected the rule in the mid of the text file and performed matching. Similarly, we have performed the matching of selected rule with the MongoDB. In both the cases we have noted the time required to match the rule. The time required to match from text file is 8.49s while the 3.103s is required to match using MongoDB.
  • Worst case scenario: In the worst case scenario, we have selected the last rule in the text file and performed matching. Similarly, we have performed the matching of selected rule with the MongoDB. In both the cases we have noted the time required to match the rule. The time required to match from text file is 19.59s while the 6.5s is required to match using MongoDB. The performance comparison of all three cases is shown in Figure 1.

 

Figure 1: Performance comparison of MongoDB with Text File

4. Conclusions

Based on the results of conducted experiment, we have analyzed that the MongoDB requires lower time to perform match as compared to the text file. Moreover, we have analyzed that the MongoDB provides rapid response for searching a rules from the large number of rules dataset. Consequently, response of searching rule from the text file is three times lower than the MongoDB.