Questions regading pricing, how to reduce costs

hello I have a app that runs with postgres, redis, and a single instance running, the last month bill was $ 42 and it's already estimated to $ 76 is that correct ? what Im missing ?
No description
Solution:
update those two url variables with the values shown below
DATABASE_URL=${{Postgres.DATABASE_PRIVATE_URL}}
REDIS_URL=${{Redis.REDIS_PRIVATE_URL}}
DATABASE_URL=${{Postgres.DATABASE_PRIVATE_URL}}
REDIS_URL=${{Redis.REDIS_PRIVATE_URL}}
...
Jump to solution
154 Replies
Percy
Percy•9mo ago
Project ID: N/A
Brody
Brody•9mo ago
are you connecting to postgres and redis via the private network? if not, you are subjecting yourself to unnecessary egress fees
sostenesapollo
sostenesapollo•9mo ago
hello not sure
Brody
Brody•9mo ago
hello!
sostenesapollo
sostenesapollo•9mo ago
probabbly via network let me check it
Brody
Brody•9mo ago
what variables are you using when connecting to your two databases?
sostenesapollo
sostenesapollo•9mo ago
yeah Im using the external url :HAHAHA: how to switch ?
Brody
Brody•9mo ago
both postgres and redis have private url variants, using those to connect to the database will eliminate all database <--> service egress fees
sostenesapollo
sostenesapollo•9mo ago
got it how to change ?
sostenesapollo
sostenesapollo•9mo ago
No description
sostenesapollo
sostenesapollo•9mo ago
I think I must set like this, right ?
Brody
Brody•9mo ago
that is using the public network to connect to the databases
sostenesapollo
sostenesapollo•9mo ago
sh**t that's the reason additional $18
Brody
Brody•9mo ago
what two environment variables does your code use to connect to the two databases?
sostenesapollo
sostenesapollo•9mo ago
Database_url and redis_url
Brody
Brody•9mo ago
and would you happen to be using ioredis?
sostenesapollo
sostenesapollo•9mo ago
I don't know what is ioredis
Brody
Brody•9mo ago
then it seems you aren't using it 😆
sostenesapollo
sostenesapollo•9mo ago
what is the difference ?
sostenesapollo
sostenesapollo•9mo ago
No description
sostenesapollo
sostenesapollo•9mo ago
I'm connecting like this
Brody
Brody•9mo ago
it's a client library for redis, just needed to know for the next steps, one minute I'll get you the new references you want to use
sostenesapollo
sostenesapollo•9mo ago
ok, but what it changes ? exactly
sostenesapollo
sostenesapollo•9mo ago
it crashed my app
No description
sostenesapollo
sostenesapollo•9mo ago
:blob_help:
Solution
Brody
Brody•9mo ago
update those two url variables with the values shown below
DATABASE_URL=${{Postgres.DATABASE_PRIVATE_URL}}
REDIS_URL=${{Redis.REDIS_PRIVATE_URL}}
DATABASE_URL=${{Postgres.DATABASE_PRIVATE_URL}}
REDIS_URL=${{Redis.REDIS_PRIVATE_URL}}
sostenesapollo
sostenesapollo•9mo ago
No description
Brody
Brody•9mo ago
what did you change??
sostenesapollo
sostenesapollo•9mo ago
the database_url and redis_url only
Brody
Brody•9mo ago
slow down please, use the variable I have provided
sostenesapollo
sostenesapollo•9mo ago
ok
Brody
Brody•9mo ago
once done changing the variables, please resend an updated version of this screenshot
sostenesapollo
sostenesapollo•9mo ago
ok There was one thing I also added in the previous postgres url that is the max connections as I'm using prisma, and some times I got the max connections reached
Brody
Brody•9mo ago
well that's easy enough to add later on
sostenesapollo
sostenesapollo•9mo ago
ok, I'm waiting the build
Brody
Brody•9mo ago
^
sostenesapollo
sostenesapollo•9mo ago
No description
Brody
Brody•9mo ago
looks good to me
sostenesapollo
sostenesapollo•9mo ago
No description
Brody
Brody•9mo ago
is this bun?
sostenesapollo
sostenesapollo•9mo ago
remix not bun
Brody
Brody•9mo ago
remix with node?
sostenesapollo
sostenesapollo•9mo ago
node yes
Brody
Brody•9mo ago
do any of those error logs have attributes, hover over the log line and look for a plus icon on the far left of the log line
sostenesapollo
sostenesapollo•9mo ago
No description
Brody
Brody•9mo ago
well those aren't very helpful errors to say the least at what point in your applications lifecycle do you open thr connection to the two databases? right on startup?
sostenesapollo
sostenesapollo•9mo ago
No description
sostenesapollo
sostenesapollo•9mo ago
No description
sostenesapollo
sostenesapollo•9mo ago
so in the file I use prisma just import it
Brody
Brody•9mo ago
right but that doesn't quite answer my question
sostenesapollo
sostenesapollo•9mo ago
I can't say this exactly Brody
Brody
Brody•9mo ago
please try to answer my question
sostenesapollo
sostenesapollo•9mo ago
inside my root file, I import this db.server that inside of it has the getClient() that handles the client.$connect();
Brody
Brody•9mo ago
I'm sorry but that doesn't quite answer my question
sostenesapollo
sostenesapollo•9mo ago
What kind of answer do you need ? in the startup I open my connections
Brody
Brody•9mo ago
are you sure about that?
sostenesapollo
sostenesapollo•9mo ago
yes
Brody
Brody•9mo ago
what's your current start script
sostenesapollo
sostenesapollo•9mo ago
I got the error
Brody
Brody•9mo ago
that doesn't quite answer the question
sostenesapollo
sostenesapollo•9mo ago
this
sostenesapollo
sostenesapollo•9mo ago
No description
sostenesapollo
sostenesapollo•9mo ago
Uses the default database but mine has a different name
Brody
Brody•9mo ago
^
sostenesapollo
sostenesapollo•9mo ago
"start": "cross-env NODE_ENV=production node ./build/server.js",
Brody
Brody•9mo ago
what is the name of your postgres database?
sostenesapollo
sostenesapollo•9mo ago
pedegas
Brody
Brody•9mo ago
then update that name in the variable
sostenesapollo
sostenesapollo•9mo ago
postgresql://${{PGUSER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_PRIVATE_DOMAIN}}:5432/pedegas I should set something like this, right ?
Brody
Brody•9mo ago
hold on, send a screenshot of your railway project first please
sostenesapollo
sostenesapollo•9mo ago
No description
sostenesapollo
sostenesapollo•9mo ago
b19b2751-44b4-49a2-b64d-0be0ed08b0b8
Brody
Brody•9mo ago
but you aren't using the default database name of railway (where your tables are located) correct?
sostenesapollo
sostenesapollo•9mo ago
No description
Brody
Brody•9mo ago
please do your best to answer my questions, I seem to be asking my questions a few times each time I ask a question
sostenesapollo
sostenesapollo•9mo ago
I'm using the default database name
Brody
Brody•9mo ago
is that what your code has always used? the default database name?
sostenesapollo
sostenesapollo•9mo ago
no. that's different
Brody
Brody•9mo ago
what database name where you using before
sostenesapollo
sostenesapollo•9mo ago
railway
Brody
Brody•9mo ago
may I ask why you said no? it becomes increasingly harder for me to help with incorrect information
sostenesapollo
sostenesapollo•9mo ago
sorry for that
Brody
Brody•9mo ago
set your start script to this please
sleep 3 && cross-env NODE_ENV=production node ./build/server.js
sleep 3 && cross-env NODE_ENV=production node ./build/server.js
sostenesapollo
sostenesapollo•9mo ago
ok Hello @Brody I did that I solved the issue of the database connection
Brody
Brody•9mo ago
why delete?
sostenesapollo
sostenesapollo•9mo ago
just redacting Now I think I will not have more billings for egress as both redis and postgres are using the private network
Brody
Brody•9mo ago
did you modify the database url on the postgres service?
sostenesapollo
sostenesapollo•9mo ago
yes
Brody
Brody•9mo ago
why?
sostenesapollo
sostenesapollo•9mo ago
as it is my default database
Brody
Brody•9mo ago
what did you change the private url to?
sostenesapollo
sostenesapollo•9mo ago
My application Database url
Brody
Brody•9mo ago
you should be using these
sostenesapollo
sostenesapollo•9mo ago
yes That's the same DATABASE_URL=postgresql://${{Postgres.PGUSER}}:${{Postgres.POSTGRES_PASSWORD}}@${{Postgres.RAILWAY_PRIVATE_DOMAIN}}:5432/${{Postgres.PGDATABASE}}?connection_limit=10&pgBouncer=true
sostenesapollo
sostenesapollo•9mo ago
No description
sostenesapollo
sostenesapollo•9mo ago
And now it works
Brody
Brody•9mo ago
why did you write out the entire url instead of using ${{Postgres.DATABASE_PRIVATE_URL}}?
sostenesapollo
sostenesapollo•9mo ago
bcs I need the other params after the ?
Brody
Brody•9mo ago
${{Postgres.DATABASE_PRIVATE_URL}}?params=here
sostenesapollo
sostenesapollo•9mo ago
I tried this not worked I can try it again
Brody
Brody•9mo ago
it would work why set pgbouncer to true? you arent using pgbouncer
sostenesapollo
sostenesapollo•9mo ago
I don't know I just set this a lot of time ago to don't reach the max connections And I did not get it anymore so I just kept
Brody
Brody•9mo ago
fair enough
sostenesapollo
sostenesapollo•9mo ago
HEY I still have a question @Brody regarding the ioredis will it make any difference for me ?
Brody
Brody•9mo ago
you can still ask questions, im just marking the solution to the initial question no, its just another redis client
sostenesapollo
sostenesapollo•9mo ago
ah ok It worked !
Brody
Brody•9mo ago
awsome
sostenesapollo
sostenesapollo•9mo ago
ty have a nice day
Brody
Brody•9mo ago
no problem! you too!
sostenesapollo
sostenesapollo•9mo ago
@Brody and if I have another project that uses the same database I checked that another one also was using an external database_url Is that possible to still share the private database url ?
Brody
Brody•9mo ago
you have a service in another project that is connecting to the database in this project?
sostenesapollo
sostenesapollo•9mo ago
yes
Brody
Brody•9mo ago
then no, the private network is scoped to the project and environment that they are located in, you would want to bring that service into the project that has the database (please dont close threads)
sostenesapollo
sostenesapollo•9mo ago
I see @Brody I moved the project for the same that the db is located but now it can't connect to the db
sostenesapollo
sostenesapollo•9mo ago
No description
Brody
Brody•9mo ago
screenshot of project please
sostenesapollo
sostenesapollo•9mo ago
No description
Brody
Brody•9mo ago
have you added the 3 second sleep to the start command?
sostenesapollo
sostenesapollo•9mo ago
no let met add
sostenesapollo
sostenesapollo•9mo ago
No description
sostenesapollo
sostenesapollo•9mo ago
Still error
Brody
Brody•9mo ago
please use these
sostenesapollo
sostenesapollo•9mo ago
fixed. thanks again
Brody
Brody•9mo ago
no problem!
sostenesapollo
sostenesapollo•9mo ago
@Brody I really don't know what is happending
sostenesapollo
sostenesapollo•9mo ago
No description
sostenesapollo
sostenesapollo•9mo ago
when I updated the estimated bill decreased to $ 22.33
sostenesapollo
sostenesapollo•9mo ago
now it is $ 47.08
No description
Brody
Brody•9mo ago
its down from 80 so thats good
sostenesapollo
sostenesapollo•9mo ago
no lol I was paying under 30
Brody
Brody•9mo ago
open the project cost and view billing by service
sostenesapollo
sostenesapollo•9mo ago
No description
No description
Brody
Brody•9mo ago
well you did add another service to the project
sostenesapollo
sostenesapollo•9mo ago
yes
Brody
Brody•9mo ago
did you remove the service from the old project?
sostenesapollo
sostenesapollo•9mo ago
yes
Brody
Brody•9mo ago
go and look into each services metrics
sostenesapollo
sostenesapollo•9mo ago
No description
sostenesapollo
sostenesapollo•9mo ago
No description
sostenesapollo
sostenesapollo•9mo ago
No description
sostenesapollo
sostenesapollo•9mo ago
this last one is a cron, just runs once in the day
Brody
Brody•9mo ago
you would be charged egress for the backup data you send away to wherever you store
sostenesapollo
sostenesapollo•9mo ago
would that cost that much ? just 29 mb zip file
Brody
Brody•9mo ago
no, just letting you know
sostenesapollo
sostenesapollo•9mo ago
ok the thing is, last year I was paying a lot less that was just update the db and this happened
Brody
Brody•9mo ago
last year railway didnt charge as much for egress
sostenesapollo
sostenesapollo•9mo ago
I see
sostenesapollo
sostenesapollo•9mo ago
look
No description
sostenesapollo
sostenesapollo•9mo ago
from 19 to 42 😓 under 25 would be great for me
Brody
Brody•9mo ago
yeah looks normal, they used to waive 100% of egress, then 50% and now 0%
sostenesapollo
sostenesapollo•9mo ago
hmm, let's see so, next month
Brody
Brody•9mo ago
is the backup service using the private url too?
sostenesapollo
sostenesapollo•9mo ago
actually I notticed that it's oscilating
No description
sostenesapollo
sostenesapollo•9mo ago
now, yes.
Want results from more Discord servers?
Add your server