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
Project ID:
N/A
N/A
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-variablesGotcha, 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?
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
gotcha I'll play around with it
thanks!
no problem