1

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:

  1. Make that the workers in AWS Lambda connect directly to the SQL Database on Heroku. Then they should be able to run SELECT ... and 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...?)

  2. 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.

J0ANMM
  • 131
  • 5
  • This could be helpful to some: https://mattwelke.com/2019/01/06/free-tier-managed-sql-with-aws-lambda-and-heroku-postgres.html – J0ANMM May 30 '19 at 11:23

1 Answers1

0

I ran into an issue or am currently running into one still, with respect to Lambda.

Basically, Lambda starts to have problems with losing connections when the work it is doing is longer and especially if it is maintaining connections to services. I am not sure if this is limited to services outside AWS or not. In my case, my services being called by Lambda are outside AWS and Lambda is not able to do what I can do with the same JS script, external to Lambda, which suggests I am mis-using Lambda.

It is possible that you might have the same problem where your Lambda's are trying to do work on Heroku and will possibly timeout. But this is my hypothesis so far. As in, don't use Lambda until you make sure of this.

Neeraj Murarka
  • 343
  • 2
  • 9