Google App Engine

1,637 views

Published on

Google adp

Published in: Technology

Google App Engine

  1. 1. Google App Engine Ensky
  2. 2. Outline - Today• GAE Introduction• GAE Hello world• Python• WebApp2 – A python-based Web development framework
  3. 3. Outline• Cloud(IaaS, PaaS, SaaS)• Google App Engine – Some features• NoSQL• Storage of GAE - Datastore
  4. 4. Cloud• Cloud 三兄弟 – IaaS (Infrastructure as a Service) – PaaS (Platform as a Service) – SaaS (Software as a Service)
  5. 5. Cloud 三兄弟• IaaS (Infrastructure as a Service) 直接給你虛擬主機用 優:很彈性,你想安裝任何軟體、採用任何架構 都很容易 缺:要管理主機、處理一大堆問題 (ex: 駭客攻擊、版本升級等等)• amazon AT&T HP• hinet 台灣大 遠傳
  6. 6. Cloud 三兄弟• PaaS (Platform as a Service) 規定你APP要怎麼寫,簡化你管理主機的步驟 有些工具的賣點是自動幫你處理擴充問題 優:管理方便,只需要focus在app開發 缺:寫法、使用工具、環境受到限制• Google app engine• Microsoft Azure
  7. 7. Cloud 三兄弟• SaaS (Software as a Service) 善用別人寫好的web app• Gmail, Google calendar, Facebook, …
  8. 8. Outline• Cloud(IaaS, PaaS, SaaS)• Google App Engine – Some features• NoSQL• Storage of GAE - Datastore
  9. 9. Google Cloud• Google cloud包含了四大部份,分別解決不同問題 – Google App Engine • Build your apps and websites on Google’s infrastructure with Google App Engine. – Google Compute Engine • Run Linux Virtual Machines in the cloud using Google Compute Engine (Limited Preview). – Google Cloud Storage • Store, access and manage your data on Google’s storage infrastructure. – Google BigQuery • Analyze Big Data in the cloud using SQL and get real-time business insights in seconds using Google BigQuery.
  10. 10. GAEIt’s PaaS• Features – Focus on Web service – 規模自動擴張 – 安全性 – 效能 – 支援Python and Java (and Go) – 完整的SDK
  11. 11. 安全 or 限制 ? – Sandbox• 對外的連線只能是HTTP / HTTPS的protocol 若要對外作任何操作都要透過HTTP 也不能作「listen某個port」的操作• 不能對file system作任何寫入操作(可以讀取) 你只能用Google提供的GAE datastore或其他服務• 不能fork一個process來用,也不能在連線結束之後執行別 的程式• 執行時間限制60秒以內要完成
  12. 12. Some useful features• DataStore – NoSQL schemaless object datastore• BlobStore – Let you store "Binary large object" (blob)• Memcache – Fast Caching server• URL Fetch – Get data from HTTP/HTTPS• Mail – Just a Mail sender• Images – Image Processing, like resize, rotate• User – Supply Google account login• Task Queue – Send heavy load job to queue• Cronjob – Schedule a job…. and more
  13. 13. Storage• GAE provide two major Storage engine, for difference usage. – App Engine Datastore • NoSQL schemaless object datastore – App Engine Blobstore • to store blob data
  14. 14. Not only SQL• Relational DB focus on relation – User • id, username, password, email, … – Comment • id, user_id, title, content, …
  15. 15. Not only SQL• NoSQL focus on scalability, speed, or something else. – document-oriented 沒有任何的schema, 適合存document • MongoDB – key-value database 只有key-value的形式, focus on speed, scalability • Redis, memcached
  16. 16. Not only SQL– Distributed database focus on distribution on servers • HBase, cassandra, …
  17. 17. Outline• Cloud(IaaS, PaaS, SaaS)• Google App Engine – Some features• NoSQL• Storage of GAE - Datastore
  18. 18. Entity - GAE Datastore• 一個帳號可以開很多個datastore• 一個Datastore可以有很多Entity ex: User 這個datastore可以有很多筆資料• 一個Entity可以有很多屬性(properties) – ensky, enskylin@gmail.com – lalala, lalala@gmail.com
  19. 19. Key – GAE Datastore• 每一筆entity都會有一個unique key – 就很像SQL的Primary key一樣• 可以不設讓系統自動產生; 也可以自己設定• 刪除操作是用key來判斷
  20. 20. Types - GAE DatastoreProperty in PythonStringProperty str unicodeBooleanProperty boolIntegerProperty intFloatProperty floatDateTimeProperty datetime.datetimeListProperty listBlobProperty db.BlobTextProperty db.Text
  21. 21. Using Datastore• Create a model – 定義了該 datastore 的屬性有哪些• Use it like a ORM 資料皆為物件,對物件操作就是對資料操作 – Insert:新增一個物件,最後呼叫.put()方法儲存 – Update:先query出你想要修改的物件,直接修改該物 件,最後呼叫.put()方法儲存 – Delete:先query出你想要刪除的物件,直接呼 叫.delete()方法刪除之
  22. 22. Create – GAE Datastore
  23. 23. Get, Update, Delete – GAE Datastore
  24. 24. Reference• https://developers.google.com/appengine/

×