How to replicate 3 MongoDB instances for read, write, reporting then access it from an app?

hi all, please help, i want to replicate 3 mongodb.

  • primary for write access
  • secondary for read access
  • analytics for reporting query

testing access from hrm-test-app .

please help why i can’t use the internal network access?

I did a MongoDB setup over a weekend project several billion years ago:

Hope this can help with some ideas!

sorry asking, in your version use 1 apps isn’t it? and use 1 ip,right? is the performance good for production?

1 Like

Yeah a single app for simplicity sake. Iirc one ip too.

As for performance: I was more focused on “how to” than actually using by I’ve been working with Fly.io Postgres for a while and we just use fly machines too so I say it’s good for production and I wouldn’t see any reason why mongo would not be like that. That being said I don’t know much about mongodb internals!

My one tip for production grade would be to use performance machines whenever possible. Also make sure to look into machine memory usage, that will depend on your app and how it’s using mongo so that’s trial and error

I second @lubien’s advice, we ran a MongoDB cluster based off his mongo template for a while without issues. Just ensure that your machines are properly sized WRT your load / throughput / queries. Depending on your needs, you can set the readPreference option in your code to ensure the replicas are taking their share of the load.

1 Like

How have you configured your Mongo instances to replicate? Please show the relevant changes you made to the configuration files. You may need to read the docs on Fly networking to understand the naming conventions of the different network types.

1 Like

i want use the hrm-mongodb-primary.internal, hrm-mongodb-secondary.internal,etc instead of used .fly.dev domain.

Remove any IPv4 and IPv6 and then you’re only left with .internal from custom DNS.

You might also want to checkout flycast:

It comes with many benefits over using .internal and we use it a lot in our platform for services such as managed postgres.

Great stuff. What problem are you having specifically? It may be necessary to go into detail. Show your config here if it would help readers understand what isn’t working.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.