Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Clarification][Compatibility]: MongoDB x FerretDB #8279

Open
leleobhz opened this issue Jul 29, 2024 · 6 comments
Open

[Clarification][Compatibility]: MongoDB x FerretDB #8279

leleobhz opened this issue Jul 29, 2024 · 6 comments

Comments

@leleobhz
Copy link

Nightscout formally only supports MongoDB. I bring up a testing instance using FerretDB (As their description, "FerretDB is an open-source proxy that translates MongoDB wire protocol queries to SQL, with PostgreSQL or SQLite as the database engine.") to test if NightScout behaves properly and until now - without much data it behaves normally.

That said, considering the FerretDB Differences from MongoDB, does FerretDB misses something Nightscout uses (Or plans to use)?

@psonnera
Copy link

From what I know Nightscout uses basic features of Mongo and Ferret translation most probably covers all that's needed. The issue I've seen with this is FerretDB requires another cloud service that results as an extra cost for most PaaS. If you run your own VPS, I'm not sure of the added value. It would for sure be obvious if we could find a free DB larger than Atlas. You did check this, right? https://github.com/3timeslazy/nightscout-ferretdb/tree/main/all-on-one

@leleobhz
Copy link
Author

leleobhz commented Aug 5, 2024

Hello @psonnera

The issue I've seen with this is FerretDB requires another cloud service that results as an extra cost for most PaaS.

FerretDB can be deployed to translate into SQLite for example. Thinking with heroku-like in mind indeed ddo not have much advantage, but for a single VPS as example, sqlite will be lighter than a MongoDB database (For coincidence this is more or less my case).

In fact, FerretDB may increase the database support, since adds SQLite, PostgreSQL and in future, MySQL support. If we can confirm any of FerretDB limitations is being used here, may Nightscout officially support it in future. For now, I just want check if something bad may happen with some specific register or condition.

Another suggestion is to add FerretDB to testing alongside with MongoDB testing.

@leleobhz
Copy link
Author

leleobhz commented Aug 5, 2024

You did check this, right? https://github.com/3timeslazy/nightscout-ferretdb/tree/main/all-on-one

I really disagree on s6 usage - all the more using docker-compose. My approach is just running ferretdb and nightscout in different services at same docker-compose - and it works very well. Aside, this avoid the lose of updates from both projects due to misleading with all-in-one container CI builds.

About Atlas, at least for me, heath data being inside my infrastructure - or being controlled by me at least - is a must to. Also, a setup with Nightscout + FerretDB + SQLite + Rpi + Zerotier (as example) would fit better than running MongoDB in such small device.

@leleobhz
Copy link
Author

leleobhz commented Aug 5, 2024

Just for reference, my docker-compose file:

services:
  ferretdb:
    image: ghcr.io/ferretdb/ferretdb:1
    restart: always
    labels:
      autoheal: "true"
    healthcheck:
      test: ["NONE"]
    environment:
      FERRETDB_HANDLER: "sqlite"
    volumes:
      - nightscout-ferretdb:/state
    networks:
      nightscout:
      
  nightscout:
    image: nightscout/cgm-remote-monitor:latest
    restart: always
    depends_on:
      - ferretdb
    labels:
      autoheal: "true"
    environment:
      ### Variables for the container
      NODE_ENV: "production"
      TZ: "America/Sao_Paulo"
      HOSTNAME: "::"
      PORT: "1337"
      INSECURE_USE_HTTP: 'true'
      MONGODB_URI: "mongodb://ferretdb:27017/nightscout"
      API_SECRET:  <API KEY HERE>
      ENABLE: "careportal rawbg iob sage dbsize"
      AUTH_DEFAULT_ROLES: "denied"
      DISPLAY_UNITS: "mg/dl"
      BASE_URL: "https://<URL HERE>"
      TIME_FORMAT: "24"
      # For all other settings, please refer to the Environment section of the README
      # https://github.com/nightscout/cgm-remote-monitor#environment
    networks:
      nightscout:
        aliases:
          - nightscout
      webservices:

  nightscout-libre-link:
    image: docker.io/timoschlueter/nightscout-librelink-up
    restart: always

    depends_on:
      - nightscout
    environment:
      LINK_UP_USERNAME: "<LIBREVIEW USER HERE"
      LINK_UP_PASSWORD: "<LIBREVIEW PASS HERE>"
      LINK_UP_TIME_INTERVAL: "1"
      LINK_UP_REGION: "<LIBREVIEW REGION HERE>"
      NIGHTSCOUT_URL: "nightscout"
      NIGHTSCOUT_API_TOKEN: "<NIGHTSCOUT API KEY HERE>"
      LOG_LEVEL: "info"
    networks:
      nightscout:


volumes:
  nightscout-ferretdb:

networks:
  webservices:
    name: webservices
    external: true

  nightscout:
    driver: bridge
    name: nightscout

@psonnera
Copy link

@leleobhz this is a very smart choice but I'm not sure it adds so much value over running an older Mongo version (I use 4.4 in my VPS with great satisfaction) but as I've been looking forever for free Mongo alternatives to Atlas (and the result of my search is exactly the opposite of free), having the possibility of finding other free Posgres/SQLite databases available would be fantastic. How would you modify this yml to have an external Postgres/SQLite database on a different server?

@leleobhz
Copy link
Author

@psonnera For use FerretDB with Postgres, just replace the POSTGRES_ variables in the environment - as in the example at https://docs.ferretdb.io/quickstart-guide/docker/#postgresql-setup-with-docker-compose - and add a postgres service if you need it.

About Old Mongo x Ferret, MongoDB have some requirements that may hit very small environments. MongoDB does not behave very well with slow storage (In any version for anything) - and since probably you VPS is a SSD ones, MongoDB works well. Also, In SoC like Rpi, MongoDB may suffer with low bandwidth bus and some CPU congestion for I/O. The scenario with RPI or even weaker SoCs may be better with FerretDB, allowing reducing price for on premisses/own hardware solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants