Highly changing environment variables shouldn't be made constant #1223
Replies: 2 comments 3 replies
-
@xoldyckk @palisadoes @DMills27 Please provide your feedback over this. |
Beta Was this translation helpful? Give feedback.
-
@anshgoyalevil I've never heard anything about dynamically loading and injecting environment variables inside a running server. This is a fairly common problem and it's simply solved by having a function run at server boot time to check for existence of these environment variables which are critical at runtime. It's not only limited to environment variables, you also test whether the 3rd party services you're using are actually reachable during server boot, because you can simply provide a dummy environement variable to escape the environment variables function check. If any of the required environment variables are not provided or the services are not reachable the server boot up fails. |
Beta Was this translation helpful? Give feedback.
-
We are relying on the Constants such as
RECAPTCHA_SECRET_KEY
,MAIL_USERNAME
, MAIL_PASSWORD```, etc. inside the Talawa API.When we start the node server, all of the constants are loaded from the environment variables.
What's the problem here?
This is because even if there exists mail variables now but the server loads the value
undefined
in place of mail variables initially. You would have to stop and start the node server again.This could seem like an easy task if we look at it inside local machine, but when we scale it to production, this will result in the server downtime.
An admin may want to change the environment variable while the server is running. This couldn't be achieved since all environment variables are loaded during the initial server boot, and a typical cloud or vps server takes about 5-10 minutes to restart the node process. This may also result in data loss if the storage system is non persistent.
Also, most cloud or vps providers offer a 99.99 SLA (~ 4 minutes in a year) which will become useless in such a case.
What can be the solution?
Provide your suggestions on what could be the possible solution or, if we should stick to the current talawa api constants system only.
Beta Was this translation helpful? Give feedback.
All reactions