Skip to content

Instantly share code, notes, and snippets.

@ptinsley
Created April 22, 2019 21:08
Show Gist options
  • Save ptinsley/7644dfb23c5d4f989ba85afd955d0fee to your computer and use it in GitHub Desktop.
Save ptinsley/7644dfb23c5d4f989ba85afd955d0fee to your computer and use it in GitHub Desktop.
Cloud Run PoC Braindump

Cloud Run PoC

Pricing

  • Standard
    • First 180,000 vCPU-seconds free (unsure if per deploy, per project etc..?)
    • First 360,000 GB-seconds free (unsure if per deploy, per project, etc...?)
    • First 1GB egress free
    • First 2 Million requests free
    • Billed to the nearest 100 milliseconds, billed for container startup time and time when a container is processing requests
  • GKE
    • TBD Platform Cost (no cost in Beta)
    • Direct GKE costs

Sizing

  • Standard
    • CPU: 1 core, not configurable
    • RAM: 128MB, 256MB, 512MB, 1GB, 2GB
  • GKE
    • CPU: Can be set to anything a GCE instance can handle
    • RAM: 128MB, 256MB, 512MB, 1GB, 2GB (need to confirm this)

Hostnames

By default Cloud Run Services (what we call a deployed app) run under *.run.app but custom domain mappings can be setup after proving ownership of your custom domain(s)

Concurrency

Concurrency is a huge differentiator between Cloud Run and Cloud Functions, in functions the concurrency is always one. In Cloud Run it defaults to 80 (the maximum) concurrent requests and is configurable down to 1.

Deployment

A deployment to Cloud Run is called a revision and packages up the container image to use, environment variables that are set, sizing and concurrency information. Revisions are immutable, any change to the parameters of a Cloud Run deployment creates a new revision.

Memory Usage

The default allocation is 256MiB and can be adjusted up to 2GB. It's important to note that the filesystem in the runtime environment is mounted in memory, if you write files to the filesystem (temporary files, etc..) you should ensure you are cleaning them up as they use the memory available to the runtime. If a Cloud Run instance exceeds it's RAM limit, it will be killed.

Request Specifics

  • Websockets are not currently supported
  • gRPC is not currently supported
  • Maximum request size of 32MB
  • Maximum response size of 32MB
  • Requests starting with "ah/" will not make it to your app

Timeouts

The default timeout is 300 seconds (5 minutes) and is configurable from 1 second up to 900 seconds (15 minutes.)

Environmental Variables

Environment variables are completely configurable with some caveats:

  • Key names can be alphanumeric and underscore only
  • Maxiumum of 32Kb (per variable)
  • Blacklisted Variables (used by cloud run itself)
    • PORT
    • K_SERVICE
    • K_REVISION
    • K_CONFIGURATION

Security

Containers run inside gVisor which adds an additional layer of security but depending on the apps behaviour could run into issues with restricted service calls.

Debugging

  • Logging
    • Fling and ELK can be used just like any other container deploy
    • Stackdriver logs have the console logs and any deploy related details
      • WARNING: we will need to be very careful with console output, stackdriver costs can baloon quickly.
  • Console Access
    • Not possible in Standard mode, finding the pod in GKE mode would allow you to get console access.

Unanswered Questions

  • How do we handle secrets?
  • Can I force Cloud Run to never scale to zero to avoid cold start delay?
  • What size gap between requests would trigger a scale to zero event?
  • Can I truly only use 2G of ram in GKE mode?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment