Live data from Hacker News

Serverless dev practices questions

news.ycombinator.com

21–30 of 30 posts

Re: Serverless dev practices questions

#21
This stuff is hard and we're all still figuring it out. Just recently we realized we built a monolith because we weren't paying enough attention to whether all the features should be a part of a single system. We're going to revisit that.

Don't look at your function as an app, it's an function and the best functions do a single thing. The definition of a single thing depends on the scale of view you're taking. But that may help you to realize your functions shouldn't be very complex and possibly small enough to test more easily.

However, that results in increased system complexity as you start adding SNS topics, SQS queues, DynamoDB tables, and all sorts of event triggers. Something I've adopted is using draw.io (others use Lucid Chart) to draw out the system logic. Maybe this helps?

https://www.draw.io/ https://www.lucidchart.com/

Maybe this makes the confusion worse?

Re: Serverless dev practices questions

#22
post #4

AWS Lambda is a very small interface. I'm only getting started, but I'm planning to keep all my application code in a separate project with no Lambda dependencies, test that as I would any application, and then have a thin wrapper that just wraps each endpoint in the Lambda interface. This would also maintain as loose as possible coupling to the Lambda ecosystem, making porting easy -- I'm in Java-land, so that proba…

Have you thought about the added execution time from JVM startup? A project I had dropped in my lap awhile ago was figuring out a way to speed up a java lambda function. Basically we decided the only way was to try and make the lambda container always hot. A cloudwatch event would trigger the lambda function every 5 minutes to make sure it was always hot.

Re: Serverless dev practices questions

#23
post #4

AWS Lambda is a very small interface. I'm only getting started, but I'm planning to keep all my application code in a separate project with no Lambda dependencies, test that as I would any application, and then have a thin wrapper that just wraps each endpoint in the Lambda interface. This would also maintain as loose as possible coupling to the Lambda ecosystem, making porting easy -- I'm in Java-land, so that proba…

Have you thought about the added execution time from JVM startup? A project I had dropped in my lap awhile ago was figuring out a way to speed up a java lambda function. Basically we decided the only way was to try and make the lambda container always hot. A cloudwatch event would trigger the lambda function every 5 minutes to make sure it was always hot.

For now, my project isn't very sensitive to taking a couple-of-seconds warm-up hit. But I'm aware of the issue, and it seems that keeping your classpath lean works wonders. I'll be investigating further, but my tentative plan is to section the endpoints by their dependency-size. The majority of the enduser-latency-sensitive endpoints will need little more than a JDBC connector.

Re: Serverless dev practices questions

#24

We use AWS Lambda exclusively on the product I am currently working on (3 peoples team). - We use the Serverless framework - Monorepo with multiple (micro) services - Each service exposes Lambda for particular functions (e.g. Articles service exposes GetArticle, CreateArticle, etc..) - No business logic is being shared between services, only libraries - Three environments, Dev, Stage, Production (and every developer…

What do you use to store articles? DynamoDB? If so, are you ok with querying and searching data? What about security? How do you implement it?

Re: Serverless dev practices questions

#26

Earlier quoted context omitted.

> seriously consider using Cognito for your user management. Can you please expand on that recommendation? I tried and found it profoundly opaque, and eventually gave up in favour of auth0. I specifically wanted to use the hosted login/sign-up forms.

I found this tutorial had some very good information on incorporating Cognito into an app: https://aws.amazon.com/blogs/aws/build-your-first-serverless... It lays out the architecture fairly well and how Cognito ties into it. Still very fiddly, and doesn't give any indication on how to use their hosted forms (which are a bit of a mystery to me as well). Since it's still on point with the OP's question, I'll ask: What…

We recently managed to implement Cognito User Pools with hosted pages, the details are on the StackOverflow page[0].

[0]: https://stackoverflow.com/questions/45828654/aws-cognito-use...

Re: Serverless dev practices questions

#28

We use AWS Lambda exclusively on the product I am currently working on (3 peoples team). - We use the Serverless framework - Monorepo with multiple (micro) services - Each service exposes Lambda for particular functions (e.g. Articles service exposes GetArticle, CreateArticle, etc..) - No business logic is being shared between services, only libraries - Three environments, Dev, Stage, Production (and every developer…

What do you use to store articles? DynamoDB? If so, are you ok with querying and searching data? What about security? How do you implement it?

DynamoDB for storing only. After an article is stored in DynamoDB and stream will index it into an ES Service. Then we are quering and searching only ES. DynamoDB can't handle searching very good.

Security wise, everything is private except one Lambda that exposes a GraphQL server and is being forwarded to the public net through API Gateway. We will implement subnets and security groups very soon.

Re: Serverless dev practices questions

#29
We are using microrepos, we implement all logic in libraries then import those libs into another project that wraps it w/ the lambda logic. The lambda logic tends to be small and all the 'work' is done in libraries. Thought here being if we need to migrate to another serverless solution (or server solution) it's quick/easy to wrap the tested libraries in whatever the next logic should be.

Then we use Apigee a127 Node project to invoke the lambda's. This is where authentication is done (we use Auth0 JWT/Bearer tokens). The Apigee a127 project invokes the lambda and handles routing. We looked at serverless but didn't want to use API Gateway since we already had apigee. We plan to look at SAM next but so far haven't need it. We have a few grunt scripts that we can use for running the lambda locally so far not a big deal.

For logging we use an AWS ElasticSearch cluster and Kibana.

So far we haven't run into any big issues with lambda, we see better response times when there is a constant load on the system, I guess that helps w/ keeping the lambda's warm. Even cold start isn't a big issue b/c the $$$ saved is well worth it.

Automate EVERYTHING. You will quickly get a bunch of lambda's and you need a way to keep them all updated, manual SUCKS.

Re: Serverless dev practices questions

#30

Earlier quoted context omitted.

What do you use to store articles? DynamoDB? If so, are you ok with querying and searching data? What about security? How do you implement it?

DynamoDB for storing only. After an article is stored in DynamoDB and stream will index it into an ES Service. Then we are quering and searching only ES. DynamoDB can't handle searching very good. Security wise, everything is private except one Lambda that exposes a GraphQL server and is being forwarded to the public net through API Gateway. We will implement subnets and security groups very soon.

With ES do you mean ElasticSearch from AWS? This is interesting, can you tell me something more please?
Post reply on HN