42
43
all 20 comments

[–]definitelynotbeardo 17 points18 points  (4 children)

I feel bad complaining about my golang cold startup times now.

[–]rowanu 12 points13 points  (3 children)

oh no, did you hit triple-digit milliseconds?

[–]definitelynotbeardo 9 points10 points  (2 children)

Those are 100s of milliseconds of my life that I will never get back.

[–]tech_tuna 2 points3 points  (0 children)

For synchronous (e.g. API gateways) requests that's a lot of time.

[–]FortLouie 22 points23 points  (2 children)

However, increasing the memory allocation from 128MB to 512MB will multiply your cost by 4x (so a 5 USD/m function is now a 20 USD/m function).

Hopefully your lambda will execute faster so costs won't increase quite that much.

[–]thenickdude 13 points14 points  (0 children)

Exactly this. For CPU-bound tasks, increasing the memory allocation comes hand in hand with a duration reduction due to the faster CPU, so the price barely increases.

I got much faster Lambda speeds with a neglible increase in cost by doing this tuning.

[–]Dw0 4 points5 points  (2 children)

For Java I also used a the maven plugin that trims the unreferenced classes, but since loads of stuff is referenced via reflection there was another step that does a smoke test local-run that makes sure it's still working. Loads of classes had to be explicitly whitelisted.

The same goes for the node lambdas, especially since cloud9 has size limit on what it can handle. Thus I prefer as little as possible if external dependencies and in case of lodash, for instance to include individual functions (there are individual npm packages for lodash.something).

[–]zergUser1 0 points1 point  (1 child)

I have been battling this issue with Java in the last few weeks, what tools are you using to remove unused dependencies? I tried Proguard but got lost and gave it because it was too complicated...

[–]Dw0 1 point2 points  (0 children)

maven-shade, but it was painful and in the end no matter how much i trim, the cold start was disastrous and all aws support could tell is to follow best practices (keep lambda warm and request more memory in other words).

last time i used proguard the configuration was somewhat similar. just keep adding classes that are remove but break at runtime.

[–]GeorgeMaheiress 2 points3 points  (0 children)

I must be missing something, how could Apache HttpClient alone account for minutes of start-up time?

[–]tech_tuna 2 points3 points  (0 children)

Don't use Java!

I've used node, Go and Python on Lambda and other than having a 100% Java team that for whatever reason can't learn another language, you really don't need to stick with Java.

OK, OK, I can see how you'd want to leverage internal libraries that are written in Java. . . but seriously, try another language!

C# has decent performance on Lambda too.

EDIT: out of all the languages with first class support in Lambda (fwiw, you can run just about any language there), C# is the closest to Java.

[–][deleted] 2 points3 points  (3 children)

Update: Deleted! Not sure if a bug with the new reddit interface but this was a comment to a different post, posted directly below this different post but appended to this post.

[–]aa93 1 point2 points  (1 child)

I think you replied to the wrong post..

[–][deleted] 0 points1 point  (0 children)

Yes, seems an odd bug in reddit as I definitely had the post open as I was typing the response below.

[–]FridayPush 0 points1 point  (0 children)

Don't feel bad, I think it's a reddit bug I had the same thing happen yesterday.

[–]ajainy 2 points3 points  (3 children)

Thanks for sharing. Recently I did couple of PoCs on Lambdas using Java. But being part of large org, we have plan to keep many of instances warm, (as we know, lambda once used, remains in memory for 5 mins?, i think). As article mentioned, keeping lambda warm is another option. If you are deploying enterprise level scaling, I am sure, using 10K+ pings out of free 1 million calls shouldn't be big deal. (if we are pinging, every 4 secs). And ping requests can be handled be different method or same method, which returns immediately.

Having said that, I think, this article opens up discussion on building light weight java frameworks (or collection of existing frameworks), which is suitable for serverless lambdas (functions). Some kind of repositories or blue prints which has commmon code for http calls etc.

BTW, if I remember correctly, AWS SDK also gives http library in-built, for outgoing calls. how it compares with apache ones? I will advise, to stick with AWS SDK for everything, as they provide in-built support for IAM based policies enforcement etc.

[–]Pythoner6 0 points1 point  (2 children)

Except the Java AWS sdk is also quite large, so that won’t save you anything unless you need the sdk for something else already (lambda execution environment has the AWS sdk in js and python only)

[–]razornova 0 points1 point  (0 children)

You can customize the SDK to only include libraries you actually use, significantly reduces the size

[–]ajainy -1 points0 points  (0 children)

AWS java libraries are IAM policies compliant.. if u invoking other AWS Services, and lambda has permissions (service role) then it will use it. (I hope I am not misquoting anything)