Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about lambda workers doing local operations #42

Open
adrianmiu opened this issue May 26, 2021 · 4 comments
Open

Question about lambda workers doing local operations #42

adrianmiu opened this issue May 26, 2021 · 4 comments

Comments

@adrianmiu
Copy link

Hello,

I'm wondering what would be the best approach to the following scenario:

  1. There are "retrieve data" jobs are dispatched to make requests to external APIs. The worker retrieves the data, stores it in a file (json/xml), dispatches "process data" jobs and marks the request as being retrieved. There are 10s of thounthands of external requests to be made and I have a table to store the status for each one (pending/queued/retrieved/processed) so that I don't push the same request to the queue multiple times.
  2. The "process data" jobs parses the file, extracts the required data and performs some MySql queries (delete/update/create) to insert the processed data into the database

I have a VPS for the site and Mysql and I want to offload the retrieval and processing to AWS Lambda but I don't think the lambda can perform the database queries. What are my options here? The best I could come up so far is this using webhooks:

  1. Have a webhook to notify that the data was retrieved for a particular request
  2. Store the results of the processing in a S3 bucket and notify the site about the location of the file
  3. Have the main site perform the required queries to import the data

Are there better options?

Thank you.

@deleugpn
Copy link
Member

Why can't the lambda perform the database queries?

@adrianmiu
Copy link
Author

adrianmiu commented May 26, 2021

@deleugpn

The lambda function operates in a different environment so it cannot access the website (right?), unless I open the mysql instance to the world which I don't want to do. The VPS is a regular whm/cpanel instance

@bkuhl
Copy link

bkuhl commented Jun 13, 2021

If you want to use Lambda, you'll need to either open mysql to the world, or a specific ip range in which lambda operates. Otherwise move your database to AWS. This is a networking item though, not an issue with this package so this can be closed.

@deleugpn
Copy link
Member

deleugpn commented Mar 9, 2022

@adrianmiu You can opt to deploy your AWS Lambda inside a VPC with a NAT Instance or a NAT Gateway. In both cases, the public IP will be static (and predefined by the NAT). You can then add the predefined IP to your Database allow-list so that Lambda can successfully connect to your database. NAT Gateway does add $25/month cost (per AZ). NAT Instance is cheaper but you have to manage it yourself.

mnapoli pushed a commit that referenced this issue Mar 10, 2023
* Support Laravel 10

* monolog 3

* Support both monolog v2 and v3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants