I love how easy it is to deploy and run containerized ASP.NET Core apps on App Engine (flex). So much so that, I created a Cloud Minute recently to show you how, here it is.
It basically involves 3 steps:
- Create your ASP.NET Core app using dotnet command line tool inside Cloud Shell and publish your app to get a self-contained DLL.
- Containerize your app by creating a Dockerfile, relying on the official App Engine image and pointing to the self-contained DLL of your app.
- Create an app.yaml file for App Engine and use gcloud to deploy to App Engine.
That’s it! If you want to go through these steps yourself, we also have a codelab for you that you can access here.
The next component I want to explore in the Compute layer of Google Cloud Platform (GCP) is App Engine. As usual, App Engine Docs is the best place to learn more but I want to provide shorter notes here. Being a Java guy myself, I also want to emphasize aspects of App Engine relevant to Java.
What is App Engine?
- Platform as a Service (PaaS) offering of Google Cloud.
- Provides managed runtimes for specific versions of Java, Go, PHP, Python.
- Mainly for web and mobile apps.
- App Engine provides:
- Automatic scaling and load balancing.
- Access to other App Engine services such as Datastore, Blobstore, Memcache, Endpoints, Task Queues, Scheduled Tasks, Search API, Logs API and more.
- Each language comes with an App Engine SDK for local development, testing and deployment.
- There are 2 flavors of App Engine:
- Sandbox: Provides a sandboxed (and limited) environment to run your web app.
- Managed VM (beta): Built on top of Compute Engine, provides more freedom on environment.
In the default flavor of App Engine, your Java app needs to conform these sandbox constraints in order to run on App Engine:
- App needs to run in Java 7 and a limited subset of Java standard library.
- App cannot write to file system (use Datastore instead).
- No arbitrary network connections.
- No slow responses: A web request must be handled within reasonable amount of time (the exact time depends on scaling mode).
- Limited threads and background threads (depends on scaling mode).
App Engine (Sandbox) and Java
- Runs your Java web application using Java 7 in a sandboxed environment.
- Uses the Java Servlet 2.5 standard.
- App Engine Java SDK for development. It also has a plugin for supporting development with Apache Maven.
- Development server for local development and testing.
- IDE support: Google Plugin for Eclipse to manage App Engine directly from Eclipse. Additionally, Google App Engine Integration for IntelliJ and NetBeans plugin for Gaelyk Framework.
- Java apps are deployed as App Engine Modules where each module can act like a microservice.
- In terms of configuration:
- Top level app is packaged as EAR (similar to JEE).
- Individual modules are packaged as WAR within EAR (again similar to JEE).
- Each Module can independently choose its own scaling type (how each instance is created and scaled)
- 3 scaling types: Manual, Basic and Automatic.
- Each scaling type has its own instance classes. The instance class determines compute resources and pricing:
- Manual: B1, B2, B4, B4_1G, or B8.
- Basic: B1, B2, B4, B4_1G, or B8.
- Automatic: F1, F2, F4, or F4_1G.
- Managed VM is in beta.
- Based on Google Compute Engine, allows one to customize runtime and OS (beyond what Sandbox provides) using Docker while providing the benefits of App Engine (automatic scaling, load balancing etc.)
- Native support for Java 8 / Servlet 3.1, Java 7 / Jetty 9, Python 2.7 and Python 3.4, Node.js, and Go. Further customization with Docker.
- Google Cloud SDK is needed to administer Managed VMs.