r/aws • • Aug 07 '20

serverless AWS Lambda now supports EFS. Practice hands-on with this exercise.

http://aws-dojo.com/excercises/excercise7

[removed] — view removed post

77 Upvotes

53 comments sorted by

5

u/admiralsj Aug 07 '20

Interesting but in what situation would you use EFS over S3?

16

u/aws-dojo Aug 07 '20

EFS is block storage and S3 is object storage (accessed via http/rest call). Due to this, EFS will give you better performance over S3. The same EFS can be mounted on more than one Lambda functions to create shared data storage between Lambda functions to orchestrate with the data in efficient and performing way.

2

u/ScaryNullPointer Aug 07 '20

The performance of EFS is terrible for many smaller files. E.g. we've switched from EFS to S3 with cached map tiles generated and served by a cluster of around 100 EC2s of a relatively large GIS solution. EFS was not up to the task and we observed multi-second response times from EFS and micro-second from S3. We did have to partition S3 though (AWS did that for us) to overcome the 5000 req/s quotas.

1

u/aws-dojo Aug 07 '20

I echo. EFS might not be good option for small files. However, if you have a large file and multiple Lambda functions are operating on it - then mounting EFS across these Lambda function would give better performance over S3.

1

u/doobiedog Aug 07 '20

If someone could figure out how to get on-demand jenkins running in lambda that would be crazy. I imagine it'd be possible with EFS. Maybe that doesn't even make sense to do... but curious none-the-less.

1

u/Pawda Aug 08 '20

Nothing prevents you from triggering fargate instances that runs Jenkins on demands

1

u/tornadoRadar Aug 07 '20

partition as in using prefixes in a better way for your data usage?

2

u/ScaryNullPointer Aug 08 '20

Yup, prefixes. Except AWS specifically assigned the partitions to prefix structure on our request. We've been using a 3rd party tool which generated paths in a specific way and S3 could not properly figure out the partitions, so we created a support case for AWS to set things up for us and they did.

1

u/tornadoRadar Aug 08 '20

Got it. Glad there wasn’t some magic I was missing

11

u/Laoracc Aug 07 '20

EFS is block file storage and S3 is object storage

File storage, attached over cifs or nfs. Block would be over fiber or iscsi.

1

u/a1b3rt Aug 07 '20

any pointers on how much the performance actually differs ... to warrant the additional complexity for use cases that need that performance

is this a technical limitation that will always give better performance on block storage ...or is there a chance S3 improvements could in future make this difference neglible

1

u/aws-dojo Aug 07 '20

Generally block storage will give better performance over http/api. how much? hard to predict because I don't think there is any official benchmark. if you want to make decision based on data point - then take file big enough to match your requirement, copy to S3 and EFS and access from Lambda to benchmark the performance.

12

u/moofox Aug 07 '20

If you have a choice, choose S3 every time. EFS exists for when you don’t have a choice.

7

u/max0r Aug 07 '20

there are scenarios where you might need "local file-system" semantics. S3's eventual consistency can be an issue (at least in theory) for certain use cases.

1

u/humannumber1 Aug 07 '20 edited Aug 08 '20

I didn't think eventual consistently with S3 was a thing anymore. Looking it up there does appear to be one corner case, but I suspect it wouldn't be an issue for most. You may know this, but for others wondering if eventually consistently will be an issue for them.

Amazon S3 provides read-after-write consistency for PUTS of new objects in your S3 bucket in all Regions with one caveat. The caveat is that if you make a HEAD or GET request to a key name before the object is created, then create the object shortly after that, a subsequent GET might not return the object due to eventual consistency.

https://docs.aws.amazon.com/AmazonS3/latest/dev/Introduction.html#ConsistencyModel

EDIT: it was pointed out that the link above also states:

Amazon S3 offers eventual consistency for overwrite PUTS and DELETES in all Regions.

So yes a consideration for existing objects.

1

u/max0r Aug 07 '20

I've noticed it with overwrites of existing objects as opposed to puts of new objects.

1

u/humannumber1 Aug 08 '20

And you are very correct. The next line in the link above states:

> Amazon S3 offers eventual consistency for overwrite PUTS and DELETES in all Regions.

I did not know that and wish I would have read just one more sentence.

I'll update my previous post as well.

1

u/[deleted] Aug 07 '20

EFS also gives you more control over bandwidth accessible to you.

2

u/doobiedog Aug 07 '20

I've had a use case where I needed to do a git clone on a massive monorepo to perform actions within that repo but couldn't because local storage on Lambda is too small. S3 won't help here. EFS will. I'm sure there are other use cases.

1

u/trnka Aug 07 '20

You could use it as a simple workaround for big Python packages.

For files that would fit in RAM but not on the scratch space, it'd be nice for that too. I'm thinking of some machine learning models that are about that size.

It's probably better to just go the Docker route for either of those cases though.

21

u/mjs2020 Aug 07 '20

When AWS announced this I got excited and wanted to use it at work and got burned because I did not realise until after doing a fair amount of work that having the lambda run inside the VPC (in order to mount the EFS fs) meant losing access to other AWS endpoints such as SNS, SQS, Cloudwatch which I needed for that lambda. There are options to get access to these (NAT and interface enponts) but can add significant cost and effort if you don't already use them. This is a good overview https://www.alexdebrie.com/posts/aws-lambda-vpc/

Might have been obvious to others but I missed it so thought I'd share to prevent anyone else coming late to that realisation.

17

u/Some_IT_dude Aug 07 '20

The endpoints you mentioned are available as VPC endpoints so that solves that problem very quickly.

5

u/[deleted] Aug 07 '20

[removed] — view removed comment

6

u/smk081 Aug 07 '20

I belive the Gateway variety endpoints (S3 and Dynamo) are free.

5

u/jonathantn Aug 07 '20

The TCO in my mind is

Cost/Hr + Cost/GB = VPC Endpoint
Cost/GB = NAT

Assuming the hourly cost of NAT is a sunk cost and it's in the VPC already. So the break even point for a VPC endpoint on bandwidth is 206 GB of data through the endpoint vs the NAT gateway.

S3 and DynamoDB gateways are free and everyone should always use those. VPC endpoints once the traffic is at that level.

2

u/Some_IT_dude Aug 07 '20

They're like a penny an hour.

3

u/houz Aug 08 '20

Per endpoint, per AZ. It can add up, depending on how your environment is structured.

5

u/shotgunsparkle Aug 07 '20

You can segregate the lambdas that has access to EFS and your other things and orchestrate it using stepfunctions. Add vpc to the lambda that uses EFS and do whatever on the rest

-2

u/chaospatterns Aug 07 '20 edited Aug 08 '20

That sounds like you're adding more architectural complexity to workaround limitations in AWS and you'd be better suited to just use a solution where you can have it in a single component, for example a AWS Fargate scheduled task. This would give the same benefits of Lambda where you don't manage OS patching.

Serverless should reduce cognitive complexity not add to it.

2

u/--algo Aug 07 '20

Significant cost im not so sure of. It's $35 / month

5

u/mjs2020 Aug 07 '20

We're a small org and running stuff in 5 or 6 regions. Our preference would have been interface endpoints but they are $22/service/region/month. With two services we needed access to it would have meant more that $200/month on our bill for using those services, for us it's significant. NAT would have been cheaper but we handn't really anticipated messing with our VPC when we got excited about using EFS+Lambda so we thought we were going for a quick win. We (and by we I really mean I) misjudged and that's on us.

11

u/[deleted] Aug 07 '20

Not sure if you know this or not but you can make a NAT EC2 instance and use its network interface in the place of a NAT gateway which is significantly cheaper and still offers up to 1gbps local transfer speed.

So you could have private subnets and then bridge them to your public subnet via route tables.

We are a smallish agency and use this with great success and rely on EFS extensively for internal block storage.

2

u/Timnolet Aug 07 '20

Same here. Small company, we run in every region. This would balloon our cost

1

u/[deleted] Aug 07 '20

VPC endpoints exist for everything you've listed.

0

u/[deleted] Aug 07 '20

[deleted]

3

u/stephanemaarek Aug 07 '20

You can’t. The doc mentions that. Unfortunate limitation

0

u/[deleted] Aug 07 '20

[deleted]

1

u/indianapwns2 Aug 07 '20

the Lambda function in the example isn't trying to access anything outside the VPC, so in this example it doesn't matter.

2

u/indianapwns2 Aug 07 '20

AWS Lambda functions running in a VPC do not get public IPs assigned to them, even if you try running them in a public subnet, so this is not an option. You have to use a NAT to give them access to things outside the VPC.

1

u/tech_tuna Aug 07 '20

Yep, this is not a new problem. Still a pain.

2

u/serendipity7777 Aug 07 '20

Anyone has a benchmark of speed comparing this to EC2, or to an actual mounted hard drive ?

2

u/M1keSkydive Aug 07 '20

Significantly slower especially for accessing multiple files (eg listing directories or running a PHP website)

2

u/omeganon Aug 07 '20

I don't have benchmarks, but anecdotally, one of the Eng teams that I work with has an open support case related to this. They're trying to move some workloads that require high performance access to EFS from EC2 to Lambda (it's highly parallelize-able work). The word from them is EFS is significantly slower from Lambda than EC2.

1

u/serendipity7777 Aug 07 '20

Thanks, so It's not mature yet for i/o intensive workloads like geocoding

-6

u/ydio Aug 07 '20

2

u/aws-dojo Aug 07 '20

True - sorry - I am little slow :)

6

u/[deleted] Aug 07 '20

So it's true. It does support this right now.

Back off - the guy put together a tutorial to help folks out.

0

u/ydio Aug 07 '20

The lack of HTTPS and "kindly use the link to create free trial" should have been a dead giveaway that this would be low quality content.

-2

u/[deleted] Aug 07 '20

Why do you need https on a blog?

And the public link with no affiliate code attached to it?

Try harder. The guy is doing a good thing.

1

u/ydio Aug 07 '20

Why do you need https on a blog?

  1. Because my ISP doesn't need to know which article I'm reading on that site

  2. Because a MITM could inject malware

  3. Because it's 2020 and certificates are free

  4. Because every modern browser labels the website as "Not Secure" in the address bar

-1

u/[deleted] Aug 07 '20

So for you, not for him. Got it.

Don’t want to read his content because it doesn’t meet your standards? Move on.

0

u/ydio Aug 07 '20

So for you, not for him. Got it.

Perhaps you don't understand the affects of your domain being associated with malware because you refuse to properly secure it. It very much affects the website operator. Additionally, showing your visitors "Not Secure" doesn't do your website and its reputation any good. Lastly, Google penalizes websites that don't use HTTPS (which would be something that 100% affects the website, not me).

Try harder.

0

u/[deleted] Aug 07 '20

It’s a blog. He posted a link. I have no problem with it. Sorry you do.

Thanks, OP, for good content.