R
Railway•10mo ago
sostenesapollo

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