question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve build performance of NodejsFunction on Mac (@aws-cdk/aws-lambda-nodejs package)

See original GitHub issue

Using volumes in Docker on Mac specifically is a huge pain point due to performance issues. CPU often spikes to above 100% utilization when there is heavy read or write operations inside the container (as it happens with the parcel-builder Docker container that the CDK construct NodejsFunction uses internally.

This has been very well documented in https://docs.docker.com/docker-for-mac/osxfs-caching/ and the workarounds are also described.

I suggest we force Docker volume mounts within this construct to start using Docker volume in “delegated” mode, to improve build performance (speed) on Mac based deployment environments.

I think a good starting point is: https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-lambda-nodejs/lib/builder.ts#L118

Use Case

Developing and deploying CDK stacks with many lambdas on a Mac machine.

Proposed Solution

Replace -v sourcevolume:targetvolume with -v sourcevolume:targetvolume:delegated

Other

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
moltarcommented, Jun 16, 2020

Is there a reason why it runs inside a Docker container anyways? Seems to be a bit heavy handed. I think there should be an option to run it locally.

1reaction
Dzhuneytcommented, Jun 15, 2020

Other OSs don’t suffer from this performance issue and the “:cached” or “:delegated” flag is a no-op for them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Optimizing Node.js dependencies in AWS Lambda
This post shows how to bundle and minify Lambda function code to optimize performance and stay up to date with the latest version...
Read more >
@aws-cdk/aws-lambda-nodejs | Yarn - Package Manager
Node.js Function. The NodejsFunction construct creates a Lambda function with automatic transpiling and bundling of TypeScript or Javascript code.
Read more >
aws-cdk/aws-lambda-nodejs
To use this module, you will need to have Docker installed. Node.js Function. Define a NodejsFunction : new lambda.
Read more >
Cannot deploy Nodejs and Typescript to AWS cdk + lambda
Do you have esbuild in your package.json as a devDependency? Ideally, you should not be using Docker to build the Lambda, but instead...
Read more >
Migrating Go and Node.js Fargate tasks and Lambda ...
Migrating Node.js Lambda functions with CDK is very straightforward. ... package main import ( "github.com/aws/aws-cdk-go/awscdk/v2" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found