# Implications of multiple redis db support on emoncms components

**URL:** <https://community.openenergymonitor.org/t/implications-of-multiple-redis-db-support-on-emoncms-components/10245>\
**Category:** Emoncms\
**Created:** [26 February 2019 20:16 UTC](https://community.openenergymonitor.org/t/implications-of-multiple-redis-db-support-on-emoncms-components/10245 "2019-02-26T20:16:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Greebo](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/greebo/32/4556_2.png) [@Greebo](https://community.openenergymonitor.org/u/Greebo)\
**Post date:** [26 February 2019 20:16 UTC](https://community.openenergymonitor.org/t/implications-of-multiple-redis-db-support-on-emoncms-components/10245/1 "2019-02-26T20:16:10Z")

</div>

> [@Emoncms V9.9.7+ Release](https://community.openenergymonitor.org/t/emoncms-v9-9-7-release/10240/1):
>
> Support multiple redis databases @karlp [V9.9.6 Stable merge by glynhudson · Pull Request #1159 · emoncms/emoncms · GitHub](https://github.com/emoncms/emoncms/pull/1159/commits/67a36a28891adcb8c4784512d03fc9c27fb8dc38)

Did anyone test service-runner with a non-null `dbnum`?  
My expectation is that service-runner is unaware of this and if you choose any other `dbnum` apart from `''`, service-runner and all Modules that use it will cease to trigger on a service-runner flag.  
It should certainly be noted in the comments in the settings file that changing `dbnum` will cause service-runner to no longer trigger. While we’re updating the settings file, until the service-runner flag has its own code that always uses the same prefix, it’s probably also worth adding as comment that changing the prefix from `emoncms` or `''` also breaks service-runner.

---

<div class="post-metadata">

**Author:** ![borpin](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/borpin/32/193_2.png) [@borpin](https://community.openenergymonitor.org/u/borpin)\
**Post date:** [26 February 2019 20:33 UTC](https://community.openenergymonitor.org/t/implications-of-multiple-redis-db-support-on-emoncms-components/10245/2 "2019-02-26T20:33:55Z")

</div>

> [@Emoncms V9.9.7+ Release](https://community.openenergymonitor.org/t/emoncms-v9-9-7-release/10240/3):
>
> While we’re updating the settings file, until the service-runner flag has its own code that always uses the same prefix, it’s probably also worth adding as comment that changing the prefix from `emoncms` or `''` also breaks service-runner.

I did suggest the comment was added regarding the prefix.

---

<div class="post-metadata">

**Author:** ![pb66](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/pb66/32/27_2.png) [@pb66](https://community.openenergymonitor.org/u/pb66)\
**Post date:** [26 February 2019 20:42 UTC](https://community.openenergymonitor.org/t/implications-of-multiple-redis-db-support-on-emoncms-components/10245/3 "2019-02-26T20:42:46Z")

</div>

only the core emoncms supports multiple databases, it’s not implemented in the other modules.

This did cross my mind when looking at service-runner, but I didn’t pursue it as it raised further questions about which Redis database would the service-runner connect to if there are multiple Redis databases? Presumably multiple databases would be used when there are multiple emoncms instances, so do we then need a single database for service-runner across instances??

TBH I was a bit surprised to see the multiple database option merged since it seems widely documented that _"Use of multiple database in same server instance is **discouraged** and **deprecated**"_ and that’s why we use prefix’s.

I looked into this way back when I first ever created a multi(emoncms) instance server, I wanted to use separate db’s so that the flush command worked, but I was dissuaded by the general consensus that it was bad form to have multiple databases on one Redis server. Although “deprecated” for several years, it’s still possible it would seem.

Perhaps a decision needs to be made as to whether emoncms really needs to support multi-db’s and invest in supporting something that isn’t widely used, or not.

(a quick search found [c# - Why using multiple database in same instance a bad idea in Redis? - Stack Overflow](https://stackoverflow.com/questions/43244958/why-using-multiple-database-in-same-instance-a-bad-idea-in-redis) which links to a couple of discussions, but I have read it in many places)

---

<div class="post-metadata">

**Author:** ![borpin](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/borpin/32/193_2.png) [@borpin](https://community.openenergymonitor.org/u/borpin)\
**Post date:** [26 February 2019 20:51 UTC](https://community.openenergymonitor.org/t/implications-of-multiple-redis-db-support-on-emoncms-components/10245/4 "2019-02-26T20:51:35Z")

</div>

> [@Emoncms V9.9.7+ Release](https://community.openenergymonitor.org/t/emoncms-v9-9-7-release/10240/5):
>
> Perhaps a decision needs to be made as to whether emoncms really needs to support multi-db’s and invest in supporting something that isn’t widely used, or not.

Unless it creates work supporting it (I suspect this might only be used when the connection is created - don’t know) I’d be inclined to leave it be now and simply put a comment that says “don’t touch these settings unless you really know what you are doing” plus some comments on the impact to service-runner for those that need to change them.

---

<div class="post-metadata">

**Author:** ![TrystanLea](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/trystanlea/32/31_2.png) [@TrystanLea](https://community.openenergymonitor.org/u/TrystanLea)\
**Post date:** [26 February 2019 22:27 UTC](https://community.openenergymonitor.org/t/implications-of-multiple-redis-db-support-on-emoncms-components/10245/5 "2019-02-26T22:27:14Z")

</div>

Good points re dbnum, the changes to support this where very small ([redis: support db selection via dbnum config · emoncms/emoncms@67a36a2 · GitHub](https://github.com/emoncms/emoncms/commit/67a36a28891adcb8c4784512d03fc9c27fb8dc38)) and I thought if its useful for particular users then why not - but your right, it has knock on effects if there is assumed support in other emoncms components.

We could remove dbnum from default.settings.php but keep the check in index.php for advanced users keen to use this/using this already.

Happy to add notes for both the prefix and dbnum in the default settings file

---

<div class="post-metadata">

**Author:** ![Greebo](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/greebo/32/4556_2.png) [@Greebo](https://community.openenergymonitor.org/u/Greebo)\
**Post date:** [26 February 2019 22:29 UTC](https://community.openenergymonitor.org/t/implications-of-multiple-redis-db-support-on-emoncms-components/10245/6 "2019-02-26T22:29:56Z")

</div>

> [@Emoncms V9.9.7+ Release](https://community.openenergymonitor.org/t/emoncms-v9-9-7-release/10240/7):
>
> Happy to add notes for both the prefix and dbnum in the default settings file

I think that should cover it - as long as people know the consequences (and can see those documented at the point where they’re making the change) there seems little actual risk in leaving it available.
