Hey, I’m trying to determine if I can leverage horizontal scaling for my Discord.js bot hosted on render. To do this I believe the straightforward approach would be to know if code was running on render instance 0, 1, 2,… N. I found the RENDER_INSTANCE_ID env variable, but I’m not sure how to translate that into a “index” to indicate which render instance the code is running in.
For more context about discordjs/why I’m looking for this info:
The tricky part about discordjs is that only one instance of the bot can be active at a time per server. This is improved with sharding which they provide a useful API for, but it does not support a load balancing approach like a web app.
HOWEVER - the code must manually tell the shard manager which shards to run on the current instance. This would be fairly straightforward if I had a simple number to indicate which render instance the code was currently running on, I could basically take shard count / render instance count and then increment by the instance index, and voila each instance would manage it’s set of shards.
Thanks in advance for any help!