Can you assign custom environment variables to Horizontally scaled instances?

I have setup Horizontal Scaling via replicas. I was wondering if it was possible to assign a custom environment variable to each replica? Thanks!
7 Replies
Percy
Percy2y ago
Project ID: N/A
Plinpod
PlinpodOP2y ago
N/A
Brody
Brody2y ago
you can't assign your own variables to specific replicas, but there is RAILWAY_REPLICA_ID that has a unique Id specific to that replica https://docs.railway.app/develop/variables#railway-provided-variables
Plinpod
PlinpodOP2y ago
Gotcha, so I need to change my DATABASE info for each instance because I'm setting up sharding. In that case I would likely need to use the Cloudflare LB approach?
Brody
Brody2y ago
I'm sure there's a way you could do it with railways replicas some type of broker that hands out database credentials, but only once, so on each request to the broker you get different database credentials provide the broker with 5 sets of database credentials, query the broker 5 times (once from each of the 5 replicas) and each will get their own separate database credentials there's probably a multitude of ways to go about this, but that's just what first popped into my mind have this broker also only be on the internal private network of course
Plinpod
PlinpodOP2y ago
gotcha I'll play around with it thanks!
Brody
Brody2y ago
no problem
Want results from more Discord servers?
Add your server