I currently have a web application working completely on Heroku.
This web application needs a lot of Power of calculation and access to several external APIs. for short periods of time, and nothing at all if there is no user activity.
So far, I have several workers who are inactive for a long time but who are not enough when there is a lot of activity. As a result, users must wait too much + I am paying money for workers who are inactive most of the time.
To solve this, I am thinking of moving these workers to AWS Lambda. As I am totally illiterate with AWS and with any type of server configuration in general, I am willing to keep the web and the database in Heroku.
Workers currently interact a lot with the database, both in reading and in writing. Therefore, I am considering two possibilities:
Make sure that the AWS Lambda workers connect directly to the SQL database in Heroku. Then they should be able to run
INSERT ...consultations -> Is that possible? I just found this page and it's on it, so I'm not sure it's easy enough to configure (maybe I'm not using the right keywords to find more information …)
Create some kind of API to make the communication between Heroku and Lambda, so that the real access to the SQL Database is done in Heroku, and the information to perform the SQL queries is what comes and goes.
Do any of these possibilities make sense?
Is there any other way to connect AWS Lambda and Heroku?
I am open to any other idea too.