Issue with Redis Outbound

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?
138 Replies
Percy
Percyā€¢2w ago
Project ID: N/A
PrivateScript
PrivateScriptOPā€¢2w ago
N/A N/A because im not sure which id to show, the backend id, or redis id?
PrivateScript
PrivateScriptOPā€¢2w ago
And i just saw this: , does that mean im doing it wrong? Sorry im newbie with this stuff
No description
Brody
Brodyā€¢2w ago
you should check the variables on your app's service, not the Redis service
PrivateScript
PrivateScriptOPā€¢2w ago
oh, okey, im going to check that now
PrivateScript
PrivateScriptOPā€¢2w ago
mm I dont see any:
No description
PrivateScript
PrivateScriptOPā€¢2w ago
not sure if im doing it right
PrivateScript
PrivateScriptOPā€¢2w ago
im confused right now I read that but im kinda same, im a noob at this
Brody
Brodyā€¢2w ago
look at the picture
PrivateScript
PrivateScriptOPā€¢2w ago
the picture i sent?
Brody
Brodyā€¢2w ago
the picture in the docs page i sent
PrivateScript
PrivateScriptOPā€¢2w ago
ah okey
PrivateScript
PrivateScriptOPā€¢2w ago
No description
Brody
Brodyā€¢2w ago
^
PrivateScript
PrivateScriptOPā€¢2w 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 right
Brody
Brodyā€¢2w ago
no, you have no need for shared variables
PrivateScript
PrivateScriptOPā€¢2w ago
but this worked before for me at some point which is even more strange ah right thats why it worked, cause they not needed then
PrivateScript
PrivateScriptOPā€¢2w ago
No description
PrivateScript
PrivateScriptOPā€¢2w ago
No description
PrivateScript
PrivateScriptOPā€¢2w ago
I got these envs right now on my 2 services wait when you say app service you mean like, my service-backend-project, right?
Brody
Brodyā€¢2w ago
yes send a link to the project please
PrivateScript
PrivateScriptOPā€¢2w ago
here in my code i reference this
No description
PrivateScript
PrivateScriptOPā€¢2w ago
yes
PrivateScript
PrivateScriptOPā€¢2w ago
Railway
Railway
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
Brody
Brodyā€¢2w ago
youre good, its using the private url
PrivateScript
PrivateScriptOPā€¢2w ago
and REDIS URL seems a string I dont even remember where I got the value from, maybe it should be reference variable? aah okey so im good there
Brody
Brodyā€¢2w ago
it already is a reference variable
PrivateScript
PrivateScriptOPā€¢2w ago
okey āœ… so thats ok but yeah outbound is still like, big, it wasnt at some point god knows what happened not me xd
Brody
Brodyā€¢2w ago
i dont really see any outbound on redis
PrivateScript
PrivateScriptOPā€¢2w ago
No description
PrivateScript
PrivateScriptOPā€¢2w ago
No description
Brody
Brodyā€¢2w ago
thats not the redis service
PrivateScript
PrivateScriptOPā€¢2w ago
cause im just basically getting the data from redis on cache in theory ah wait can you see where it comes from? i got a login and user-settings but no way thats 130 mb
Brody
Brodyā€¢2w ago
no i cant
PrivateScript
PrivateScriptOPā€¢2w ago
maybe my cache is just not working now? but it works locally, how could it not work same on railway? strange issue i think maybe i messed up railway redis because locally i always do redis flush all but i cant flsh all on redis railway service, is there a way to flush all? maybe old data is caussing some issue idk
Brody
Brodyā€¢2w ago
again, you are connecting to redis via the private network, so there would be no measurable network
PrivateScript
PrivateScriptOPā€¢2w ago
right, so all that data is 100% not redis then... mmm what could it even be idk
Brody
Brodyā€¢2w ago
its any outbound data leaving the private network, could be mongo, could be sending data to your frontend side question, where is the frontend service?
PrivateScript
PrivateScriptOPā€¢2w ago
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
Railway
Railway
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
Brody
Brodyā€¢2w ago
why is it in a different project?
PrivateScript
PrivateScriptOPā€¢2w ago
wait what? i just see theres no repo connected to it, wtf
No description
PrivateScript
PrivateScriptOPā€¢2w ago
cause i had to create new project when i was setting it up or maybe its mistake and should been a service? but how is it no repo connected ah wait right because i uploaded with the weird react method OOH
Brody
Brodyā€¢2w ago
via cli
PrivateScript
PrivateScriptOPā€¢2w ago
then its not updating like backend f0ck
Brody
Brodyā€¢2w ago
^
PrivateScript
PrivateScriptOPā€¢2w ago
funk right hold on hold on 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 thats gotta be the issue 1st question: can i fix it where it is now then move it to the same project?
Brody
Brodyā€¢2w ago
delete it and deploy it into the correct project this time
PrivateScript
PrivateScriptOPā€¢2w ago
ah okey, lets do that
PrivateScript
PrivateScriptOPā€¢2w ago
if i rename project, does it affect anything in terms of functionality or its just name change?
No description
PrivateScript
PrivateScriptOPā€¢2w ago
just so instead of backend project ah i change it to project ah and put all the 3 services together: backend, frontend, and redis
Brody
Brodyā€¢2w ago
just a name change
PrivateScript
PrivateScriptOPā€¢2w ago
okey i changed that name now 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?
Brody
Brodyā€¢2w ago
lets get the service into the correct project first
PrivateScript
PrivateScriptOPā€¢2w ago
yeah ima delete the frontend project 1 sec done right, so first of all i create an empty service
PrivateScript
PrivateScriptOPā€¢2w ago
Railway Docs
Deploy a React App | Railway Docs
Documentation for Railway
PrivateScript
PrivateScriptOPā€¢2w ago
oh theres a one click template option, but i never used template before
PrivateScript
PrivateScriptOPā€¢2w ago
No description
Brody
Brodyā€¢2w ago
no, you already did that. empty service -> name the service -> set variables -> deploy -> create domain -> attach github repo -> deploy
PrivateScript
PrivateScriptOPā€¢2w ago
ah, okey 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
Brody
Brodyā€¢2w ago
the frontend does not need redis
PrivateScript
PrivateScriptOPā€¢2w ago
No description
PrivateScript
PrivateScriptOPā€¢2w ago
ah right you are right
Brody
Brodyā€¢2w ago
the frontend should need a backend api domain variable though
PrivateScript
PrivateScriptOPā€¢2w ago
for now im just hardcoding the values but will change in future dont worry okey so i cant see the domaint hingy yeah i cant see it in settings
Brody
Brodyā€¢2w ago
fixed
PrivateScript
PrivateScriptOPā€¢2w ago
ah deploy okey
PrivateScript
PrivateScriptOPā€¢2w ago
shows me this
No description
PrivateScript
PrivateScriptOPā€¢2w ago
i click there to make a deployment yes? idk
Brody
Brodyā€¢2w ago
id go with the big deploy button
PrivateScript
PrivateScriptOPā€¢2w ago
oke
PrivateScript
PrivateScriptOPā€¢2w ago
Railway Docs
Quick Start Tutorial | Railway Docs
Documentation for Railway
Brody
Brodyā€¢2w ago
no it does not
PrivateScript
PrivateScriptOPā€¢2w ago
wait ah no the purple button you meant right the deploy one, wasnt looking at it
PrivateScript
PrivateScriptOPā€¢2w ago
No description
PrivateScript
PrivateScriptOPā€¢2w ago
it shows me this now
Brody
Brodyā€¢2w ago
it seemed pretty noticeable to me lol
PrivateScript
PrivateScriptOPā€¢2w ago
sorry im not used to the interface yet i miss on obvious stuff
Brody
Brodyā€¢2w ago
continue with the steps i gave you
PrivateScript
PrivateScriptOPā€¢2w ago
i been user of railway for few years but actively went back just like few days ago okey okey i created domain, next is attach github repo and next deploy, okey okey its doing stuff its loading YEEES GOOD JOB! 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
PrivateScript
PrivateScriptOPā€¢2w ago
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)
No description
PrivateScript
PrivateScriptOPā€¢2w ago
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
Brody
Brodyā€¢2w 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
PrivateScript
PrivateScriptOPā€¢2w ago
wait... šŸ˜¢
Brody
Brodyā€¢2w ago
if i recall correctly ive said that a few times
PrivateScript
PrivateScriptOPā€¢2w ago
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 šŸ˜¦ and i spent months on it omg idk
Brody
Brodyā€¢2w ago
dont send 130mb worth of data to the frontend then
PrivateScript
PrivateScriptOPā€¢2w ago
right...right, i just cant, it defeated my entire plan but theres no work around
Brody
Brodyā€¢2w ago
though im just going off that you are saying, id first figure out what this outbound traffic is
PrivateScript
PrivateScriptOPā€¢2w ago
must think of something ah yeah its the 120k items, but its weird because the size is about 65 MB 55 to 65 MB, no idea why it shows 130 MB, its like it fetching the data twice, but is not.
Brody
Brodyā€¢2w ago
figure out where this outbound traffic is going
PrivateScript
PrivateScriptOPā€¢2w ago
ima try
Brody
Brodyā€¢2w ago
is your frontend actually downloading 130mb of data?
PrivateScript
PrivateScriptOPā€¢2w ago
only 65
PrivateScript
PrivateScriptOPā€¢2w ago
No description
PrivateScript
PrivateScriptOPā€¢2w ago
cant be a coincidence than 130 mb is twice 65
Brody
Brodyā€¢2w ago
we are not double counting outbound
PrivateScript
PrivateScriptOPā€¢2w ago
else { console.log("through the else"); const userDesiredItemsFromCache = await retrieveArrayFromRedis(); res.json({ items: userDesiredItemsFromCache, update: { nextMinute: timer.minute, nextSecond: timer.second, }, }); } thats my cache code maybe retrieveArray is doing it twice idk need to see that
PrivateScript
PrivateScriptOPā€¢2w ago
doesnt seem like
No description
Brody
Brodyā€¢2w ago
are you console logging 65mb worth of data?
PrivateScript
PrivateScriptOPā€¢2w ago
yeah
Brody
Brodyā€¢2w ago
lets not do that
PrivateScript
PrivateScriptOPā€¢2w ago
that could be the issue maybe?
Brody
Brodyā€¢2w ago
no
PrivateScript
PrivateScriptOPā€¢2w ago
ah yeah i removed the console.logs
PrivateScript
PrivateScriptOPā€¢2w ago
rest of code on the cached version are these:
No description
PrivateScript
PrivateScriptOPā€¢2w ago
theres an if below, but im going through the else on all cached (verified im going through it)
Brody
Brodyā€¢2w ago
find a way to not send 65 mb worth of data to the frontend
PrivateScript
PrivateScriptOPā€¢2w ago
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
Brody
Brodyā€¢2w ago
dont really know what to tell you, i have no way of looking at your network traffic
PrivateScript
PrivateScriptOPā€¢2w ago
and getHighestTime returns about 300 KB ah right well no worries I will have to change all of this somehow and hopefully that fixes that issue as well, who knows but yeah brb dinner 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
Brody
Brodyā€¢2w ago
scroll to the bottom - https://railway.app/pricing
PrivateScript
PrivateScriptOPā€¢2w ago
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 so that should be 0.32$ network usage does this make sense? yeah I know pricing its 0.1$ per 1 GB of network egress just want to make sure I understand the thing with this simplified math I did for an estimate ooh
Brody
Brodyā€¢2w ago
scroll to the bottom please
PrivateScript
PrivateScriptOPā€¢2w ago
I can make example there, nice okey I do example there thanks āœ…
Brody
Brodyā€¢2w ago
switch to resource-based
PrivateScript
PrivateScriptOPā€¢2w ago
yes
PrivateScript
PrivateScriptOPā€¢2w ago
āœ…
No description
Brody
Brodyā€¢2w ago
well you absolutely will not be using 0 cpu and 0 bytes of memory and that's only 1 users worth of networking
PrivateScript
PrivateScriptOPā€¢2w ago
oh yeah yeah i meant just to calculate the network of 1 user, yes 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?
Brody
Brodyā€¢2w ago
nope
PrivateScript
PrivateScriptOPā€¢2w ago
oh, how do i calculate it then
Brody
Brodyā€¢2w ago
put in your average cpu and memory usage
PrivateScript
PrivateScriptOPā€¢2w ago
right its what i mean, the average it is the cost for RAM and CPU
Brody
Brodyā€¢2w ago
so put in the average and it will tell you the cost
PrivateScript
PrivateScriptOPā€¢2w ago
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 right
Brody
Brodyā€¢2w ago
I highly doubt your app could idle down to 10mb especially with replicas
PrivateScript
PrivateScriptOPā€¢2w ago
you think even less, or more?
Brody
Brodyā€¢2w ago
far more, it's node
PrivateScript
PrivateScriptOPā€¢2w ago
ah no no, forget the app, it will have a base RAM cost but im thinking the added RAM usage per user right now 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
Brody
Brodyā€¢2w ago
then put that into the calculator
PrivateScript
PrivateScriptOPā€¢2w ago
average is good because nobody uses app 24 hours, at most they will use 12 hours and 99% of people will use less yeah 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?) and another replica for 96 GB of RAM, etc etc...
Brody
Brodyā€¢2w ago
it's still 32gb of ram per instance, just now that you have two running the total combined can be 64gb
PrivateScript
PrivateScriptOPā€¢2w ago
yeah its what i mean, the total combined
Brody
Brodyā€¢2w ago
then yes, but that may be subject to change
PrivateScript
PrivateScriptOPā€¢2w ago
so theorical limit is crazy high because if I have 1 service + the 49 replicas available is 1600 GB of RAM but dont worry cause my bank account is little and i will have little server im not rich xd
Brody
Brodyā€¢2w ago
exactly, and what's why I say it's subject to change, that's far too much resources for a single user
PrivateScript
PrivateScriptOPā€¢2w ago
but its good to know the limit, i think i will never find limit in this platform which is possitive to hear šŸ˜„ yeah it really is lol
Want results from more Discord servers?
Add your server