Here is how it works:
1. User contacts the bot 2. Configures how he wants to run the script. 3. User asks the bot to start it.
What happens when the user starts it is that I create a new thread running the script. The script involves listening from updates from another API so I thought running it as a thread would be a good choice.
Now what happens is that some users tell me that the script stops working after a while. Perhaps the thread gets killed by the OS after a while?
I am trying to understand what is a good architecture for such an application.
Right now, there are 10 people who use the bot so it handles it effectively. What if I run it on EC2 instances with load balancing enabled?
Another way I was thinking of making it work is like this: 1. Running the bot on a separate EC 2 instance 2. Running a web server on another instance with load balancing. 3. Now when a user asks the bot to run it, the bot calls the web server and runs a new process/thread there.
I wonder what would be the implications when load balancing comes into the picture.
Another question: thread vs new process. Different processes did not work properly the last time I tested so I want to know whether it is my mistake or running a different process IS a wrong way of doing it.
If you need to just keep polling, I'd recommend using a managed background task service like SWF on AWS or Cloud Tasks on GCP. Not worth the trouble of debugging to build it yourself these days