Skip to content

Higher memory usage when using Yarn 2 (w/ PnP) vs Yarn 1 in production environments #2884

Answered by merceyz
bjshort asked this question in Q&A
Discussion options

You must be logged in to vote

We actually realised one of the causes we that we were running the yarn executable twice, once via yarn workspace foo-service start, which then ran yarn node dist/main - this caused an extra yarn process to start on the server. After altering the second command to just be node dist/main the total memory usage reduced by about 30%, but the overall memory usage is still a lot higher than with Yarn1.

You can (and should) avoid executing yarn in the container by running node -r ./.pnp.cjs ./dist/main.js instead

https://yarnpkg.com/features/pnp#initializing-pnp

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@bjshort
Comment options

Comment options

You must be logged in to vote
2 replies
@bjshort
Comment options

@MonsterDeveloper
Comment options

Answer selected by merceyz
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants