I currently have a web app running fully on Heroku.
This web app needs a lot of computing power and access to several external APIs during short time periods, and nothing at all if there is no activity from users.
Until now, I have several workers that are idle during a long time but are not sufficient when there is a lot of activity. As a result, the users need to wait too long + I am paying money for workers that are most of the time idle.
In order to solve this, I am thinking about moving these workers to AWS Lambda. Since I am totally illiterate with AWS and any kind of server configuration in general, I am willing to keep the web itself and the database on Heroku.
The workers currently interact a lot with the database, both reading, and writing. Therefore, I am considering two possibilities:
Make that the workers in AWS Lambda connect directly to the SQL Database on Heroku. Then they should be able to run
INSERT ...queries --> Is that possible? I only found this page and this one about it, so I am not sure if it will be easy enough to set-up (maybe I am not using the right keywords to find more information...?)
Create some sort of API to do the communication between Heroku and Lambda, so the actual access to the SQL Database happens on Heroku, and the information to perform the SQL queries is what goes back and forth.
Do any of these possibilities make sense? Is there any other way to connect AWS Lambda and Heroku?
I am open to any other ideas as well.