The following whitepaper provides a guide to technical audiences on how to use Google Cloud Platform (GCP) serverless products. The guide also provides advice on how to build serverless microservices, and the business benefits serverless.
What is Serverless ?
Serverless means no upfront provisioning, no management of servers, and pay-what-you-use economics for building applications. Since the beginning of Client-Server development, IT had to manage servers for application hosting (compute) and application databases. Google Cloud has always believed in the vision of serverless by debuting with Google App Engine in 2008, the first fully serverless compute service. Since then, Google has evolved more serverless offerings in both application development and analytics.
Serverless for Application Development
Hosting your Application
GCP’s serverless application hosting options are Cloud Functions and App Engine. Both services abstract the need to manage any servers, and will dynamically scale as needed. Cloud Function is for smaller units of code that are triggered by cloud events or HTTP requests and are only billed per request, which can result in savings for applications with low or uneven traffic patterns. App Engine is for larger units of code (e.g. a website) that triggered by HTTP or cloud events.
For customers that need more control, Kubernetes Engine and Compute Engine are lower-level services that require explicit management of servers. Kubernetes Engine does offload some of the server management by utilizing Kubernetes; however there is still some management of the underlying compute infrastructure, and requires effort on the customer’s operations and development team to automate scaling.
Applications written with Cloud Functions and App Engine are generally have only 2 forms of communication - synchronous HTTP requests and asynchronous events via Pub/Sub. The choice of communication is dependant on the application needs. Both of these services remove the need to configure load balancers or hand manage event queues, further improving developer productivity and lowering operational overhead.
Storing your Application Data
GCP’s serverless database products are Cloud Datastore and Firebase. Both products are a serverless NoSQL database that automatically scales based on traffic. For example, Pokémon GO leveraged Cloud Datastore to automatically scale 50X more than the predicted traffic at launch. Cloud Datastore provides significant cost and management savings over managing your own NoSQL database such as Cassandra and MongoDB. Firebase has additional features and functionality for mobile and web application developers such as real time data synchronization across clients, integrated OAuth and Analytics.
For customers that need more control or have special database requirements, they can install their own database on GCP VMs with persistent disks, or use one of GCP’s managed database products such as Bigtable, Spanner, or Cloud SQL. These managed databases offload much of the operational management overhead, but still require the customer to explicitly control scaling based on application needs.
Serverless for Analytics
GCP serverless analytics covers data warehousing, data pipelines (ETL), and machine learning. The backbone of these products is Cloud Pub/Sub and Google Cloud Storage, which allows transfer of both streaming and batch data of any size or velocity.
Dataflow is a managed service for developing and executing a wide range of data processing patterns including ETL, batch computation, and continuous computation. Dataflow is designed to handle unbounded, unordered, global-scale datasets (e.g. web logs, mobile usage statistics, and sensor networks), which are increasingly common in day-to-day business. This type of data presents a server management nightmare due to dynamic resource requirements. Dataflow abstracts these concerns, and automatically scales the underlying compute resources to meet user’s requirement on latency, correctness, and cost.
BigQuery is GCP’s petabyte scale, low cost data warehousing product. The secret to BigQuery’s low cost and high performance is the ability to automatically scale out to thousands of CPUs across petabytes of data. Users can interactively query data through BigQuery’s API.
For organizations that want to go beyond traditional SQL-based analytics, Cloud ML Engine is a managed machine learning service based on the popular TensorFlow framework. It has both batch and realtime (online) prediction APIs, and also automatically scales depending on resource requirements. You can also opt to process your data on TensorFlow using GPUs and TPUs for faster training and inference.
Serverless for Microservices Architecture
GCP’s serverless products solve certain pain-points organizations encounter while implementing microservices architectures.
Reducing Infrastructure Cost - Microservices architectures require each service to have their own isolated application server cluster and database. Sharing infrastructure is an anti-pattern. Because microservices leads to an explosion in smaller services, the corresponding # of servers that need to run databases and application servers also explodes. Without dynamic scaling of serverless, companies are often forced to over provision compute resources.
Reducing Operational Cost - The operational cost of provisioning and managing many server clusters also explodes when the # of microservices increase. By providing out-of-the-box self-service provisioning of servers for compute and databases, operational costs are dramatically lowered. All of GCP’s serverless offerings provide APIs for managing serverless products, so an enterprise’s operations teams can spend their resources implementing high-level governance requirements rather than managing individual servers.
Avoiding long synchronous call chains - A common issue with microservices is that services are developed in isolation, and often resulting in synchronous call chains which lead to poor performance for microservices that are customer facing. A pattern to eliminate this issue is by asynchronously “pre-computing” results for a set of microservices, and storing the results in a low-latency / high-throughput database. GCP’s Cloud Pub/Sub, compute, and database services allows easy and cost effective construction of such architectures.
Business Benefits of Serverless:
Applications with rapid time-to-market and unpredictable scale requirements benefit most from serverless compute and serverless databases. Frequently, enterprise innovation projects or startup development fall into this category.
- Google is committed to providing its customers a broad set of serverless products. Over the years, GCP has introduced new serverless products covering both application development and analytics.
- Microservices are especially suited for serverless in terms of cost and performance.
- Applications and databases that are not suitable to be hosted on GCP’s serverless products can be mixed and matched with services such as Compute Engine, Kubernetes Engine, or Cloud SQL.
- Business benefits are rapid time-to-market and lower infrastructure and operations costs compared to using non-serverless solutions.