jcconf 2015 - 輕鬆學google的雲端開發 - google app engine入門(下)

61
輕鬆學Google的雲端開發 - Google App Engine入門 Simon Su & Sunny Hu JCConf 2015 http://goo.gl/VoMoU7

Upload: simon-su

Post on 12-Jan-2017

708 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

輕鬆學Google的雲端開發 - Google App Engine入門

Simon Su & Sunny HuJCConf 2015

http://goo.gl/VoMoU7

Page 2: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

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入門(下)

Cloud Logging

Page 4: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

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入門(下)

Cloud Monitor Integrate

Page 6: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

Cloud Debugging

Page 7: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)
Page 8: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

Cloud Debugging

● Push to Deploy

● Runtime tracking and

debugging

● Performance tuning

Page 9: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)
Page 10: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

Cloud Traces

Page 11: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)
Page 12: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)
Page 13: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

Security Scan

Page 14: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)
Page 15: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)
Page 16: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

Push to Deploy

Page 17: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)
Page 18: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

Architectures inside GAEModules & Managed VM

Page 19: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

GAE Modules

Page 20: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

● 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 22: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

GAE Managed VM

Page 23: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

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入門(下)
Page 25: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

Managed VM

Page 26: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

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入門(下)

MVM - Standard Runtime

Page 29: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

Standard Runtime

Page 30: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

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入門(下)

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入門(下)

Node.js Standard MVM Runtime

Page 33: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

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入門(下)

Deploy your App Engine project to MVM Standard Runtime

Page 35: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

MVM - Custom Runtime

Page 36: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

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入門(下)

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入門(下)

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入門(下)

Local Test

$ dev_appserver.py <app.yaml>

Page 40: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

Deployment

$ gcloud preview app deploy <file...>

Page 41: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

if Node.js...

Page 42: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

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入門(下)

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入門(下)

Local Test

$ npm start

Page 45: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

Deploy to Server

$ gcloud preview app deploy app.yaml

Page 46: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

Check Server Running Status

Page 47: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

● Special maintain● Debug● Testing

Switch to User Managed Mode...

Page 48: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

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入門(下)

Answer: https://github.com/gcpug-tw/mvm-nodejs-

webcapture

Page 50: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

Cloud Endpoint

Page 51: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

What’s Cloud Endpoint?

Page 52: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

Benefit of Cloud Endpoint

Page 53: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

Development with Cloud Endpoint

Page 54: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

GAE Architecture in Advance

Page 55: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

Inside GAE

Page 56: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

[Web Application]

Page 57: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

[Real Time Bidding]

Page 58: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

[Mobile Apps and Games]

Page 59: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

[Real Time Stream Processing - Internet of Things]

Page 60: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

Where is your Architecture?Let’s discuss in GCPUG.TW~

Page 61: JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(下)

Q & A