How close is my Redis & Application when deployed on Railway?
Would it be two pods on the same machine? Two pods in a magic EKS cluster in the same region?
I'm trying to gain a better mental model of it all. One thing I know is accessing Redis (in my same project) should be faster than access a Neon DB in the same geographic region but not guranteed to be on the same datacenter.
67 Replies
Project ID:
N/A
N/A
I did some digging in the docs and couldn't really find any information about that, it's possible I missed it though
since you're on pro plan you can directly email railway and ask for that information ( via
[email protected]
from the email you use on railway ) if you wantoh dope
ty
no problem :)
two services given that they are both set to the same region will absolutely be in the same data center, but are not guaranteed to be on the same host due to how railway packs compute, but either way, all services within the same project and environment will be part of a wireguard tunnel making service to service communication faster then connecting to an external database elsewhere, provided you connect over the private network
ahh! so I should prefer to use private networking over everything else for inter-service communication
when I set up my redis instance, and had it connect to my app with shared variables is that url (proxy.rlwy.net) a private network one?
on the docs it shows "railway.internal" being the private net
absolutely, there's no networking fees and less hops on the private network
OH wait I'm currently using the TCP proxy right
rlwy.net is the public one
railway.internal is the private one
gotcha
so new goal acquired: convert redis to private network rather than tcp proxy
just connect to the private network using the correct variable instead
use the private url reference variable
i see
so rather than REDISHOST
i just do REDIS_PRIVATE_URL?
nope, a url isn't the same as a host, this is what I'd do, it's for bullmq but bullmq uses the exact same connection object type
https://discord.com/channels/713503345364697088/1176342343826280540/1176379472228909087
ohhh interesting
so you parse the URL
I'm surpised there isn't a native URL option
oh wait
there totally is
doesn't seem to work
oh it doesn't?
when I tried it will bullmq, it didnt
is bullmq ontop of redis?
yes, uses the same types
on top of ioredis*
just pushed, will try the single url and then the url extraction
TIL I was leaving the datacenter and then coming back via TCP proxy
do you have that variable referenced on your service?
I do
referenced and not just copy pasted lol
yeah, I used the reference variable UI
show code please
oh
wait
haha
i changed the variable on prod
but my code is on
you'll have that
oh, it won't work anyway, you need family 0 since ioredis assumes ipv4 by default and the private network is ipv6 only
family 0?
have a look at the example code here, same connection object
bullmq just passes it to ioredis, so you can use it all the same
do a sanity check variable print?
though maybe buns url parser doesn't wanna parse a url with a redis scheme
yeah the url logs
but doesn't get parsed
uncommon bun L
hmmm
i think i know why
i didn't have private networking enabled
<:stare_hmm:869304431093620776>
i think it works now?
i'm a little confused about the logs though
oh nevermind
i think it works
hype
turns out you need to enable it
or else the URL is services need private networking enabled right?
ah yeah that makes a lot of sense
even though the private networking enable and disable is in a services settings, it's a global option for the project
are these settings able to be stored in railway.toml at all?
would be nice to do this through code
nope this setting isn't available in a config file
but it's enabled by default, so not sure why it was even off
i think i had turned it off at some point
didn't understand what it was
fair enough lol
are you using the private network to connect to postgres? (i think you mentioned at some point you use postgres too)
my postgres currently lives in NeonDB (same region & datacenter I believe) but I'm heavily considering moving it to railway for latency gains
and egress reduction
true
my main thing was scaling
I would like minimal setup max autoscale
neon kind of just lets me do that on the right with the slider there
also handles connection pooling from my serverless functions on vercel
youre on pro so you get a max of 32vcpu and 32gb of ram
👀
does it dynamically scale up to that?
it just what you could use at any time, if postgres only needs 1gb, then its only gonna use 1gb, if postgres needs 28gb, then it will be able to use 28gb
aka vertical scaling
gotcha
what about connection pooling?
if I have 100 serverless functions trying to access it at once that's needed right?
you can deploy PgBouncer
oh nice is that just built into postgres?
no its a template on the marketplace
nice
need to read up on that some more
https://railway.app/template/L09YMd
dont know how well it will work with the private networking though, but im always here to help
well so I'd need to be able to access it via private networking and public
since my Bun application can use private, but Vercel functions need public
thats true
dont see why you cant use both
alrighty
time to read up and implement 😤
goal for tonight:
- implement pgbouncer & move postgres to railway
- setup Infisical for secret management (i dunno how nicely it'll play for variable references )
saw that thread, i unfortunately cant answer it, never used it myself