Using google appengine_final2

39
使使 Google AppEngine 使使使使使使使使 weibo.com/sagasw 2011-11

description

 

Transcript of Using google appengine_final2

Page 1: Using google appengine_final2

使用 Google AppEngine建立个人信息中心

weibo.com/sagasw2011-11

Page 2: Using google appengine_final2

编程对我而言,就是永远玩不腻的玩具

- sagasw

Page 3: Using google appengine_final2

Agenda

1 )云计算那些事儿 2 ) GoogleAppEngine 简介 3 ) GAE 搭建个人信息中心

Page 4: Using google appengine_final2

调查

1 ) Python 语言? 2 ) Google AppEngine ? 3 )云计算平台?

Page 5: Using google appengine_final2

1 )云计算那些事儿

 

Page 6: Using google appengine_final2

调查结果 - 公有云计算平台使用

Page 7: Using google appengine_final2
Page 8: Using google appengine_final2

http://addons.heroku.com/

Page 9: Using google appengine_final2

2 ) Google AppEngine 简介

 

Page 10: Using google appengine_final2

Google AppEngine云计算平台。支持 Go, Python, Java (JRuby, Rails etc.) ,有免费 Quota 。 优点:

o   UrlFetch,Memcache,TaskScheduleo XMPP,Mail,Crono   MapReduce,Channelo   支持 OAuth 认证或 Google 账号o   Image 处理 o   域名绑定o 易使用,易管理o 免费限额大方

缺点 : o 无全文搜索o 调整后的付费方案o 需要熟悉新 SQL 操作方式

Page 11: Using google appengine_final2

适用于:Wiki,CMS, 博客 , 微博 , 手机游戏后台 ,应用服务器 , 问答网站 , 电子书发布 ,SNS, 网店 , 工作流

不适合: 音频视频服务 , 大文件 , 密集计算

Google AppEngine 适用业务领域

Page 12: Using google appengine_final2
Page 13: Using google appengine_final2

GAE SDK 1.5.5 Changes (Latest 1.6.0)

• Python 2.7 支持• 支持多线程,可使用 threading• 支持并发请求• 支持更多 Python lib ( PIL v1.1.7 )• 前台请求的时间 30 秒增加到 60 秒, URLFetch 请求时间从 10 秒增加到 60 秒。

• TaskQueue 响应时间增加。

From Keakon's blog

Page 14: Using google appengine_final2

GAE 编程优化心得

• 尽量使用 MemCache• 组合 GoogleAppEngine & VPS • 通过 webservice 访问 VPS 数据库, GAE 缓存结果• 使用 google 或 VPS 搭建搜索功能• Nginx 反向代理 GAE (必须的)

  VPS seller and coupon         http://www.lowendbox.com/ 

  Install Debian, Nginx in VPS         http://www.howtoforge.com/ 

Page 15: Using google appengine_final2

Google AppEngine 后台管理

Page 16: Using google appengine_final2

免费 Quota 统计

Page 17: Using google appengine_final2
Page 18: Using google appengine_final2

3 ) GAE 建立个人信息中心

 

Page 19: Using google appengine_final2

GAE 可实现的服务• TwitterWeb 客户端,同步到新浪腾讯微博• RSS 聚合阅读• 获取网页,解析短网址• Cron Jobs• 在线个人笔记,在线个人博客• 网络小说阅读• 推送文章到 Kindle• 每日定时发送天气短信给自己或家人• 生日提醒(邮件,聊天工具,短信等)• 监控 iPhone 预订网页的内容变化 • 相册• Webproxy

Page 20: Using google appengine_final2

个人常用功能1 )选择现成代码修改( Doodle, V2EX )2 )同步发推到新浪微博功能,解析 t.co 短网址 3 )定期采集 RSS4 ) HackerNews 全文阅读5 )网页内容变化,通过短信提醒6 )支持 XMPP 协议( gtalk )客户端自动聊天7 )网络小说 web client8 )发送 Flickr 每日 interesting 图片到新浪微博

Page 21: Using google appengine_final2

同步到新浪微博  import mechanize  br = mechanize.Browser()  br.open("http://abcd.com/weibosdk/weibopost.php")  br.select_form(nr=0)  strform = status.encode('utf-8')  br.form['text'] = str  br.submit()

需要 VPS 上搭建微博 PHP SDK 作中转 或者使用 SinaAppEngine 作为中转

 

Page 22: Using google appengine_final2

https://gist.github.com/1298152

抓取网页 ( Webproxy )

Page 23: Using google appengine_final2
Page 24: Using google appengine_final2
Page 25: Using google appengine_final2
Page 26: Using google appengine_final2

推特简单客户端

Page 27: Using google appengine_final2
Page 28: Using google appengine_final2

https://gist.github.com/1312657

XMPP gtalk 聊天机器人

Page 29: Using google appengine_final2

网页内容监控,发送邮件( 139.com )

Page 30: Using google appengine_final2

示例一 Mobile01 阅读

• 分析网页内容• 设计抓取方式• HTML readability

– viewtext.org,

– www.instapaper.com/m?u=

– Readitlaterlist api

• 下载图片• 添加文章

Page 31: Using google appengine_final2
Page 32: Using google appengine_final2
Page 33: Using google appengine_final2
Page 34: Using google appengine_final2
Page 35: Using google appengine_final2

实例二 发送 flickr 图片到新浪微博

• Cron 任务采集 flickr 的 explore 图片• 访问图片网址,获取 favor 信息(确定是否 pos

t )• 建立 task ,投递到 taskqueue (使用 ETA )• 在 SAE 上搭建中转服务• Mechanize 模拟 form submit 访问 SAE

• Fix bug ,调整参数

Page 36: Using google appengine_final2
Page 37: Using google appengine_final2
Page 38: Using google appengine_final2

总结

• 好玩很重要• 云计算平台值得投入时间了解学习• 推荐使用 Python + Tornado

• 组合 WebService, API 进行 Mashup 设计思路

Page 39: Using google appengine_final2

Q & A