Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GeoDjango on Zappa with Lambda

Avatar for Adam Fast Adam Fast
September 25, 2019

GeoDjango on Zappa with Lambda

A lightning talk on getting GeoDjango to run in AWS Lambda

Avatar for Adam Fast

Adam Fast

September 25, 2019

More Decks by Adam Fast

Other Decks in Programming

Transcript

  1. GeoDjango on Zappa A shortcut to save you time Adam

    Fast @adamcanfly https://www.jbssolutions.com/geodjango-zappa-lambda/
  2. I would use environment variables Setting to Lambda’s paths will

    make local or Docker development difficult
  3. Downside: Code Size (Figures include ~4MB of data files, other

    code) Using RasterIO’s bundle 55.7MB
 Manually managing 33.5MB
  4. Zappa ‘Slim’ Handler • If you don’t use it, you

    can use these paths as long as you install rasterio==1.0.25 • Other versions could bundle different versions of the libraries with different filenames • If you use it, your GEOS_LIBRARY_PATH / GDAL_LIBRARY_PATH will change • The path will live in /tmp/ and depend on what your project folders are named • /tmp/<project>/rasterio/.libs/libgeos_c-595de9d4.so.1.10.2 • /tmp/<project>/rasterio/.libs/libgeos-3-cd838e67.6.2.so
  5. `zappa invoke …` Use this to find GEOS / GDAL

    if my paths don’t work due to slim_handler, version upgrades, etc
  6. Bonus: Zappa? • Several DjangoCon in-depth talks available in the

    archive on YouTube • “Serverless” still requires servers, but rather than having WSGI processes running full time it invokes each request as it comes in • Zappa is a compatibility wrapper on AWS Lambda to allow Django to run • There is vendor lock-in, but you can still run Django in a more traditional model in the event that becomes an issue • Many applications can run inside of the free limit AWS provides
  7. If you’re not using Zappa already… • Recommend you have

    your application using Zappa before adding GeoDjango using this tip • `pip install zappa` • `zappa init` and answer questions • `zappa deploy <envname>` • Take URL you’re issued and configure for ALLOWED_HOSTS, etc • `zappa update <envname>` • `zappa tail <envname>` will be useful to watch logs