webiny / webiny-js

Open-source serverless enterprise CMS. Includes a headless CMS, page builder, form builder, and file manager. Easy to customize and expand. Deploys to AWS.
https://www.webiny.com
Other
7.4k stars 614 forks source link

⚠️ Services Bundles Optimization #1261

Closed adrians5j closed 3 years ago

adrians5j commented 4 years ago

A more-than-we-would-like amount of code is piling up in our Lambda functions / federated GraphQL services, which affects cold starts.

There are a couple of annoying packages that increase the size significantly, for example the apollo-server-lambda, which I decided to trim this week. By going deep into the package and checking what it contained, I managed to shave of ~1.3MB from each service! The problem with the apollo-server-lambda was that it imported GQL Playground and famous busboy lib for handling file uploads, both of which we weren't using at all (GQL playground was used only on the Apollo Gateway Lambda).

In order to see what else could be removed, I continued my research. The conclusion is that there are still packages that should NOT be in the bundle, like ajv (225kb), bson (203kb), mime-db (186kb), etc. I even saw bluebird (186kb) in I18N GraphQL bundle 😱 🤯.

Anyways, at the moment, I didn't had more time to go and check these, but this is something we'll certainly need to check. There might be a couple of easy wins there. For example, bson lib should go automatically go away with the introduction of DynamoDb, as we won't need the DB Proxy anymore (included in commodo-fields-storage-db-proxy package). We won't be needing @commodo/fields-storage-ref as well, which is additional 47kb.

And so on, and so on...

Hopefully, we'll be able to revisit this before v5 launch.

webiny-bot commented 3 years ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

adrians5j commented 3 years ago

Will close this, we did massive optimizations along the way.