#How close is my Redis & Application when deployed on Railway?
120 messages · Page 1 of 1 (latest)
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 want
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
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
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
#1176342343826280540 message
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?
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
show code please
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
// Documentation: https://www.npmjs.com/package/ioredis
import Redis from 'ioredis';
if (!process.env.REDIS_PRIVATE_URL) {
throw new Error('REDIS_PRIVATE_URL not found');
}
const redisURL = new URL(process.env.REDIS_PRIVATE_URL);
export const redis = new Redis({
family: 0,
host: redisURL.hostname,
port: parseInt(redisURL.port),
username: redisURL.username,
password: redisURL.password,
});
do a sanity check variable print?
though maybe buns url parser doesn't wanna parse a url with a redis scheme
uncommon bun L
hmmm
i think i know why
i didn't have private networking enabled

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 malformed

both 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
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
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
dont know how well it will work with the private networking though, but im always here to help


