a year ago
Hi, I have a doubt about Redis, Im using a Redis service for my API, both deployed here in Railway. Cache works fine right now for what im doing but theres an issue, its showing some serious (100 MB+ of outbound network) on a request with the cache, is that a bug?
222 Replies
And i just saw this: , does that mean im doing it wrong? Sorry im newbie with this stuff

a year ago
you should check the variables on your app's service, not the Redis service
a year ago
a year ago
look at the picture
a year ago
the picture in the docs page i sent
a year ago
^
im looking at it but i cant figure out, i mean what i understand is that some variables that are used in 2 places must be placed here, right
a year ago
no, you have no need for shared variables
wait when you say app service you mean like, my service-backend-project, right?
a year ago
yes
a year ago
send a link to the project please
a year ago
youre good, its using the private url
and REDIS URL seems a string I dont even remember where I got the value from, maybe it should be reference variable?
a year ago
it already is a reference variable
but yeah outbound is still like, big, it wasnt at some point god knows what happened not me xd
a year ago
i dont really see any outbound on redis
a year ago
thats not the redis service
wait can you see where it comes from? i got a login and user-settings but no way thats 130 mb
a year ago
no i cant
maybe my cache is just not working now? but it works locally, how could it not work same on railway? strange issue
but i cant flsh all on redis railway service, is there a way to flush all?
a year ago
again, you are connecting to redis via the private network, so there would be no measurable network
right, so all that data is 100% not redis then… mmm what could it even be idk
a year ago
its any outbound data leaving the private network, could be mongo, could be sending data to your frontend
a year ago
side question, where is the frontend service?
yeah its here, also having an issue with it where it crashes on a certain page when it tries to fetch some data: https://railway.app/project/e1a3daa8-0161-42a8-9945-2ddf4a33a66d
a year ago
why is it in a different project?
a year ago
via cli
a year ago
^
how can I make it so that it does like backend it auto updates on git commit? is possible? that must be the issue 99%
cause i did commit pushed and thought already frontend updated like backend but no
1st question: can i fix it where it is now then move it to the same project?
a year ago
delete it and deploy it into the correct project this time
if i rename project, does it affect anything in terms of functionality or its just name change?

just so instead of backend project ah i change it to project ah and put all the 3 services together: backend, frontend, and redis
a year ago
just a name change
so for the react thingy is there a way to make it like, automatically build from github repo everytime or i gotta do the cli setup every time?
a year ago
lets get the service into the correct project first
then i use this, right: https://docs.railway.app/guides/react
oh theres a one click template option, but i never used template before
a year ago
no, you already did that.
empty service -> name the service -> set variables -> deploy -> create domain -> attach github repo -> deploy
theres no variables in the frontend except the process.env.REDIS_URL I think being only exception. So for that I gotta use reference variable I believe
a year ago
the frontend does not need redis
a year ago
the frontend should need a backend api domain variable though
for now im just hardcoding the values but will change in future dont worry
a year ago
fixed
a year ago
id go with the big deploy button
it just sends me here: https://docs.railway.app/quick-start
a year ago
no it does not
a year ago
it seemed pretty noticeable to me lol
a year ago
continue with the steps i gave you
i been user of railway for few years but actively went back just like few days ago
it was this thing man, i can finally see my data again my stuff 🥹 nice!
lets see if it also fixes the outbound stuff, right? because now in theory it same project
okey so 1st request is this: 130mb, completely normal, data is not cached (i need to re-cache every hour btw its not a permanent cache)

so now i wait like 2 mins and reload the page again to re-fetch, in theory from cache and hopefully no more big outbound data like this 130 mb
a year ago
no it wont, to avoid outbound traffic you need to use the private network and you cant use the private network for client side rendered websites, or 3rd party services such as mongo
a year ago
if i recall correctly ive said that a few times
you probably did but i did not get it, im too slow with all these stuff im new to it and my mind if like close to explode plus im coding so much these days learning stuff too im like exhausted mentally tbh
so theres no absolute way to cache the 130 mb response for the frontend theres no trick or workaround? my app literally wont be profitable if I dont find a way to do that idk what to do 😦
a year ago
dont send 130mb worth of data to the frontend then
right…right, i just cant, it defeated my entire plan but theres no work around
a year ago
though im just going off that you are saying, id first figure out what this outbound traffic is
55 to 65 MB, no idea why it shows 130 MB, its like it fetching the data twice, but is not.
a year ago
figure out where this outbound traffic is going
a year ago
is your frontend actually downloading 130mb of data?
a year ago
we are not double counting outbound
else {
console.log("through the else");
const userDesiredItemsFromCache = await retrieveArrayFromRedis();
res.json({
items: userDesiredItemsFromCache,
update: {
nextMinute: timer.minute,
nextSecond: timer.second,
},
});}
a year ago
are you console logging 65mb worth of data?
a year ago
lets not do that
a year ago
no
theres an if below, but im going through the else on all cached (verified im going through it)
a year ago
find a way to not send 65 mb worth of data to the frontend
yeah thats something i need to do, but lets ignore this for a moment now and try to see why it takes 130 mb
im not doing a double operation there and im just fetching a timer from mongoDB thats an object with 3 fields
connectedRealms is not even a fetch but its an object with like 100 fields, neither can be that
a year ago
dont really know what to tell you, i have no way of looking at your network traffic
well no worries I will have to change all of this somehow and hopefully that fixes that issue as well, who knows
Hi Brody, I got it way way lower now frontend response is about 2 MB, for some reason it will still shows 4 MB but i think thats fine.
So I want to try and calculate the cost of a user network usage based on this, you let me know if what i say makes sense
a year ago
scroll to the bottom -
So a user makes request of 4 MB to my app, he will lets say, do it on average around 4 times per hour, so 16 MB per hour. I expect the user to (at most, lets put higher case) use this app for 8 hours a day, 25 days a month. so thats 3200 MB, 3,2GB
just want to make sure I understand the thing with this simplified math I did for an estimate
a year ago
scroll to the bottom please
a year ago
switch to resource-based
a year ago
well you absolutely will not be using 0 cpu and 0 bytes of memory
a year ago
and that's only 1 users worth of networking
cause then I have some doubt, RAM for example, it takes around 400 MB of RAM per app load, but like they just load the app and then they can see all data they dont need to reload often just once every hour for user, for new data to come in because external API updates every 1 hour. so maybe they are using the app 1/3 of all the entire time of a day, so that would be 400 MB of RAM divided between 3, so 133 MB RAM average cost per user, does my example make sense?
a year ago
nope
a year ago
put in your average cpu and memory usage
a year ago
so put in the average and it will tell you the cost
so if user peaks 400 MB on app load doesnt matter because lets say he does 1 app load per month then average would be super low, like 10 MB or whatever
a year ago
I highly doubt your app could idle down to 10mb
a year ago
especially with replicas
a year ago
far more, it's node
idle is probably 300 MB, but per user maybe on average it adds 10 MB, is what I mean,based on my above example here
a year ago
then put that into the calculator
average is good because nobody uses app 24 hours, at most they will use 12 hours and 99% of people will use less
another question: lets imagine im hitting the 32 GB RAM limit, can I add 1 replica and then it scales about 64 GB of RAM? (I know its not exactly like that in theory, but in practice, in a very simplified way of putting it, its basically double hardware power, right?)
a year ago
it's still 32gb of ram per instance, just now that you have two running the total combined can be 64gb
a year ago
then yes, but that may be subject to change
so theorical limit is crazy high because if I have 1 service + the 49 replicas available is 1600 GB of RAM
a year ago
exactly, and what's why I say it's subject to change, that's far too much resources for a single user
but its good to know the limit, i think i will never find limit in this platform which is possitive to hear 😄















