jcconf 2015 - 輕鬆學google的雲端開發 - google app engine入門(下)
TRANSCRIPT
![Page 1: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/1.jpg)
輕鬆學Google的雲端開發 - Google App Engine入門
Simon Su & Sunny HuJCConf 2015
http://goo.gl/VoMoU7
![Page 2: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/2.jpg)
Google App Engine also DevOps enabled
- Cloud Logging
- Cloud Debug
- Cloud Tracing
- Security Scan
- Push to Deploy
![Page 3: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/3.jpg)
Cloud Logging
![Page 4: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/4.jpg)
Cloud Logging Features● View platform logs
● Export logs to BigQuery,
GCS, Pub/Sub
● 3rd party log integrate
![Page 5: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/5.jpg)
Cloud Monitor Integrate
![Page 6: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/6.jpg)
Cloud Debugging
![Page 7: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/7.jpg)
![Page 8: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/8.jpg)
Cloud Debugging
● Push to Deploy
● Runtime tracking and
debugging
● Performance tuning
![Page 9: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/9.jpg)
![Page 10: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/10.jpg)
Cloud Traces
![Page 11: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/11.jpg)
![Page 12: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/12.jpg)
![Page 13: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/13.jpg)
Security Scan
![Page 14: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/14.jpg)
![Page 15: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/15.jpg)
![Page 16: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/16.jpg)
Push to Deploy
![Page 17: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/17.jpg)
![Page 18: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/18.jpg)
Architectures inside GAEModules & Managed VM
![Page 19: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/19.jpg)
GAE Modules
![Page 20: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/20.jpg)
● Frontend instance (not App Engine Front End)○ Dynamically created and deleted = low cost○ Enforce fast response and stateless design○ Suitable for processing short-lived requests
● Backend instance○ Statically created and deleted = higher cost○ No limit for response time, supports stateful design○ Suitable for batch processing
Frontend Instance vs. Backend Instance
![Page 21: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/21.jpg)
Modulesdispatch.yaml
Module doc: https://cloud.google.com/appengine/docs/java/modules/https://cloud.google.com/appengine/docs/java/modules/converting
![Page 22: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/22.jpg)
GAE Managed VM
![Page 23: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/23.jpg)
Choice..
IaaSRaw compute
Granular control
PaaSPreset run-times
Focus is app logic
ClustersData centre as computerDeclarative management
Managed VMs Beta
Bring your own runtime Health-checked VMs
AgilityNoOps
ConfigurabilityDevOps
Compute Engine App EngineContainer Engine Cloud Endpoints
![Page 24: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/24.jpg)
![Page 25: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/25.jpg)
Managed VM
![Page 26: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/26.jpg)
From: https://cloud.google.com/appengine/docs/managed-vms/#standard_runtimes
Feature Standard Runtime Custom Runtime
Dockerfile Default file supplied automatically by the SDK Hand-written by the developer
Dockerfile modifications permitted
Yes Yes
Languages Python, Java, and Go Any software that can service HTTP requests
Configuration file Python and Go modules use app.yaml, Java modules use WAR and appengine-web.xml
app.yaml
Start/Stop Request Requests are handled automatically by default. You may optionally write your own handlers.
Your app will receive these requests but does not need to respond to them. You may optionally write your own handlers.
Health Checking Requests are handled automatically by default. You may optionally write your own handlers.
You must write your own handlers or disable health checks.
App Engine Service APIs
Some API support is baked in. Read thePython, Java, or Go page for each runtime.
You must use the publicly available REST APIs for cloud services.
![Page 27: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/27.jpg)
MVM - Standard Runtime
![Page 28: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/28.jpg)
Standard Runtime
● Datastore● Logging● Memcache● Search● Task Queue● URL Fetch● Users
![Page 29: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/29.jpg)
Standard Runtime
![Page 30: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/30.jpg)
Configure MVM Scaling
<manual-scaling>
<instances>1</instances>
</manual-scaling>
<automatic-scaling>
<min-num-instances>2</min-num-instances>
<max-num-instances>20</max-num-instances>
<cool-down-period-sec>60</cool-down-period-sec>
<cpu-utilization>
<target-utilization>0.5</target-utilization>
</cpu-utilization>
</automatic-scaling>
![Page 31: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/31.jpg)
Resource Setting
<resources>
<cpu>.5</cpu>
<memory-gb>1.3</memory-gb>
<disk-size-gb>10</disk-size-gb>
</resources>
![Page 32: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/32.jpg)
Node.js Standard MVM Runtime
![Page 33: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/33.jpg)
Example - Node.js
$ express web
$ cd web && npm install
$ vi app.yaml runtime: nodejs
vm: true
$ gcloud preview app deploy app.yaml
![Page 34: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/34.jpg)
Deploy your App Engine project to MVM Standard Runtime
![Page 35: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/35.jpg)
MVM - Custom Runtime
![Page 36: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/36.jpg)
Dockerfile
app.yaml
$ dev_appengine.py app.yaml
$ gcloud preview app deploy app.yaml
gcloud SDK
Docker registry
container
dockerd
VM*
* A VM running docker
![Page 37: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/37.jpg)
gcloud deploy
gcloud build
Your awesome docker images
your laptop
Google App Engine
Your awesome docker images
docker container
private Google Cloud Storage
bucket
update start Google Compute Engine Instance
usinggoogle/docker-registry
container
docker run
usinggoogle/docker-registry
container
docker push
docker pull
Behind the scenes
![Page 38: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/38.jpg)
Example - Nginx
Step 1:git clone https://github.com/GoogleCloudPlatform/appengine-nginx-hello
Step 2:FROM nginxCOPY nginx.conf /etc/nginx/nginx.confCOPY ok /usr/share/nginx/www/_ah/startCOPY ok /usr/share/nginx/www/_ah/healthADD www/ /usr/share/nginx/www/
From: https://github.com/GoogleCloudPlatform/appengine-nginx-hello
![Page 39: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/39.jpg)
Local Test
$ dev_appserver.py <app.yaml>
![Page 40: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/40.jpg)
Deployment
$ gcloud preview app deploy <file...>
![Page 41: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/41.jpg)
if Node.js...
![Page 42: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/42.jpg)
Example - Node.js
$ mkdir myproject && cd myproject
$ express web
$ cd web && npm install
$ cd .. && vi app.yaml runtime: custom
vm: true
![Page 43: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/43.jpg)
Example - Dockerfile
FROM google/debian:wheezy
RUN apt-get update -y && apt-get install --no-install-recommends -y -q curl python build-essential git ca-certificates libfreetype6 libfontconfig1
RUN mkdir /nodejs && curl http://nodejs.org/dist/v0.12.1/node-v0.12.1-linux-x64.tar.gz | tar xvzf - -C /nodejs --strip-components=1
ENV PATH $PATH:/nodejs/bin
WORKDIR /app
ADD web/ /app/
RUN npm install
ENTRYPOINT ["/nodejs/bin/npm", "start"]
![Page 44: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/44.jpg)
Local Test
$ npm start
![Page 45: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/45.jpg)
Deploy to Server
$ gcloud preview app deploy app.yaml
![Page 46: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/46.jpg)
Check Server Running Status
![Page 47: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/47.jpg)
● Special maintain● Debug● Testing
Switch to User Managed Mode...
![Page 48: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/48.jpg)
PhantomJS is a easy module for create screenshot, please reference the link:
“http://phantomjs.org/screen-capture.html”
to create a url screenshot api and deploy to Google App Engine Managed VM
![Page 49: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/49.jpg)
Answer: https://github.com/gcpug-tw/mvm-nodejs-
webcapture
![Page 50: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/50.jpg)
Cloud Endpoint
![Page 51: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/51.jpg)
What’s Cloud Endpoint?
![Page 52: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/52.jpg)
Benefit of Cloud Endpoint
![Page 53: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/53.jpg)
Development with Cloud Endpoint
![Page 54: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/54.jpg)
GAE Architecture in Advance
![Page 55: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/55.jpg)
Inside GAE
![Page 56: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/56.jpg)
[Web Application]
![Page 57: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/57.jpg)
[Real Time Bidding]
![Page 58: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/58.jpg)
[Mobile Apps and Games]
![Page 59: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/59.jpg)
[Real Time Stream Processing - Internet of Things]
![Page 60: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/60.jpg)
Where is your Architecture?Let’s discuss in GCPUG.TW~
![Page 61: JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(下)](https://reader035.vdocuments.mx/reader035/viewer/2022082211/5877a93f1a28ab826e8b68fb/html5/thumbnails/61.jpg)
Q & A