Skip to content

Instantly share code, notes, and snippets.

@redroot
Created October 26, 2017 13:10
Show Gist options
  • Select an option

  • Save redroot/5ef2fdce2dc3cc2540b885c4c0a57a52 to your computer and use it in GitHub Desktop.

Select an option

Save redroot/5ef2fdce2dc3cc2540b885c4c0a57a52 to your computer and use it in GitHub Desktop.
Notes on Google Cloud

Node.js Bookshelf Google Cloud App Engine Tutorial

Using:

  • Google Cloud Datastore - Horizontally Scalable NoSQL Document Database
  • Google Cloud Pub/Sub - Provides reliable, many-to-many, asynchronous messaging between applications.
  • Google Cloud Storage JSON - Lets you store and retrieve potentially-large, immutable data objects.
  • Google Cloud Stackdriver Logging - Writes log entries and manages your Stackdriver Logging config.
  • Google+ API - The Google+ API enables developers to build on top of the Google+ platform.

Notes

  • GC Lets you split traffic between versions by default, would be great for A/B testing a new performance-factored feature.
  • Looks like GC also offers MongoDb and Managed SQL as part of their package
  • Definitely slow to deploy, 5+ minutes each time.
  • Datastore seems pretty standard CRUD stuff in Node.js at least, seems cool. toDatastore method used to convert to Datastore format, have to explicitly remove keys from indexs. Has pagination built in to apparently.
  • Express Multer used to store images in memory during upload. Post method chains several command together, using next() and then uploads the file to GC Cloud and returns image to req.file to be saved to Datastore.
  • For Oauth Consent Screen, you can not only register Authorised Callback URLs but also Authorised Javascript Origins
  • Using RedisLabs powered Memcache (serverless) to persist sessions between versions and deploys.
  • Idea of a worker.js with its own .yaml file. Can deploy that .yaml file separately which then defines it as a new service! In this case the worker tries to find more info on a book and update it!
  • This is a pretty mental testing idea - proxy requres within node requires and stub out what they return https://github.com/thlorenz/proxyquire. See example in https://github.com/GoogleCloudPlatform/nodejs-getting-started/blob/master/6-pubsub/test/worker.test.js#L68

Just a test to try out different Google Cloud static site offerings.

Basic Cloud Storage Steps

Requires gsutil command line tool.

  1. Create CNAME pointing at Google Verified subdomain e.g. foo.example.com | CNAME | c.storage.googleapis.com.
  2. gsutil mb gs://foo.example.com Create the bucket
  3. gsutil rsync -R dist gs://foo.example.com Deploy by syncing everything to the bucket
  4. gsutil acl ch -u AllUsers:R gs://foo.example.com Make all files publically accessible
  5. gsutil web set -m index.html -e 404.html gs://foo.example.com set up index and error pages

Questions at this stage?

  1. Cloudfront equivalent for high availability? - Cloud Storage offers in build edge caching
  2. Storage cost comparisons to s3 for 1G of data, 100G of data out, 1M read requests, 1k write requests, us-east-1: S3 is $11.57, CS is ~ $15

Google App Engine

Requires gcloud tool

  1. Set up app.yaml file with stuff required for site
  2. gcloud app deploy [--version] [--project] deploy the site
  3. gcloud app browse to open it
  4. Can install domains component to extend gcloud to manage domains

Questions/Notes at this stage?

  1. Cache invalidation of static assets seems hard
  2. app.yaml seems cool, has lots of options for python at least https://cloud.google.com/appengine/docs/standard/python/config/appref. CORS and login!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment