Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building Grails Apps For Google Cloud

Building Grails Apps For Google Cloud

In this presentation we introduce basics of building and deploying Grails applications on Google Cloud as well as using Bigtable, Cloud Storage, and PubSub with Grails apps.

Ryan Vanderwerf

March 16, 2018
Tweet

More Decks by Ryan Vanderwerf

Other Decks in Programming

Transcript

  1. objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights reserved.

    No part of these notes may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior, written permission of Object Computing, Inc. (OCI) Grails and Google Cloud Greach 2018 Ryan Vanderwerf
  2. objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights reserved.

    2 • Father of 2 kids • Members of OCI Grails Team • other stuff here About Ryan
  3. objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights reserved.

    3 WE ARE SOFTWARE ENGINEERS. We deliver mission-critical software solutions that accelerate innovation within your organization and stand up to the evolving demands of your business. INDUSTRIAL IoT BLOCKCHAIN CONSULTING MACHINE LEARNING CLOUD SOLUTIONS AREAS OF EXPERTISE We equip industrial environments with seamless connectivity and real-time analytics that reduce operating costs and deliver on customer demands. We can modernize your legacy applications and enable scalable, integrated AI capabilities tailored to your unique sets of data. We are at the forefront of blockchain technology, and we have practical, real-world experience with its implementation. We combine software engineering expertise with cloud-native architecture to accelerate innovation within your organization.
  4. 6 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. 160+ Engineers MS/PHD Advanced Security Clearance 14 Average Years OCI Tenure 19 Average Years Engineering Experience OUR GLOBAL FOOTPRINT
  5. 7 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. • Google Cloud Overview • Google Cloud Console • Google Cloud SDK • Google Compute • Google Appengine • Grails Application - Push to AppEngine • Google Cloud SDK • Cloud SQL • Cloud Storage • Bigtable Overview • Bigtable Grails Examples • PubSub Overview • PubSub Grails Examples Agenda
  6. 8 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. Free Stuff • There is now a free tier! Google now competes with AWS 1 year free tier • Also get starter $300 USD credit • Compute - free f1.micro + 3GB HDD instance per month (us regions only) • AppEngine - free 28 instance hours/day • Cloud storage - 5GB • free memcache • 1000 search ops/day • 100 emails/day • 10GB sub/sub messages/mo • and more.. check out https://cloud.google.com/free/ for everything Google Compute Overview
  7. 9 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. • Why Google Cloud? • You may be asked by your employer to investigate • Your employer may have already adopted • Where does it stand? (Gartner chart) Google Compute Overview
  8. 10 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. Go to https://console.cloud.google.com/home/dashboard • create a project - resources are always tied to context of a project • Next let's install the Cloud SDK Google Cloud Console
  9. 11 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. This is how you interact with Google cloud remotely • Download the SDK for your operating system at https://cloud.google.com/sdk/downloads • Run 'gcloud init' to set up your SDK • Enter your account, and select the project you will be working with • Next let's use app engine! Google Cloud SDK
  10. 13 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. Run 'gcloud app create' to create the AppEngine • Pick the region/zone you want • It will say use 'gcloud app deploy' but we'll be using the Gradle AppEngine plugin instead • Next we'll set up our Grails App to be able to be deployed • Create Grails App using start.grails.org or SDK man and run 'grails create-app <name>' Google App Engine
  11. 14 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. • Setup App Engine plugin in build.gradle • Setup App Engine yaml config file app.yaml • We switch Tomcat out with Jetty as it works better with App Engine Google App Engine
  12. 16 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. Enable Cloud SQL API • Go to API Manager • Enable Google Cloud SQL API Create Cloud SQL Instance • Datasource using Cloud SQL • Create Instance • Add MySQL jars to build.gradle • Get instance connection name and add to application.yml • Example Grails Application Demo Google Compute Overview
  13. 17 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. What is Google Cloud Storage? Google Cloud storage is an network object store like Amazon S3 • Enable Google Cloud Storage API • Create Bucket • Add jars to build.gradle • Add config to application.yml • Demo Grails Application Google Cloud Storage
  14. 18 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. To Deploy Use Gradle • ./gradlew appengineDeploy • Enable Logging • Logging Grails Demo • Status Console Deploy To App Engine
  15. 19 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. Bigtable is a Hbase cluster on Google Cloud • Wide Column Store • Mapreduce but with Transactions • Powers Google services, including Search, Analytics, Maps, and Gmail • Use Apache HBase Java libraries to access Google BigTable
  16. 20 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. What is BigTable? • Cloud Bigtable is a sparsely populated table that can scale to billions of rows and thousands of columns, allowing you to store terabytes or even petabytes of data. • What is it good for? • Cloud Bigtable is ideal for applications that need very high throughput and scalability for non-structured key/value data, where each value is typically no larger than 10 MB. • Cloud Bigtable also excels as a storage engine for batch MapReduce operations, stream processing/analytics, and machine-learning applications. Google BigTable
  17. 21 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. Storage Architecture • Stores data in massively scalable tables • The table is composed of rows • Each describes a single entity • Columns contain individual values • Each row is indexed by a single row key, and columns that are related to one another are typically grouped together into a column family • Each column is identified by a combination of the column family and a column qualifier, which is a unique name within the column family. Google BigTable
  18. 23 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. About the diagram • The table contains one column family, the follows family. This family contains multiple column qualifiers • Column qualifiers are used as data. This design choice takes advantage of the sparseness of Cloud Bigtable tables, and the fact that new column qualifiers can be added on the fly • The username is used as the row key. Assuming usernames are evenly spread across the alphabet, data access will be reasonably uniform across the entire table.. Google BigTable
  19. 25 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. Storage Components • Nodes are called ‘Tablet Servers’ • Nodes are shared into blocks of contiguous rows called ‘tablets’ to help balance the load of queries • Tablets are stored on Colossus, Google's file system, in SSTable format • An SSTable provides a persistent, ordered immutable map from keys to values, where both keys and values are arbitrary byte strings • Importantly, data is never stored in Cloud Bigtable nodes themselves; each node has pointers to a set of tablets that are stored on Colossus. Google BigTable
  20. 26 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. Setting up Grails • Dependencies, Dependencies • Don’t underestimate library conflicts - google has packaged various grpc libs inside their jars making working with it very difficult • Use Google cloud libs + Apache HBase libs • BigTable Grails App • See https://github.com/grpc/grpc-java/blob/master/SECURITY.md#troubleshooting for a chart to help match library versions Google BigTable
  21. © 2018, Object Computing, Inc. (OCI). All rights reserved. Dependency

    Hell grpc-netty version netty-handler version netty-tcnative-boringssl-static version 1.0.0-1.0.1 4.1.3.Final 1.1.33.Fork19 1.0.2-1.0.3 4.1.6.Final 1.1.33.Fork23 1.1.x-1.3.x 4.1.8.Final 1.1.33.Fork26 1.4.x 4.1.11.Final 2.0.1.Final 1.5.x 4.1.12.Final 2.0.5.Final 1.6.x 4.1.14.Final 2.0.5.Final 1.7.x-1.8.x 4.1.16.Final 2.0.6.Final 1.9.x- 4.1.17.Final 2.0.7.Final
  22. 29 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. “Enterprise Level Message Oriented Middleware” • Typical Topic/Subscriber/Publisher Model • Supports either push or pull model • BigTable Grails App Google PubSub
  23. 32 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. Setup Topics on Console • Create topic • Grails App - create Subscriber (Cannot do from console) • Subscriber Demo • Runs in continuous polling thread • Publisher Demo Google PubSub
  24. 33 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. Overview • Google Cloud Pub/Sub is a publish/subscribe (Pub/Sub) service: a messaging service where the senders of messages are decoupled from the receivers of messages. There are several key concepts in a Pub/Sub service: • Message • Topic • Subscription • Publisher • Subscriber Google PubSub
  25. 35 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. Running projects cost money! • If you are using above 28 instance hours you will eat into your $300 credit • Unfortunately no ‘suspend’ or easy off like AWS :( • Delete project • Delete App Versions • Delete Cloud SQL Instances • Delete Cloud Storage Buckets Cleanup
  26. Thank You! • There is so much more you can

    do with Google Cloud. Get out there and make something Great! • Can use Cloud SQL, AppEngine, BigTable, and Pubsub • Thanks to Sergio and Matt for the Grails guide! For step by step instructions see http://guides.grails.org/grails-google-cloud/guide/index.html • Source for these demos available at https://github.com/rvanderwerf/grails-google-cloud/tree/grails-gr8-demos • Dependency troubleshooting at https://github.com/grpc/grpc-java/blob/master/SECURITY.md#troubleshooting • Thank you for attending! objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights reserved.
  27. objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights reserved.

    38 Subsequent Step Question Begin End Step 1 Step 2 Step 3 Subsequent Step No Yes SAMPLE FLOWCHART
  28. objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights reserved.

    39 Process Alternate Process Data Begin No Yes Terminator/ End Connector Shapes Lines Text Boxes Use Insert > Shapes > Flow Chart and Lines for additional shape and line options. Decision FLOWCHART ELEMENTS
  29. 40 objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights

    reserved. Hierarchy of text sizes, level 1 • Level • Level 3 • Level 4 Hierarchy of text sizes, level 1 • Level • Level 3 • Level 4 This is a title
  30. © 2018, Object Computing, Inc. (OCI). All rights reserved. The

    revolution is here NOW! 4.0 Cyber-Physical Transformation 1969 3.0 Computer Automation 1870 2.0 Mass Production 1784 1.0 Mechanization
  31. Highlighting Percentages and Other Stats Encourage innovation and time-to-market XX%

    STEP 1 Copy and paste Slide 30 and modify text as needed Or copy and paste the shapes to build a graphic that highlights percentages or other statistics TIPS Build a photo background, or set the layout to Photo Background (blue gradient) Headline text should be sized at 42-48 point Highlighted number should be sized at 30-33 point Neighboring text box should use text sized to 20-22 point, and should be centered under the circle
  32. EXTERNAL SHARING – FOOTER (LIGHT BACKGROUND) • Before sharing slides

    externally (online or printing), OCI copyright and branding should be added. • The footer shown below is formatted for slides with dark colored backgrounds. • Copy the footer from this slide and paste into on your slides before sharing the deck externally. objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights reserved.
  33. EXTERNAL SHARING – FOOTER (DARK BACKGROUND) • Before sharing slides

    externally (online or printing), OCI copyright and branding should be added. • The footer shown below is formatted for slides with dark colored backgrounds. • Copy the footer from this slide and paste into on your slides before sharing the deck externally. objectcomputing.com © 2018, Object Computing, Inc. (OCI). All rights reserved.