Database plugins have been developed to try to improve storage and retrieval of low amounts of data in a high-volume
data environment. Sysrepo uses a diff data structure to inform its subscribers about the changes in the data
tree, diffs however can also be sent to datastore plugins to help them store these changes. The default plugin
JSON DS file does not use diff and it instead parses the whole data tree into a JSON format and stores it in the file. Databases on
the other hand can be used to store only the changes from the diff and in specific use-cases speed up the whole process.
In order to rerun performance tests, please feel free to use the Dockerfile below as suggested.
docker build --file scripts/db_plg_perf.Dockerfile --tag perf .
docker run --rm perf
| Options
- Data set size : 1000
- Each test executed : 10 times
| Performance tests
- JSON DS file
| test name | time | comparison |
|---|---|---|
| get tree | 0.001854 s | 1.000 x |
| get item | 0.001778 s | 1.000 x |
| get tree hash | 0.001265 s | 1.000 x |
| get tree hash cached | 0.000011 s | 1.000 x |
| get user ordered tree | 0.000771 s | 1.000 x |
| get oper tree | 0.003297 s | 1.000 x |
| create batch | 0.004387 s | 1.000 x |
| create user ordered items | 0.007394 s | 1.000 x |
| create all items | 0.009278 s | 1.000 x |
| create all items oper | 0.009828 s | 1.000 x |
| many oper change_subs | 0.268622 s | 1.000 x |
| remove all items | 0.000290 s | 1.000 x |
| remove all items cached | 0.000220 s | 1.000 x |
| remove whole subtree | 0.000279 s | 1.000 x |
| remove whole subtree cached | 0.000227 s | 1.000 x |
| create an item | 0.002188 s | 1.000 x |
| create an item cached | 0.001278 s | 1.000 x |
| create an item oper | 0.003886 s | 1.000 x |
| modify an item | 0.001398 s | 1.000 x |
| modify an item cached | 0.000505 s | 1.000 x |
| remove an item | 0.001403 s | 1.000 x |
| remove an item cached | 0.000508 s | 1.000 x |
- MONGO DS
| test name | time | comparison |
|---|---|---|
| get tree | 0.003391 s |
|
| get item | 0.004908 s |
|
| get tree hash | 0.000210 s |
|
| get tree hash cached | 0.000091 s |
|
| get user ordered tree | 0.002773 s |
|
| get oper tree | 0.009505 s |
|
| create batch | 0.015844 s |
|
| create user ordered items | 0.116348 s |
|
| create all items | 0.019848 s |
|
| create all items oper | 0.017425 s |
|
| many oper change_subs | 0.656261 s |
|
| remove all items | 0.005498 s |
|
| remove all items cached | 0.005236 s |
|
| remove whole subtree | 0.002150 s |
|
| remove whole subtree cached | 0.001359 s |
|
| create an item | 0.004550 s |
|
| create an item cached | 0.000725 s |
|
| create an item oper | 0.003609 s |
|
| modify an item | 0.004212 s |
|
| modify an item cached | 0.000737 s |
|
| remove an item | 0.003979 s |
|
| remove an item cached | 0.000465 s |
|
- REDIS DS
| test name | time | comparison |
|---|---|---|
| get tree | 0.008860 s |
|
| get item | 0.011593 s |
|
| get tree hash | 0.000079 s |
|
| get tree hash cached | 0.000055 s |
|
| get user ordered tree | 0.010339 s |
|
| get oper tree | 0.005808 s |
|
| create batch | 0.018640 s |
|
| create user ordered items | 0.055091 s |
|
| create all items | 0.023312 s |
|
| create all items oper | 0.023822 s |
|
| many oper change_subs | 0.534279 s |
|
| remove all items | 0.001734 s |
|
| remove all items cached | 0.000676 s |
|
| remove whole subtree | 0.001838 s |
|
| remove whole subtree cached | 0.000744 s |
|
| create an item | 0.009084 s |
|
| create an item cached | 0.000773 s |
|
| create an item oper | 0.003516 s |
|
| modify an item | 0.009051 s |
|
| modify an item cached | 0.000476 s |
|
| remove an item | 0.008450 s |
|
| remove an item cached | 0.000456 s |
|
All comparisons refer to how many times faster (green) or slower (red) the current plugin is compared to the first plugin.
| Options
- Data set size : 10000
- Each test executed : 10 times
| Performance tests
- JSON DS file
| test name | time | comparison |
|---|---|---|
| get tree | 0.019634 s | 1.000 x |
| get item | 0.017939 s | 1.000 x |
| get tree hash | 0.014083 s | 1.000 x |
| get tree hash cached | 0.000028 s | 1.000 x |
| get user ordered tree | 0.007701 s | 1.000 x |
| get oper tree | 0.031657 s | 1.000 x |
| create batch | 0.047354 s | 1.000 x |
| create user ordered items | 0.090858 s | 1.000 x |
| create all items | 0.106988 s | 1.000 x |
| create all items oper | 0.111167 s | 1.000 x |
| many oper change_subs | 3.713649 s | 1.000 x |
| remove all items | 0.003449 s | 1.000 x |
| remove all items cached | 0.002566 s | 1.000 x |
| remove whole subtree | 0.002902 s | 1.000 x |
| remove whole subtree cached | 0.002584 s | 1.000 x |
| create an item | 0.023081 s | 1.000 x |
| create an item cached | 0.014541 s | 1.000 x |
| create an item oper | 0.041899 s | 1.000 x |
| modify an item | 0.015329 s | 1.000 x |
| modify an item cached | 0.006262 s | 1.000 x |
| remove an item | 0.015146 s | 1.000 x |
| remove an item cached | 0.005578 s | 1.000 x |
- MONGO DS
| test name | time | comparison |
|---|---|---|
| get tree | 0.032961 s |
|
| get item | 0.032789 s |
|
| get tree hash | 0.000243 s |
|
| get tree hash cached | 0.000227 s |
|
| get user ordered tree | 0.026990 s |
|
| get oper tree | 0.034777 s |
|
| create batch | 0.151078 s |
|
| create user ordered items | 1.323064 s |
|
| create all items | 0.218437 s |
|
| create all items oper | 0.165269 s |
|
| many oper change_subs | 7.151995 s |
|
| remove all items | 0.039869 s |
|
| remove all items cached | 0.039474 s |
|
| remove whole subtree | 0.015050 s |
|
| remove whole subtree cached | 0.013198 s |
|
| create an item | 0.029860 s |
|
| create an item cached | 0.007017 s |
|
| create an item oper | 0.034413 s |
|
| modify an item | 0.028166 s |
|
| modify an item cached | 0.004840 s |
|
| remove an item | 0.026894 s |
|
| remove an item cached | 0.004642 s |
|
- REDIS DS
| test name | time | comparison |
|---|---|---|
| get tree | 0.095244 s |
|
| get item | 0.093283 s |
|
| get tree hash | 0.000123 s |
|
| get tree hash cached | 0.000153 s |
|
| get user ordered tree | 0.148259 s |
|
| get oper tree | 0.040969 s |
|
| create batch | 0.220800 s |
|
| create user ordered items | 0.627265 s |
|
| create all items | 0.264463 s |
|
| create all items oper | 0.265828 s |
|
| many oper change_subs | 5.875323 s |
|
| remove all items | 0.021471 s |
|
| remove all items cached | 0.007099 s |
|
| remove whole subtree | 0.022487 s |
|
| remove whole subtree cached | 0.008592 s |
|
| create an item | 0.112921 s |
|
| create an item cached | 0.008093 s |
|
| create an item oper | 0.041982 s |
|
| modify an item | 0.131935 s |
|
| modify an item cached | 0.006567 s |
|
| remove an item | 0.113544 s |
|
| remove an item cached | 0.006064 s |
|
All comparisons refer to how many times faster (green) or slower (red) the current plugin is compared to the first plugin.
| Options
- Data set size : 100000
- Each test executed : 10 times
| Performance tests
- JSON DS file
| test name | time | comparison |
|---|---|---|
| get tree | 0.257987 s | 1.000 x |
| get item | 0.214855 s | 1.000 x |
| get tree hash | 0.182746 s | 1.000 x |
| get tree hash cached | 0.000405 s | 1.000 x |
| get user ordered tree | 0.092115 s | 1.000 x |
| get oper tree | 0.413835 s | 1.000 x |
| create batch | 0.658496 s | 1.000 x |
| create user ordered items | 0.964103 s | 1.000 x |
| create all items | 1.214159 s | 1.000 x |
| create all items oper | 1.233159 s | 1.000 x |
| many oper change_subs | 42.937387 s | 1.000 x |
| remove all items | 0.036810 s | 1.000 x |
| remove all items cached | 0.043710 s | 1.000 x |
| remove whole subtree | 0.036970 s | 1.000 x |
| remove whole subtree cached | 0.044760 s | 1.000 x |
| create an item | 0.262785 s | 1.000 x |
| create an item cached | 0.234830 s | 1.000 x |
| create an item oper | 0.778777 s | 1.000 x |
| modify an item | 0.162250 s | 1.000 x |
| modify an item cached | 0.107049 s | 1.000 x |
| remove an item | 0.161752 s | 1.000 x |
| remove an item cached | 0.105254 s | 1.000 x |
- MONGO DS
| test name | time | comparison |
|---|---|---|
| get tree | 0.419329 s |
|
| get item | 0.415434 s |
|
| get tree hash | 0.000278 s |
|
| get tree hash cached | 0.003688 s |
|
| get user ordered tree | 0.345308 s |
|
| get oper tree | 0.432859 s |
|
| create batch | 1.749139 s |
|
| create user ordered items | 14.456433 s |
|
| create all items | 2.360571 s |
|
| create all items oper | 1.890673 s |
|
| many oper change_subs | 80.463488 s |
|
| remove all items | 0.443124 s |
|
| remove all items cached | 0.482664 s |
|
| remove whole subtree | 0.194736 s |
|
| remove whole subtree cached | 0.167887 s |
|
| create an item | 0.381125 s |
|
| create an item cached | 0.171303 s |
|
| create an item oper | 0.716619 s |
|
| modify an item | 0.343846 s |
|
| modify an item cached | 0.100483 s |
|
| remove an item | 0.364858 s |
|
| remove an item cached | 0.109074 s |
|
- REDIS DS
| test name | time | comparison |
|---|---|---|
| get tree | 1.260671 s |
|
| get item | 1.354169 s |
|
| get tree hash | 0.000126 s |
|
| get tree hash cached | 0.002517 s |
|
| get user ordered tree | 1.757068 s |
|
| get oper tree | 0.448883 s |
|
| create batch | 2.471534 s |
|
| create user ordered items | 5.911053 s |
|
| create all items | 3.006915 s |
|
| create all items oper | 3.160048 s |
|
| many oper change_subs | 68.550078 s |
|
| remove all items | 0.226741 s |
|
| remove all items cached | 0.083266 s |
|
| remove whole subtree | 0.222872 s |
|
| remove whole subtree cached | 0.093635 s |
|
| create an item | 1.344594 s |
|
| create an item cached | 0.166586 s |
|
| create an item oper | 0.694264 s |
|
| modify an item | 1.245561 s |
|
| modify an item cached | 0.108219 s |
|
| remove an item | 1.291421 s |
|
| remove an item cached | 0.100165 s |
|
All comparisons refer to how many times faster (green) or slower (red) the current plugin is compared to the first plugin.
get treeretrieves the whole data tree. The XPath used for retrieval is not a Path, so databases cannot use quick prefix match to get the necessary data and have to load all the data. Databases will always be slower since loading a file is faster than loading all of the module's data from the database.get itemretrieves one item. Since the XPath used for retrieval is not a Path (much like in the case ofget tree), databases load all the data. Databases will always be slower here.get tree hashretrieves one item. Since the XPath used for retrieval is a Path, databases load only one item (and parents of this item if any), so the number of items retrieved by the databases is at most the depth of the tree where this item lies. Databases will always be faster from certain amount of items stored (at 1000 they will always be faster).get tree hash cachedretrieves one item. No module's data are loaded, everything is cached. Databases will always be slower here, since checking file permissions is much faster than checking the data containing permissions from the database.get user ordered itemsretrieves the whole data tree. Databases will always be slower since loading a file is faster and the userordered lists and leaflists have to be sorted at the end because databases do not retrieve the data in the correct order.get oper treeretrieves the whole data tree from Operational datastore. No data are loaded, everything is cached. No permissions are checked, speed should be approximately the same.
Note: MongoDB is faster at loading many data at once than Redis, but Redis has faster retrieval of low amounts of data.
create batchcreates a lot of items. Databases should always be slower here. Loading is performed before storing to create a diff (loading is slower).create user ordered itemscreates a lot of userordered items. Databases should always be much slower here. The changes from the diff have to be applied one by one (without the advantage of bulking/pipelining). Additionaly there are multiple operations per item (not just a simple store).create all itemsis the same ascreate batch, but the sysrepo data preparation phase takes longer (no sr_edit_batch()).create all items opercreates a lot of items in Operational datastore. Since databases also use diff for Operational datastore, the times are about the same as withcreate all items(the Operational datastore also needs to store metadata for the items, so it should be a little bit slower in this case).many oper change_subscreates and deletes a lot of items. Databases should always be slower.remove all itemsdeletes a lot of items. Databases should always be much slower. Loading is performed before storing. Deleting one item in the database is slower than deleting one item in memory (forJSON DS fileplugin after loading it into the memory).remove all items cacheddeletes a lot of items. Databases should always be slower. All data are in cache (no data loading, which is good), but deleting is still slow.remove whole subtreeandremove whole subtree cachedare the same asremove all itemsandremove all items cached, but MongoDB has an optimization for deleting a whole subtree (in a form of regex delete), which is faster than a regular delete of lots of items. However databases are still much slower.
Note: MongoDB is faster at creating lots of data than Redis, but slower at deleting them. Also Redis has a much better per item insertion/deletion performance as is apparent from the create user ordered items
create an itemcreates one item. Load is performed to create the diff, so databases are always slower.create an item cachedcreates one item. Load is not performed. Databases should be faster from certain amount of items stored (at 1000 they will always be faster).create an item opercreates one item in Operational datastore. Databases should be faster from certain amount of items stored, but this depends.modify an itemandremove an itemmodifies and deletes one item. Databases are always slower because of loading.modify an item cachedandremove an item cachedmodifies and deletes one item. Databases should have a similar performance toJSON DS fileplugin. Modifying or deleting one item is much easier process than creating one forJSON DS fileplugin.
Loading of one item is much better for more data, because the complexity of other sysrepo processes during load is constant. Storing of one item on the other hand is not. The complexity of data validation during store is linear and so constant times during database store can only speed up the whole process so much.
JSON DS file store.
JSON DS file plugin.
for many items JSON DS file store. If we want to further speed up the process, we need to make the validation process faster.
Database plugins should only be used when lots of small changes are expected to be made (especially creating one item periodically) and they should only be used on Running datastore using a cached connection, otherwise they will always be slower than the default JSON DS file plugin. If unsure, avoid them.