The Definitive Guide to Modernizing Applications on Google Cloud: The what, why, and how of application modernization on Google Cloud
()
About this ebook
Legacy applications, which comprise 75–80% of all enterprise applications, often end up being stuck in data centers. Modernizing these applications to make them cloud-native enables them to scale in a cloud environment without taking months or years to start seeing the benefits. This book will help software developers and solutions architects to modernize their applications on Google Cloud and transform them into cloud-native applications.
This book helps you to build on your existing knowledge of enterprise application development and takes you on a journey through the six Rs: rehosting, replatforming, rearchitecting, repurchasing, retiring, and retaining. You'll learn how to modernize a legacy enterprise application on Google Cloud and build on existing assets and skills effectively. Taking an iterative and incremental approach to modernization, the book introduces the main services in Google Cloud in an easy-to-understand way that can be applied immediately to an application.
By the end of this Google Cloud book, you'll have learned how to modernize a legacy enterprise application by exploring various interim architectures and tooling to develop a cloud-native microservices-based application.
Related to The Definitive Guide to Modernizing Applications on Google Cloud
Related ebooks
DevOps for Databases: A practical guide to applying DevOps best practices to data-persistent technologies Rating: 0 out of 5 stars0 ratingsOptimizing Your Modernization Journey with AWS: Best practices for transforming your applications and infrastructure on the cloud Rating: 0 out of 5 stars0 ratingsMulti-Cloud Strategy for Cloud Architects: Learn how to adopt and manage public clouds by leveraging BaseOps, FinOps, and DevSecOps Rating: 0 out of 5 stars0 ratingsCloud Analytics with Google Cloud Platform: An end-to-end guide to processing and analyzing big data using Google Cloud Platform Rating: 0 out of 5 stars0 ratingsGoogle Cloud for DevOps Engineers: A practical guide to SRE and achieving Google's Professional Cloud DevOps Engineer certification Rating: 0 out of 5 stars0 ratingsCloud Native Automation with Google Cloud Build: Easily automate tasks in a fully managed, scalable, and secure platform Rating: 0 out of 5 stars0 ratingsGoogle Cloud Digital Leader Certification Guide: A comprehensive study guide to Google Cloud concepts and technologies Rating: 0 out of 5 stars0 ratingsScalable Data Architecture with Java: Build efficient enterprise-grade data architecting solutions using Java Rating: 0 out of 5 stars0 ratingsModernizing Legacy Applications to Microsoft Azure: Plan and execute your modernization journey seamlessly Rating: 0 out of 5 stars0 ratingsMigrating Applications to the Cloud with Azure: Re-architect and rebuild your applications using cloud-native technologies Rating: 0 out of 5 stars0 ratingsArchitecting Cloud-Native Serverless Solutions: Design, build, and operate serverless solutions on cloud and open source platforms Rating: 0 out of 5 stars0 ratingsArchitecting Cloud Computing Solutions: Build cloud strategies that align technology and economics while effectively managing risk Rating: 0 out of 5 stars0 ratingsAzure Integration Guide for Business: Master effective architecture strategies for business innovation Rating: 0 out of 5 stars0 ratingsDeveloping Cloud Native Applications in Azure using .NET Core: A Practitioner’s Guide to Design, Develop and Deploy Apps Rating: 0 out of 5 stars0 ratingsOptimizing Microsoft Azure Workloads: Leverage the Well-Architected Framework to boost performance, scalability, and cost efficiency Rating: 0 out of 5 stars0 ratingsAzure for Developers.: Implement rich Azure PaaS ecosystems using containers, serverless services, and storage solutions Rating: 0 out of 5 stars0 ratingsGoogle Cloud for Developers: Write, migrate, and extend your code by leveraging Google Cloud Rating: 0 out of 5 stars0 ratingsAzure Containers Explained: Leverage Azure container technologies for effective application migration and deployment Rating: 0 out of 5 stars0 ratingsEvent-Driven Architecture in Golang: Building complex systems with asynchronicity and eventual consistency Rating: 0 out of 5 stars0 ratings
Enterprise Applications For You
QuickBooks 2023 All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsQuickBooks 2024 All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsCreating Online Courses with ChatGPT | A Step-by-Step Guide with Prompt Templates Rating: 4 out of 5 stars4/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5Bitcoin For Dummies Rating: 4 out of 5 stars4/5Excel Formulas That Automate Tasks You No Longer Have Time For Rating: 5 out of 5 stars5/5Notion for Beginners: Notion for Work, Play, and Productivity Rating: 4 out of 5 stars4/5Enterprise AI For Dummies Rating: 3 out of 5 stars3/5SharePoint For Dummies Rating: 0 out of 5 stars0 ratingsQuickBooks Online For Dummies Rating: 0 out of 5 stars0 ratingsLearning Microsoft Endpoint Manager: Unified Endpoint Management with Intune and the Enterprise Mobility + Security Suite Rating: 0 out of 5 stars0 ratingsManaging Humans: Biting and Humorous Tales of a Software Engineering Manager Rating: 4 out of 5 stars4/5Mastering QuickBooks 2020: The ultimate guide to bookkeeping and QuickBooks Online Rating: 0 out of 5 stars0 ratingsScrivener For Dummies Rating: 4 out of 5 stars4/5Excel 2019 For Dummies Rating: 3 out of 5 stars3/5The New Email Revolution: Save Time, Make Money, and Write Emails People Actually Want to Read! Rating: 5 out of 5 stars5/5101 Ready-to-Use Excel Formulas Rating: 4 out of 5 stars4/5Access 2019 For Dummies Rating: 0 out of 5 stars0 ratingsSharePoint 2016 For Dummies Rating: 5 out of 5 stars5/5ChatGPT Ultimate User Guide - How to Make Money Online Faster and More Precise Using AI Technology Rating: 1 out of 5 stars1/5Excel All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsLearning Microsoft Azure Rating: 4 out of 5 stars4/5Office 365 All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsQuickBooks 2021 For Dummies Rating: 0 out of 5 stars0 ratings
Reviews for The Definitive Guide to Modernizing Applications on Google Cloud
0 ratings0 reviews
Book preview
The Definitive Guide to Modernizing Applications on Google Cloud - Steve (Satish) Sangapu
BIRMINGHAM—MUMBAI
The Definitive Guide to Modernizing Applications on Google Cloud
Copyright © 2021 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Group Product Manager: Rahul Nair
Publishing Product Manager: Rahul Nair
Senior Editor: Arun Nadar
Content Development Editor: Nihar Kapadia
Technical Editor: Shruthi Shetty
Copy Editor: Safis Editing
Project Coordinator: Ajesh Devavaram
Proofreader: Safis Editing
Indexer: Subalakshmi Govindhan
Production Designer: Alishon Mendonca
First published: December 2021
Production reference: 2121121
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-80020-979-4
www.packt.com
To the memory of my father, Ishwar, and my mother, Savithri, for their sacrifices and exemplifying that hard work has positive outcomes. To my wife, Sanju, for being my loving and supportive partner, and to my children, Riya and Risha, for keeping us on our toes.
– Steve (Satish) Sangapu
To my parents, who have encouraged me in writing this book, with their push for tenacity ringing in my ears.
– Dheeraj Panyam
Contributors
About the authors
Steve (Satish) Sangapu has been working with software since 2000. He specializes in migrating and modernizing applications from monoliths to containerized microservices as well as creating data engineering pipelines to mine vast amounts of structured and unstructured data.
He has extensive experience successfully leading large, cross-functional, geographically dispersed teams utilizing modern Agile development methodologies while collaborating effectively with product teams in creating high-performance, fault-tolerant, and high-availability systems.
He also holds seven patents from the United States Patent and Trademark Office and certifications from Carnegie Mellon Software Engineering Institute and Google Cloud.
I want to thank the people who have given me and the people around me love and support in different ways in my life.
Dheeraj Panyam has been working in the IT industry since 2000. His experience spans diverse domains (optical, telecom, retail, and healthcare) and covers all phases of the SDLC, including application development, production support, QA automation, and cloud architecture. He lives in India and collaborates with a Google Cloud consulting company, helping them design solutions and architecture set up on public cloud platforms.
He holds multiple Google Cloud certifications in addition to other certifications in networking and testing.(in new line)
Jason Marston is a Cloud Solution Architect based in England. He was recruited by Microsoft because of his OSS background. Jason has worked with Java since version 1 and has a long history with open source. He has over 30 years' of experience in developing software and now helps organizations migrate and modernize legacy applications to the cloud. Jason was an SME in the Worldwide Communities project at Microsoft and, as a part of the leadership team for those communities, helped many people solve their problems by adopting Java on Azure. In his spare time, Jason reads science fiction books and has two children who think he is a geek/nerd.
About the reviewer
Radhakrishnan (Krishna) Gopal is a cloud evangelist, seasoned technology professional, and mentor with over 22 years of industry experience in all major cloud hyperscalers, including AWS, Azure, and Google Cloud. He is currently helping organizations to drive business value through cloud adoption and innovation. He has worked in many facets of IT throughout his career and delivered high-quality, mission-critical, and innovative technology solutions leveraging multi-cloud, data, AI, and intelligent automation. He is a Google Cloud Certified Professional Cloud Architect, Google data engineer, Azure certified solutions architect expert, Azure data engineer, data science associate, AI engineer, and AWS Certified Solutions Architect Associate. He loves to explore new frontiers of technology and impart them in solutions to make his clients very successful.
Table of Contents
Preface
Section 1: Cloud-Native Application Development and App Modernization in Google Cloud
Chapter 1: Cloud-Native Application Fundamentals
The cloud-native ecosystem
Benefits of cloud-native applications
Increased speed of delivery
Increased scalability
Increased resiliency
Mixed technology stack and workforce
Continuous integration and delivery
Increased automation
Principles of cloud-native architecture
Principle 1 – lightweight microservices
Principle 2 – leveraging automation
Principle 3 – DevOps culture
Principle 4 – better to go managed
Principle 5 – innovate
Limitations of microservices
Applying the 12-factor app principles on Google Cloud
Code base
Dependencies
Config
Backing services
Build, release, run
Processes
Port binding
Concurrency
Disposability
Dev/prod parity
Logs
Admin processes
Summary
Chapter 2: End-to-End Extensible Tooling for Cloud-Native Application Development
Moving past third-party services – the beauty of end-to-end tooling
Google Cloud Code
Features and benefits of Cloud Code
The role of Cloud Code in the cloud-native app development pipeline
Google Cloud Build
Features and benefits of Cloud Build
The role of Cloud Build in the cloud-native app development pipeline
Google Container Registry
Features and benefits of GCR
The next-gen container registry – Artifact Registry
The role of GCR in the cloud-native app development pipeline
Google Cloud Run
Features and benefits of Cloud Run
The role of Google Cloud Run in the cloud-native app development pipeline
Google Kubernetes Engine
Features and benefits of GKE
The role of GKE in the cloud-native app development pipeline
Operations suite
Features of Google Cloud Monitoring
Features of Google Cloud Logging
The role of the Cloud operations suite in the cloud-native app development pipeline
Summary
Chapter 3: Cloud-Native Architecture Patterns and System Architecture Tenets
Cloud-native patterns
The scope of cloud-native patterns
Solving challenges with cloud-native patterns
Be proactive, not reactive
Scaling and performance
Deployments
Resiliency and availability
Monitoring
Security
Cloud-native design patterns
Microservices
Strangler applications
Decomposition patterns
Event-driven patterns
Command Query Responsibility Segregation
The saga pattern
Multiple service instances
Canary deployments
Stateless services
Immutable infrastructure
Anti-corruption layer
API composition
Event sourcing
The Retry pattern
Circuit breaker pattern
The bulkhead pattern
Using the cloud-native pattern judiciously
Hybrid and multi-cloud architecture recommendations
Distributed deployment patterns
Redundant deployment patterns
Summary
Section 2: Selecting the Right Google Cloud Services
Chapter 4: Choosing the Right Compute Option
Five compute options… and Firebase
Firebase
Cloud Functions
GAE
Cloud Run
GKE
GCE
Pricing
How important is it to choose the right option?
Changing compute options
Making a decision
Summary
Chapter 5: Choosing the Right Database and Storage
Storage and database options on Google Cloud – the big three
GCS – basics
GCS
Cloud SQL
Cloud Firestore (previously Datastore)
Cloud Spanner
Cloud Bigtable
Wrapping up the big five
Additional storage and database options
BigQuery
Filestore
Persistent disks/local solid-state drive (SSD) (block storage)
MemoryStore
Security and flexibility
Summary
Chapter 6: Implementing a Messaging and Scheduling System
Understanding the requirements of a messaging system
Requirement #1: Scalability
Requirement #2: Extensibility
Requirement #3: Agility
Requirement #4: Resiliency
Introduction to asynchronous messaging
Messaging products available (open source and cloud native) on the market
Amazon SQS
Kafka
RabbitMQ
NATS Streaming
Advantages of asynchronous messaging
Introduction to Pub/Sub
What is Cloud Pub/Sub?
Pub/Sub key features
Additional benefits
Pub/Sub Concepts – topics and subscriptions
Pub/Sub model – fan-in and fan-out
Pull versus push types – differences and when to use each type
Getting started with Cloud Pub/Sub
Introduction to Cloud Tasks
Introduction to Cloud Scheduler
Summary
Chapter 7: Implementing Cloud-Native Security
The principles and concepts of cloud security
Economy of Mechanism
Defense in Depth
Principle of Least Privilege
Adding infrastructure security layers (revision)
Cloud IAM
Traditional access control versus Cloud IAM
Concepts of IAM
Entity
Identity
Permissions
Policy
Authentication and authorization
Cloud IAM on Google Cloud Platform
Features of Cloud IAM
Components of Cloud IAM
Members
All authenticated users
All users
Resources
Permissions
Roles
IAM policy bindings
Limitations of Cloud IAM
Cloud Identity
Features of Cloud Identity
Setting up Cloud Identity
Cloud Identity Platform
Features of Cloud Identity Platform
BeyondCorp (a new approach to enterprise security)
Cloud Identity-Aware Proxy (IAP)
Summary
Section 3: Rehosting and Replatforming the Application
Chapter 8: Introducing the Legacy Application
Technical requirements
The infrastructure architecture
The software architecture
Spring Boot
Thymeleaf
Bootstrap
jQuery
Explaining the software architecture
Implementing the software
Spring Boot configuration
Understanding the layers of the application
The presentation layer
The controller layer
The domain layer
Validation and defensive programming
Summary
Chapter 9: The Initial Architecture on Google Compute Engine
Technical requirements
The initial infrastructure design
Designing our network
Designing our network security
Creating the modernization project
Implementing the network
Implementing the VMs
Importing the data
Summary
Chapter 10: Addressing Scalability and Availability
Technical Requirements
Designing for scalability and availability
Using instance templates
Using managed instance groups
Using an HTTP(S) load balancer
Summary
Chapter 11: Re-Platforming the Data Layer
Designing for scalability and availability
Using Cloud Memorystore
Provisioning a Cloud Memorystore instance
Updating the Regional Managed Instance Group
Using Cloud SQL
Using Cloud SQL Proxy
Using Cloud Spanner
Provisioning Cloud Spanner
Updating the build
Updating the application settings
Importing data into Cloud SQL
Exporting data from our MySQL virtual machine
Importing to Cloud SQL
Cloud SQL versus Cloud Spanner
Summary
Chapter 12: Designing the Interim Architecture
The infrastructure architecture
Google Identity Platform
Cloud Pub/Sub
The software architecture
Refactoring the frontend and exposing REST services
Adding Google Identity Platform for identity and authentication
Publishing events
Consuming events
Refactoring to microservices
Microservice boundaries
Summary
Chapter 13: Refactoring to Microservices
Technical requirements
Analyzing the structure of the application backend
Refactoring into microservices
Refactoring the database
The web frontend
The Strangler Pattern revisited
Google HTTP(S) Load Balancer Routing
Google App Engine Dispatcher
Apigee API Manager
Containerizing the deployment units with Docker
Summary
Section 4: Refactoring the Application on Cloud-Native/PaaS and Serverless in Google Cloud
Chapter 14: Refactoring the Frontend and Exposing REST Services
Technical requirements
Creating REST controllers
Creating an AngularJS web frontend
Modules
Components
Routing
Services
Authenticating in the web frontend
Setting up Firebase and Google Identity Platform
Initializing Firebase Authentication
Router updates
The authentication cycle
The signout controller
Validating the authentication token in the REST controllers
The authentication filter
Summary
Chapter 15: Handling Eventual Consistency with the Compensation Pattern
Technical requirements
The distributed transaction problem
The compensation pattern
Creating topics and subscriptions with Google Cloud Pub/Sub
Implementing eventual consistency and the compensation pattern
Deploying and testing the application
Summary
Chapter 16: Orchestrating Your Application with Google Kubernetes Engine
Technical requirements
Introducing GKE
Modes of operation
Creating a GKE cluster
Configuring the environment
Kubernetes ConfigMaps and Secrets
Deploying and configuring the microservices
Kubernetes Pods
Kubernetes ReplicaSets
Kubernetes Deployments
Kubernetes Horizontal Pod Autoscalers
Kubernetes Services
Automating the deployment of our components
Configuring public access to the application
Kubernetes-managed certificates
Kubernetes Ingress
When to use GKE
Summary
Chapter 17: Going Serverless with Google App Engine
Technical requirements
Introducing Google App Engine
Google App Engine standard environment
Google App Engine flexible environment
Components of App Engine and the hierarchy of an application deployed on App Engine
Deploying containers to the App Engine flexible environment
Application configuration updates
Deployment configuration
Automating deployment
When to use Google App Engine
Summary
Chapter 18: Future Proofing Your App with Google Cloud Run
Technical requirements
Cloud Run
The Knative stack
Cloud Run environments
Deploying containers to Google Cloud Run
Frontend configuration
Service manifest
Google Cloud Build
Domain name mapping
When to use Cloud Run
Summary
Appendix A: Choosing the Right Migration Strategy
Step 1 – assess
Cataloging existing applications
Educating teams
Choosing what to migrate first
Capable and innovative teams
The effort required for migration
License restrictions and compliance
Can afford downtime
Step 2 – plan
Migration paths versus migration strategies
Choosing the right migration path
Step 3 – migrate
Transferring your data
Deploying workloads
Setting up automated and containerized deployments
Step 4 – optimize
Letting internal teams takeover
Setting up monitoring
Leveraging managed services and automation
Cost and performance
Appendix B: Application Modernization Solutions
Modernizing Java apps
What is Google Anthos?
Preparing to modernize Java apps
Phase 1 – containerizing Java applications
Phase 2 – Refactoring and re-platforming
Modernization strategies (the 6 Rs of modernization)
Retire, retain, and re-architect
Other Books You May Enjoy
Preface
75-80% of enterprise applications are legacy and stuck in the data center. How do we modernize these applications to transform them into modern cloud-native applications so that they can scale in a cloud environment without taking months or years to see the benefits?
This book introduces the services available on Google Cloud and showcases the steps involved in modernizing an example Java Spring Boot application from legacy status to the cloud by replatforming and rehosting with target deployments on IaaS, PaaS, and serverless options available on Google Cloud.
Who this book is for
Software developers and solution architects seeking to gain experience in how to modernize their applications, moving them to Google Cloud and transforming them into cloud-native applications, will benefit from this book.
What this book covers
Chapter 1, Cloud-Native Application Fundamentals, introduces the characteristics of cloud-native applications, including their benefits, along with the ever-popular Twelve-Factor App principles.
Chapter 2, End-to-End Extensible Tooling for Cloud-Native Application Development, introduces the development toolset and services available on Google Cloud to aid in building a modern cloud-native application.
Chapter 3, Cloud-Native Architecture Patterns and System Architecture Tenets, explains the different design patterns and best practices to address specific development challenges, client needs, and platform requirements.
Chapter 4, Choosing the Right Compute Option, introduces the various compute options available on Google Cloud from IaaS, PaaS, and containers to serverless options.
Chapter 5, Choosing the Right Database and Storage, introduces the various database and storage services available on Google Cloud.
Chapter 6, Implementing a Messaging and Scheduling System, explains the need for a messaging system for cloud-native applications, introducing the Pub/Sub service in Google Cloud and comparing it to other open source options.
Chapter 7, Implementing Cloud-Native Security, introduces identity and access management and how it can be used to secure applications deployed on Google Cloud.
Chapter 8, Introducing the Legacy Application, introduces the monolithic Java Spring Boot application along with the frontend and backend components that we will modernize at a later stage.
Chapter 9, The Initial Architecture on Google Compute Engine, explains how the sample legacy application can be rehosted on Google Compute Engine virtual machines.
Chapter 10, Addressing Scalability and Availability, addresses the scalability of the legacy application by utilizing Managed Instance Groups (MIG), which is a collection of Google Compute Engine virtual machines.
Chapter 11, Re-platforming the Data Layer, showcases how to move the backend database from a self-hosted option on Google Compute Engine to a managed service on Google Cloud.
Chapter 12, Designing the Interim Architecture, focuses on understanding how infrastructure and software architecture needs to be changed to prepare for the move to microservices.
Chapter 13, Refactoring to Microservices, explains how we can package our application into separate microservices for the frontend and backend.
Chapter 14, Refactoring the Frontend and Exposing REST Services, explains how to break our monolithic legacy application into microservices for the frontend along with the backend REST APIs.
Chapter 15, Handling Eventual Consistency with the Compensation Pattern, explains how our legacy application can be designed to handle eventual consistency to allow loose coupling between the microservices.
Chapter 16, Orchestrating Your Application with Google Kubernetes Engine, explains the deployment of our legacy application to Google Kubernetes Engine. Now that we have all the individual microservices, we are ready to deploy to containerized platforms.
Chapter 17, Going Serverless with Google App Engine, explains how to deploy our containerized legacy application to Google App Engine.
Chapter 18, Future-Proofing Your App with Google Cloud Run, explains how to deploy our legacy application to Google Cloud Run, which is Google's latest serverless offering.
Appendix A, Choosing the Right Migration Strategy, explains the various migration options available when moving to Google Cloud.
Appendix B, Application Modernization Solutions, introduces Anthos, an application modernization platform.
To get the most out of this book
You will need to install the Google Cloud SDK that contains the gcloud CLI. You will also require familiarity with the Java Spring Boot framework and working knowledge of CLIs in general and the gcloud CLI specifically. You will need to have knowledge of basic DNS concepts such as setting up A records and CNAME records and understanding domains and sub-domains. Experience of working with domain registrars would be helpful. Familiarity with working YAML syntax will be useful to understand CloudBuild configuration files
In addition, if you want to set up a custom domain for your application as mentioned in the chapters that refer to deployments on GCE, GAE, GKE, and Cloud Run, you will need to purchase a DNS domain from a domain registrar. App Engine and Cloud Run, however, come with predefined URLs provided by Google Cloud in case you do not want a custom domain.
If you are using the digital version of this book, we advise you to type the code yourself or access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
After reading the book, you should have a fair understanding of applying the right architecture pattern for your use case to transform a legacy application into a modern cloud-native application, and then use advanced application modernization technologies such as Anthos to create containerized applications that run on Kubernetes.
Download the example code files
You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Modernizing-Applications-with-Google-Cloud-Platform. In case there's an update to the code, it will be updated on the existing GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Download the color images
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://static.packt-cdn.com/downloads/9781800209794_ColorImages.pdf.
Conventions used
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: Developers can use the allUsers value to manage all of the users of the application.
A block of code is set as follows:
layout (content)
xmlns:th=http://www.thymeleaf.org
xmlns:sec=https://www.thymeleaf.org/thymeleaf-extras-springsecurity3
>
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
@Bean(name = accountDataSource
)
@ConfigurationProperties(prefix=spring.account-datasource
)
public DataSource accountDataSource() {
return DataSourceBuilder.create().build();
}
Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: From the Instances page, click CREATE INSTANCE.
Tips or important notes
Appear like this.
Get in touch
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.
Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Reviews
Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!
For more information about Packt, please visit packt.com.
Share Your Thoughts
Once you've read , we'd love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.
Your review is important to us and the tech community and will help us make sure we're delivering excellent quality content.
Section 1: Cloud-Native Application Development and App Modernization in Google Cloud
On completion of Section 1, you will have gained an understanding of the cloud-native ecosystem, principles and benefits of cloud-native architecture as well as how to apply the 12-factor app principles on Google Cloud. In addition, you will get insights into the end-to-end tooling that goes into developing a cloud-native application on Google Cloud, along with a sample reference architecture. Finally, you will learn how to solve common challenges with cloud-native design patterns as well as hybrid and multi-cloud architecture recommendations.
This part of the book comprises the following chapters:
Chapter 1, Cloud-Native Application Fundamentals
Chapter 2, End-to-End Extensible Tooling for Cloud-Native Application Development
Chapter 3, Cloud-Native Architecture Patterns and System Architecture Tenets
Chapter 1: Cloud-Native Application Fundamentals
Cloud computing brought about a paradigm shift in the world of software engineering and changed how we build applications. The cloud ecosystem powers some of the most powerful, largest, and most innovative applications using the same set of universal principles. However, some of these principles go against the best practices in traditional application development but are crucial to the success of a cloud-native application.
In this chapter, we are going to explore these fundamentals and core principles to help you utilize the full potential of the cloud-native ecosystem. After finishing this chapter, you'll have a clear understanding of the following topics and how they are used in day-to-day development on the cloud:
The cloud-native ecosystem
Benefits of cloud-native architecture
Principles of cloud-native architecture
Applying the 12-factor app principles on Google Cloud
The cloud-native ecosystem
The cloud-native ecosystem is a combination of three very basic elements: the cloud platform, the architecture, and, of course, the cloud-native application. Let's break them down one by one.
The cloud platform is what makes cloud-native applications possible. For instance, the virtually unlimited computing and storage capabilities of a cloud platform give cloud-native applications the following characteristics:
Scalability, a defining characteristic.
The pay-per-use model makes the applications cost-effective.
Managed services that make cloud-native applications not only versatile but also very developer-friendly.
There are ample reasons why the industry is choosing cloud-native architecture as the foundation for its applications. The architecture dictates how the software is engineered and with cloud-native architecture, developers have far more control. It enables developers to adopt DevOps, containers, automation, microservices, and more. Microservices, in particular, are one of the most important components of a cloud-native architecture and they are what give cloud-native applications the rest of their defining characteristics: agility and resiliency.
An application can be considered cloud-native when it can take advantage of the cloud platform, and in order to take full advantage, it usually needs to be built on a cloud-native architecture. Therefore, a cloud-native application should be the following:
Managed: Use the cloud platform as an infrastructure (be dependent on it to do all the computing).
Scalable: Quickly increase or decrease resources to match the demand.
Resilient: A single bug or crash should not take down the application.
Loosely coupled: Parts of the application should be isolated enough for them to be altered or removed without any downtime.
If the cloud-native ecosystem were a house, the cloud platform would be the underground foundation, the architecture would be the main pillars, and the cloud applications would be the rooms.
Benefits of cloud-native applications
Cloud-native applications have many benefits that make them superior to traditional applications in many ways. These benefits are why people build cloud-native applications, but not all the benefits are innate; they're not guaranteed automatically.
Simply rehosting to a cloud platform does not mean that the time to market will decrease or that the application will be more resilient. It's up to the developer to ensure that the characteristics of the cloud platform and architecture are carried over to the end user. So, before learning how to develop cloud-native applications, it's a good idea to learn what makes cloud-native applications so powerful and popular among businesses.
Increased speed of delivery
Simply building applications isn't enough – delivering the service to the market is just as important. Bringing a new service or product to the market before competitors has a huge advantage (first-mover advantage). Similarly, timely feature updates and bug fixes are incredibly important as well.
Cloud-native applications can be built in a very short time and are generally much faster at pushing updates as well. This is possible due to the way they are architected as well as because of the approach developers take. Let's take a look at some of the architectural benefits first.
Not monolithic
A decade ago, the trend was to make everything monolithic. Today, the trend is to break the monolith into microservices. This paradigm shift was driven by the need to be more agile and resilient and monoliths were neither. The solution? Use a loosely coupled architecture that is not affected by the limitations of monolithic architecture.
Unlike a monolith, the cloud-native architecture supports an application being built in pieces and then joined together. These pieces are called microservices and they are completely isolated from each other in their own environments called containers. They communicate with each other through APIs. The popular saying breaking the monolith refers to breaking down the web of a complex and interconnected code base into neatly organized microservices that are much easier to maintain.
A popular real-world example of breaking the monolith is Netflix. By the time it turned 1 in 2008, Netflix's monolithic architecture had already become a problematic mess that caused extremely long downtimes. So, after 3 years of refactoring, Netflix's engineers were able to break down their giant monolith into 500-700 microservices, reducing cost, time to market, and downtimes.
A microservices architecture also reduces the time to fix bugs as each microservice is monitored separately and buggy microservices can be quickly identified, replaced with an older version, or completely removed without any downtime.
Independent development of microservices
Another major advantage of microservices is that because they are independent, developers can work on different microservices at once. This gives developers the ability to build and update different parts of the application at once, without constantly worrying about app-breaking updates or having to shut down the entire server for a small bug fix. Although compatibility issues haven't been completely eliminated in cloud-native applications, they are far fewer and rarer.
Amazon's two pizza policy is a great example of the independent development of microservices. The policy states that a microservice is too big if the team working on it cannot be fed by two pizzas. Although not very scientific, it illustrates just how great microservices are for small, especially remote, teams.
Independent deployment of microservices
The loosely coupled design philosophy has given rise to a new breed of applications that are modular. As microservices are usually designed with functionality in mind, they can be thought of as modular features that can be changed, replaced, or completely taken out with minimum impact on the entire application. But they can also be introduced independently. When adding a new microservice to the main code base, no major refactoring is required, which significantly reduces the time to market.
Increased scalability
Scalability is one of the key characteristics of cloud-native applications. They are extremely scalable due to the vast (unlimited as far as most businesses are concerned) hardware capabilities of modern cloud platforms. However, cloud-native applications are not scalable in the same way as traditional applications.
Historically, businesses increased their capacity to serve concurrent users by vertically scaling or scaling up. This means that they went from 2 gigabytes of memory to 8 gigabytes and from a 1 GHz CPU to a 2.4 GHz one.
Cloud-native applications, on the other hand, scale up using a different approach: horizontal scaling or scaling out. Instead of increasing the raw computing and storage capabilities of each unit, cloud platforms increase the number of units. Instead of a single stick of 8 gigabytes, they have four sticks of 2 gigabytes.
Although vertical scaling is easier, horizontal scaling opens up far more possibilities in terms of how resources are allocated and how applications scale with the latter, providing much better scalability.
Additionally, cloud platforms provide a number of scalability benefits such as autoscaling and pay-per-use pricing schemes that make cloud-native applications much better investments.
Increased resiliency
Risks can never be completely eliminated, so instead of solely focusing on avoiding failures, cloud-native applications are architected to respond to failures – that is, to be resilient. The resiliency of