4 ms·
I would rather disagree with these practices. Some of them are subjective and some will likely be outdated soon. > Each function should do only one thing. The
by Agebor 8y ago
I would rather disagree with these practices. Some of them are subjective and some will likely be outdated soon.
> Each function should do only one thing. The problem with one/a few functions running your entire app, is that when you scale you end up scaling your entire application.
Sure, but is that a problem in general? Same thing can be said about a monolith vs microservices, and there is always a trade-off. A function with a larger code-base makes the code easier to navigate; may be easier to deploy. First reason about / compare cold-start times before making the decision to break the function.
> Functions don’t call other functions
Is the cost of calling the other function negligible (e.g. the functions are called rarely)? If yes, feel free to do it.
> Use as few libraries in your functions as possible (preferably zero)
Security risk is another discussion, not related to serverless. Worry instead about the cold-start time. If it's short enough for your use case - do use libraries. Should be no problem for Go, Node is usually OK. Java - native compilation is slowly approaching.
> Avoid using connection based services e.g. RDBMS
If adding another library is not a problem in your case, then why not? It's not too difficult to create a pool with a single connection. As for security, there are some new options like AWS Aurora IAM authentication. No VPC needed.
- tylerhou 8y ago> Functions don’t call other functions I think this point may might also be about reducing complexity, not just cost. Pushing to a queue instead of directly calling another function decouples the two functions and might make it easier to reason about how logic flows.
- Agebor 8y agoTrue, might make it easier in some cases. This is a general architecture decision, unrelated to serverless.
- k__ 8y ago>Is the cost of calling the other function negligible (e.g. the functions are called rarely)? If yes, feel free to do it. The question is more one of errors, I think. You pump your results in a queue before you let another function do the next step, if one function fails it's not the whole process that is lost. Step Functions, for example, lets you chain functions and does retries for you if one function failed.