Reputation: 21
Is AWS Lambda good solution for next use case:
Multi-tenancy web application is hosted on AWS (EC2). Dynamic / custom datasets can be defined by user through application and data is being stored in MongoDB. There is a need for a notification system which will allow users to define rules: on some event (entity creation / update; attribute update) script function will be executed. In the script a condition over given entity is checked and email notification is sent, if condition is satisfied.
One possible solution is that scripts are stored as Lambda functions, since it look relatively easy to implement, but I am not sure is this good solution. Potentially there can be thousands of Lambda functions. Are there some limitations on maximum number of functions? I am afraid of separating user-defined functions from my own ones, and also mixing all the different tenants function in one place (since Lambda does not have some tree structure for defined functions). Also accidental change or deleting a user-defined function is possible…
Or to go with some embeded scripting?
Any opinion from AWS experts, please…
Upvotes: 0
Views: 364
Reputation: 323
IMHO, its best to avoid getting into situations, where in you have to accept code from outside (no control over input) of the system to run within your system. You are going to get too many calls from customers who want you to dev-test their poorly written scripts.
I have owned products that allow users to describe their schema for custom data sets that they'd like to import. The product integrates with known datasources, and transforms them to an internal schema. Additionally the product allows customers to import data from custom sources, and conditions to be described on attributes from such custom sources.
Have you considered modelling the conditional expressions (which your currently want evaluated through user defined scripts) within your product, and implement a back-end evaluation engine that evaluates the conditions on the relevant trigger? Depending on the outcome you, can trigger post actions (send notification email on your case). This should suffice for most scenarios.
Even if you absolutely must support some custom scripting in some rare scenario, Lambda is an inefficient choice. Its an overkill to create an execution environment for each script that you have to execute. You would have no control over your environment, if the no of scripts spiral out of control. Hosting a script execution environment would be the way to go.
Upvotes: 0
Reputation: 200860
It's hard to recommend anything without knowing more details about the data schema and the types of rules that would trigger an update, but can you store the rules in the database instead of hard coding them in user scripts? Then you could just have a single script that takes the updated data and checks if there are any rules that would result in a notification from the updated data.
Upvotes: 1