# Runtime Environments

## Basics

|                         | Cloud Functions                                   | App Engine                                                           | Cloud Run                                                            | Kubernetes Engine                                                        | Compute Engine                                             |
| ----------------------- | ------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------------------------------------------------------------ | ---------------------------------------------------------- |
| **Fully Managed**       | FaaS                                              | PaaS                                                                 | CaaS/PaaS                                                            | Kubernetes Clusters                                                      | Virtual Machines                                           |
| **Deployable Artifact** | Source or JAR                                     | Source or JAR                                                        | Container Image                                                      | Container Image                                                          | Anything, and Container Image                              |
| **Locality**            | Regional                                          | Regional                                                             | Regional                                                             | Zonal/Regional                                                           | Zonal/Regional                                             |
| **Billing Units**       | Instance execution time seconds and Invocations   | Instance up time minutes                                             | Instance execution time seconds                                      | Control plane and VM instance hours                                      | VM instance hours                                          |
| **vCPU**                | 1                                                 | 1, up to 4.8GHz                                                      | Up to 2                                                              | Up to 416 per node, and up to 5000 nodes.                                | 0.5 to 416                                                 |
| **Memory**              | Up to 2GB                                         | Up to 2GB                                                            | Up to 4GB                                                            | Up to 11TB per node.                                                     | Up to 11TB                                                 |
| **Disk**                | Writable `/tmp` directory                         | Writable `/tmp` directory                                            | Writable `/tmp` directory                                            | Attach Tmpfs/PD/SSD                                                      | Attach PD/SSD                                              |
| **Use For**             | <p>Webhooks</p><p>Event Handlers</p><p>Tasks </p> | <p>Web Apps</p><p>Microservices</p><p>Event Handlers</p><p>Tasks</p> | <p>Web Apps</p><p>Microservices</p><p>Event Handlers</p><p>Tasks</p> | <p>Any container workload</p><p>JEE applications</p><p>Microservices</p> | <p>Any workload</p><p>JEE applications</p><p>Databases</p> |

## Application Lifecycle

|                            | Cloud Functions   | App Engine   | Cloud Run         | Kubernetes Engine         | Compute Engine |
| -------------------------- | ----------------- | ------------ | ----------------- | ------------------------- | -------------- |
| **Liveness Check**         | Port is listening | /\_ah/health | Port is listening | Liveness Probe            | Manual         |
| **Readiness/Warmup Check** | No                | /\_ah/warmup | No                | Readiness Probe           | Manual         |
| **Graceful Shutdown**      | No Signal         | /\_ah/stop   | No Signal         | `SIGTERM` or custom hooks | Manual         |

## Scaling

|                     | Cloud Functions   | App Engine        | Cloud Run         | Kubernetes Engine                    | Compute Engine                   |
| ------------------- | ----------------- | ----------------- | ----------------- | ------------------------------------ | -------------------------------- |
| **Scaling**         | 0 to N in seconds | 0 to N in seconds | 0 to N in seconds | 1 to N in seconds or minutes         | 1 to N in minutes                |
| **Autoscaling**     | Yes               | Yes               | Yes               | Yes, with HPA and Cluster Autoscaler | Yes, with Managed Instance Group |
| **Scaling Min/Max** | No                | Yes               | Yes (alpha)       | Yes, with HPA and Cluster Autoscaler | Yes, with Managed Instance Group |
| **Manual Scaling**  | No                | Yes               | No                | Yes                                  | Yes                              |

## Load Balancing

|                             | Cloud Functions | App Engine | Cloud Run | Kubernetes Engine              | Compute Engine                  |
| --------------------------- | --------------- | ---------- | --------- | ------------------------------ | ------------------------------- |
| **Network Load Balancer**   | No              | No         | No        | Yes, with `Service`            | Yes, with Network Load Balancer |
| **HTTP**                    | Yes             | Yes        | Yes       | Yes, with `Ingress`            | Yes, with HTTP(s) Load Balancer |
| **HTTPs**                   | Yes             | Yes        | Yes       | Yes, with `Ingress`            | Yes, with HTTP(s) Load Balancer |
| **Custom Domain**           | No              | Yes        | Yes       | Yes, manual configuration      | Yes, manual configuration       |
| **Managed SSL Certificate** | Yes             | Yes        | Yes       | Yes, with `ManagedCertificate` | Yes, with HTTP(s) Load Balancer |

## Networking

|                                  | Cloud Functions | App Engine | Cloud Run | Kubernetes Engine | Compute Engine |
| -------------------------------- | --------------- | ---------- | --------- | ----------------- | -------------- |
| Use VPC                          | Yes             | Yes        | Yes       | Yes               | Yes            |
| Expose on VPC Only               | Yes             | No         | No        | Yes               | Yes            |
| Internal VPC Only Load Balancing | No              | No         | No        | Yes               | Yes            |
