netlify-plugin-gatsby icon indicating copy to clipboard operation
netlify-plugin-gatsby copied to clipboard

Optionally load Gatsby datastore into lambdas after deploy

Open ascorbic opened this issue 2 years ago • 6 comments

We currently include the Gatsby lmdb datastore (data.mdb) in the lambda bundle, then move it into the tmp dir at first run, because it needs to be in a writeable filesystem. The problem with this is that for large sites the database can be larger than the maximum lambda deploy size. We could avoid this by instead loading the db from the CDN at first run. This would mean its size would be limited only by the max tmp dir size (512MB), but it would have a cold start cost. It would also mean the db was technically exposed to the internet. However if we create a filename that is very long and random then that is equivalent to password protection. The filename could be bundled inside the lambda instead, along with a hash of the file.

Because of the tradeoff, it would make sense for this to be optional. We could either do it automatically if we see the datastore is larger than a certain size, or we could use an env var and give an error message that suggests enabling it if the db is too large.

ascorbic avatar Mar 11 '22 10:03 ascorbic

Some notes from our discussion:

  • we could set headers config to add basic auth to the db file too
  • we could pre-warm the lambda in an onSuccess call, which would ensure the db was loaded before the first request

ascorbic avatar May 04 '22 08:05 ascorbic

Enterprise customer excited for the fix: https://netlify.zendesk.com/agent/tickets/92557

fool avatar May 05 '22 03:05 fool

As a slight widening of scope here, if changes to the DB can be made independently to the rest of the build that would be a huge value add to our customers. It might require some work from Workflow folks but please include this in your conversations.

For more context reach out to me (or technically) @ascorbic .

krider2010 avatar May 12 '22 11:05 krider2010

@krider2010 I've created a separate issue for the work that you mentioned here and assigned @ascorbic so he can fill out the details when some thought has been given to how we want to approach that

ericapisani avatar May 13 '22 14:05 ericapisani

Just to give an update here - main functionality has been released, currently working on the documentation for this

ericapisani avatar May 30 '22 18:05 ericapisani

Looks like the documentation is done. Is there anything else left for this issue @ericapisani or is it OK to close this?

nickytonline avatar Jun 27 '22 19:06 nickytonline

It's ok to close this now

ericapisani avatar Sep 28 '22 15:09 ericapisani