-
Hi there, We're currently testing rolling out Yarn 2 + PnP for our monorepo which previously used Yarn 1 + Lerna. We have a fairly large monorepo with several packages & independently deployable services (which run inside their own docker containers). Yarn2 + PnP has worked really well in our development environment and has solved a number of issues for us - initially we only intended to use Yarn 2 + PnP in development but soon realised that we'd probably have to use it in all environments to avoid dependency differences. After successfully updating our deployment pipelines to work with Yarn 2 (We're using Zero Installs too - we copy the entire monorepo inc .yarn folder into each service's docker image) we noticed that several of our services failed to boot due to running out of memory. Monitoring this showed that in some cases services were now using 3x the memory that they had when using Yarn 1. We actually realised one of the causes we that we were running the yarn executable twice, once via We decided we weren't too concerned with this, so we just upped all the memory limits and took the hit. However, we've now noticing that a few of our services are actually running out of memory when under load, which we never had issues with before. One service is particular is throwing OOM errors even when increasing its memory cap to 512mb, which was 256mb previously (it rarely went above 128mb in actuality). So, I guess it would be really useful is someone could help with the following questions:
It's worth nothing that we have quite a few packages so Yarn 2 + PnP is using a lot of "virtual" packages to run. Thanks a lot! Sorry for the long post! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
There's an overhead caused by the Zip layer. To avoid opening/closing archives for each Another optimization that could be interesting would be to make the PnP hook a noop when executed within the Yarn CLI environment (since we don't do
Having lots of virtual packages may be sign that you have a lot of dependencies that are duplicated. If the virtualized packages are expected to be singletons (for example |
Beta Was this translation helpful? Give feedback.
-
You can (and should) avoid executing yarn in the container by running |
Beta Was this translation helpful? Give feedback.
-
Hello, I do understand that following question might easily be more generic yarn/node question, and do apologise for being on edge of offtopic here, but for my service startup command is to call binary provided by package, |
Beta Was this translation helpful? Give feedback.
You can (and should) avoid executing yarn in the container by running
node -r ./.pnp.cjs ./dist/main.js
insteadhttps://yarnpkg.com/features/pnp#initializing-pnp