I’m trying to create a website where the user enters a few numbers, these numbers are fed into some equations, and the output of these equations is emailed to the user. I’m using Python 2.7 for everything. I’m using a cheap Amazon instance (m1.small, Ubuntu 12.04) to host the frontend, but I only want to launch a backend instance when needed (the computations are heavy and require a powerful – and expensive – instance). I can use boto to programmatically launch a backend instance, but after that how do I feed the user input into the backend? Everything is simple enough when I’m doing things manually, with SFTP and SSH, but what’s the programmatic way to do it? Should I simply execute SFTP and SSH from my Python script (using, say, ‘os.system’)? Somehow that feels wrong; how do people actually do it?
In case it matters, this is not for a commercial website. I’m in grad school and I want my committee members to be able to replicate and tweak my research, which is stats-heavy. Also, I have no security concerns – it’s just academic research, I’m not storing any kind of personal info or anything.
1
Perhaps SQS (Amazon Simple Queue Service) could help you. The principle idea is that the frontend would publish a message on the queue and promptly forget about it. The backend service, upon waking up would consume messages from the queue until there is no more work to do, and then go to sleep. There are good apis for many languages, and it is generally pretty cheap at low volume.
If time is not critical you could even start and stop the backend processor as a scheduled task.
With this method you could even start up multiple instances of the back end processor, and not worry that they are duplicating work.
2