Network Egress - MongoDB Atlas
Hi there! I have a MERN app and I have set up my DB in mongoDB Atlas, I started to see egress cost are going high $25 so far for this month. My average payments in previous months were around $4 (Hobby waived plan)
My question is, how could I reduce this cost? Would I need to set up a mongoDB database in railway itself to avoid these costs?
22 Replies
Project ID:
32d3d99f-a53d-4484-8c73-dbb077d6b557
32d3d99f-a53d-4484-8c73-dbb077d6b557
If mongo is the only thing you're sending data to, then moving the mongodb to railway can remove those egress costs if you take advantage of the internal network. Of course, you'll have to compare that with the cost of hosting the db, so it could also end up costing more. You should take a look at railways pricing and compare it to the current operating cost
And, it must also be possible to use the private network. If users are communicating to the database directly over internet (for whatever reason) then the egress costs will increase, which will only worsen the situation
For this internal network, Would I need to create a DB as a new project?
No, it needs to be a service within the same project. If it is in a different project, there wont be a private network connection to rely on
If I have multiple environments within a project. Could I create it as new env? Or I'd need to have one service for each env?
I'm not sure, i dont really use the environment feature. I'll see if i can find it in the docs
It looks like if you create a new environment for this, it will automatically add the service to all environments. I believe you're looking for the "Fork environment" feature, where that doesn't happen, and your changes are easily discarded
Oh nevermind! I read it wrong!
Your changes will apply to all environments regardless:
At this moment only changes in environment variables can be merged, but we are working on adding support for any other changes made to a service or plugin.
a little extra clarification, the private networks are per environment within a single project
So to be clear, I would need one mongoDB service per environment?
environments are identical is most ways, you create a database in the production environment and one will be created in all other environments automatically, though you are responsible for cloning the data across the multiple databases
There's one thing I'm not clear about. If I connect my app to my MongoDB database using MONGO_PRIVATE_URL variable and the data gets saved there. How can I access or check this data? I was trying to do that by using MONGO_URL variable in Mongo Compass but I don't see the data created
make sure you are connecting to the same database within mongo
Hello! I'm wondering the same thing. I have deployed my railway service in us-east4 – and I created a dedicated MongoDB cluster on GCP us-east4. Would the data transfer between Mongo and my railway service would count as external egress?
Yes
Is there any work around for that?
(I do not want to manage MongoDB myself for the production env, and I want to use Atlas – but the services query a lot of data from mongo and the egress bill would be massive if it's not handling thought a private network)
connect to the database with its
MONGO_PRIVATE_URL
variable, there is zero egress fees for traffic flowing across the private networkthe workaround is to host the db through Railway yourself unfortunately
they don’t want to host the db themself, they want to use Atlas
oh shit my bad
what adam said
Damn, but is the MongoDB railway database option production ready? (I doubt)
might be worth giving this a read? https://docs.railway.app/maturity/use-cases