sudo ifconfig eth1 172.18.0.2 netmask 255.255.255.255 broadcast 172.18.0.2 mtu 1430 echo "1 rt1" | sudo tee -a /etc/iproute2/rt_tables sudo ip route add 172.18.0.1 src 172.18.0.2 dev eth1 table rt1 sudo ip route add default via 172.18.0.1 dev eth1 table rt1 sudo ip rule add from 172.18.0.2/32 table rt1 sudo ip rule add to 172.18.0.2/32 table rt1
第二网卡通网了之后,为什么第二网卡的 ip 只能访问 22 端口,80,443 之类的全都不通?请各位大神不吝赐教,急急急。
]]>再看看提示,说明了 3 月底就会停用所有未绑定账单(信用卡)的实例。
昨天花了一天时间修改代码搬迁到自己的 VPS 上,为自己以前省钱买单。
不想再用 GAE 这种太多特定 api 的托管平台了。
]]>Google Analytics(Google 分析)是 Google 的一款免费的网站分析服务,Google Analytics 功能非常强大,只要在网站的页面上加入一段代码,就可以提供丰富详尽的图表 式报告。并且显示人们如何找到和浏览相关网站以及如何改善访问者的体验。提高网站投 资回报率、增加转换,在网上获取更多收益。可对整个网站的访问者进行跟踪,并能持续 跟踪营销广告系列的效果,利用此信息将了解到哪些关键字真正起作用、哪些广告词最有 效,访问者在转换过程中从何处退出。自从其诞生以来,即广受好评。
活动时间:1 月 19 日 14:15-17:00
活动地点: 深圳市南山区中国地质大学产学研基地 2 楼 A208 科技寺
如果你满足以下其中之一的条件,欢迎你参加:
想利用工具提升网站转化效率的同学;
对 Google Analytics 工具感兴趣或想进阶学习的同学;
想要了解 Aftership 的同学;
注:
1.现场将进行 Coding 教学,有兴趣的小伙伴记得带上个人电脑,参与 Coding 环节将有机会获得主办方准备精美奖品;
2.现场将提供稳定的网络环境供用户体验;
活动流程:
14:00-14:15 签到 14:15-14:30 主持人开场 14:30-15:00 Fifty-five (智博)share GA and GTM features 15:00-15:30 AfterShip share our use case 15:30-15:45 Tea Break 15:45-16:30 Live coding and demo 16:30-17:00 Demo 点评及颁奖环节 17:00-17:00 自由交流时间
具体的出来了后将在活动行上进行发布。欢迎各位报名参加!
]]>是为了做视频配音。然后一句句去下载很麻烦嘛,就想搞个轮子。
自动识别多行文本,或者 excel,然后每段落单独下载为 mp3,这样比较方便。
目前是直接去摸了 gcloud 官方的 api 啦,传送门:
Quickstart: Using the Client Libraries | Cloud Text-to-Speech API | Google Cloud
现在全局开着飞机,但跑 sample.py 还是会 504 超时。(访问 google 或 youtube 或 g trans 都 ok 的)
想请问有没有人用过 google 这个接口?
或者有其它轮子也可以推荐一下
]]>Hi xxx, My name is Sarah and I ’ d like to personally connect with you about maximizing your trial and to understand any customer feedback you might have to share. I can also help connect you and your team with support or our developer communities if needed. If you're open to it, let me know a quick time to chat later this week or next, or you can book some time on my calendar directly here. Thanks, Sarah Barbour | Cloud Sales & Customer Growth | sbarbour@google.com | 404-400-8203 "Google Cloud, changing how people compute, not just where"
各位能帮我解释一下吗?
免费增值?要写反馈?
后端服务
后端服务
端点协议:HTTPS 已命名的端口: https 超时:30 秒 运行状况检查: https-kk 会话粘性:无 Cloud CDN:已停用
高级配置 实例组 地区 运行状况良好 自动调节 平衡模式 容量 instance-group-1 asia-east1-b 1 / 1 关闭 CPU 利用率上限:80% 100% 主机和路径规则
主机 路径 后端 所有不匹配的项(默认) 所有不匹配的项(默认) instance-2 前端
协议 IP:端口 证书 HTTP 135.10.167.69:80 — HTTPS 135.10.167.69:443 js-ca1
]]>Java8 只是开始:-)
]]>我弄了个 GCE
asia-northeast1-a 和 asia-east1-a
日本的 ping 在 100 左右 台湾在 60 左右(北方联通)
手贱把 asia-northeast1-a 删了重新建了一个悲剧发生了
第一次分配的 ip 是 104 开头的 延迟 100 左右……
第二次分配的就是 3x 开头的 ip 了……延迟直接 200+
重试了好多次都是这样了……看了下绕路美国了……怎么破
]]>谢谢
]]>比如,开了代理,想测试 ping facebook.com 的延迟情况,怎么测?
]]>心里只有一万个WTF,一万个草泥马。
GAE的Datastore收费方法简直令人恶心,一个App的开发过程中,想着怎么优化write/read Op,浪费的时间和精力,你定可以转换为很多创新点子...特别是对于一个不存在code review的个人App来说。
如果app自用且足够小,放到GAE上追求个稳定,还是可以接受的,但理由也仅限如此了...
本来是一个py3+Django写的小程序,跑在我的Linode JP VPS上。在优化扶墙的过程中,想将debian8换成debian7,然后想想为了未来省事,感觉把几个app移到gae上去吧,以后折腾vps也无所谓了。
软件成品在此,实现也很简单,每五分钟抓一些feed,然后jieba分词,然后推送消息...已经超免费配额了,大家随便看看就好,我不是职业写代码的,也就不敢开源出来献丑了。
CPU:600 Mhz, 内存:128 MB, 28个执行小时。
5万次数据库读作业,5万次写作业。
不支持Python3:处理中文,要花费大量时间在utf-8上。
不支持tempfile:很多库需要改造。
免费配额不支持socket:无法使用外部数据库。收费配额皆不可socket listen。
相比之下,其他的配额对应用的影响微不足道:Memcache是免费的。UrlFetch除非抓来的数据不做任何处理,Mail除非用来滥发邮件。
GAE的数据库额度存在3个关键:
keys_Only=True
可以随便用。user = User.query(User.username = "tom").first()
替换为
user = User.get_by_key_name("tom")
原方法会消耗1 Fetch Op + 1 Query Op = 2 read Op
,修改后,会产生1 Small Op + 1 read Op,而且这个read Op会被自动memcache。
比如一个表有,我想一次取出N条数据时,常规ORM的写法:
feeds = Feed.query().fetch(N)
每次查询,都会消耗1+N Read Op
,为了优化额度,可以修改成:
q = Feed.query() feeds = ndb.get_multi(q.fetch(N,keys_Only=True))
首次查询,消耗1 Small Op + N Read Op
,但是在重复查询是,则只消耗1 Small Op + m*N Read Op
,m是memcache未命中的概率,理想情况是0。
至于性能,可以参看这里,大概75%缓存命中是性能的分界线。
Memcache hit ratio: 100% (everything was in cache) Query for entities: 3755 ms Query/memcache/ndb: 3239 ms Keys-only query: 834 ms Memcache.get_multi: 2387 ms ndb.get_mutli: 0 ms Memcache hit ratio: 75% Query for entities: 3847 ms Query/memcache/ndb: 3928 ms Keys-only query: 859 ms Memcache.get_multi: 1564 ms ndb.get_mutli: 1491 ms Memcache hit ratio: 50% Query for entities: 3507 ms Query/memcache/ndb: 5170 ms Keys-only query: 825 ms Memcache.get_multi: 1061 ms ndb.get_mutli: 3168 ms Memcache hit ratio: 25% Query for entities: 3799 ms Query/memcache/ndb: 6335 ms Keys-only query: 835 ms Memcache.get_multi: 486 ms ndb.get_mutli: 4875 ms Memcache hit ratio: 0% (no memcache hits) Query for entities: 3828 ms Query/memcache/ndb: 8866 ms Keys-only query: 836 ms Memcache.get_multi: 13 ms ndb.get_mutli: 8012 ms
为所有不需要的被query()和order()的字段,使用indexed=False
当你插入一条数据时,每个索引字段都会产生write Op,特别当操作对象是ListProperty,会根据list的数量,倍数消耗写配额。
对于一些查询,有些和实际逻辑需求相左,但能大幅节约Op的手段。。
class EntryCollect(ndb.Model): apublished = ndb.DateTimeProperty() need_collect_word = ndb.BooleanProperty(default=True, indexed=False) key_word = ndb.StringProperty(repeated=True, indexed=False)
对于原先是in(List)的查询:
keys = EntryCollect.query().order(-EntryCollect.published) entrys = ndb.get_multi(keys.fetch(PER_PAGE*2, keys_Only=True)) new_entry = [] for entry in entrys: if keyword.decode('utf-8') in entry.key_word: new_entry.append(entry)
对于原先是list.IN(other_list)的查询:
keys = EntryCollect.query().order(-EntryCollect.published) entrys = ndb.get_multi(keys.fetch(PER_PAGE*2, keys_Only=True)) top_entry = [] for entry in entrys: if set(other_list).intersection(set(entry.key_word)): top_entry.append(entry)
对于原先是Boolean的字段:
keys = EntryCollect.query().order(-EntryCollect.published) entrys = ndb.get_multi(kesy.fetch(CONT*2, keys_Only=True)) for entry in entrys: if entry.need_collect_word: # do something
这里就有个权衡,如果read Op紧张,write Op富裕,那么就可以使用projected()。
将查询的参数作为key,取md5,查询的结果用json存储起来。
json_data = memcache.get('{}:XXXXXXX'.format(md5sum)) if json_data is None: # do something.... json_data = json.dumps(data) memcache.add('{}:Analyse'.format(md5sum), json_data, MEMCACHE_TIMEOUT)
一个App拆分成多个App,是最简单的,倍翻利用app engine的方法。
根据我自己的测试结果:
marshal取胜,而且处理utf-8更简便一些,但切记marshal不能用于两个不同版本的python之间序列化数据,不适用于开放的api。
如果使用json,要随时注意编码:
form_fields = { "something": self.request.get("something", default_value="").encode("utf-8"), } form_data = urllib.urlencode(form_fields) result = urlfetch.fetch(url=SOME_URL, payload=form_data, method=urlfetch.POST, follow_redirects=False, headers={'Content-Type': 'application/x-www-form-urlencoded'}) self.response.headers['Content-Type'] = 'application/json' self.response.out.write(result.content)
为节约网络延迟而浪费的cputime,使用异步urlfetch就十分重要。 官方手册在这里,例如:在抓取多个feed时:
q = Feed.query() results = ndb.get_multi(q.fetch(keys_Only=True)) rpcs = [] for f in results: rpc = urlfetch.create_rpc() urlfetch.make_fetch_call(rpc, f.url) rpcs.append(rpc) for rpc in rpcs: rpc.wait() result = rpc.get_result() d = feedparser.parse(result.content) for e in d['entries']: # do something....
以jieba词库为例:默认情况,jieba每次初始化,都会将本地词库dict.txt进行readline操作,生成字典,这个过程在GAE默认的CPU上需要将近6秒。先将这个字典在本地使用marshal.dump,在GAE中在load,初始化阶段则只消耗1.x秒。
try: with open(cache_file, 'rb') as cf: object_a, object_b = marshal.load(cf) except : for line in open(dict, 'rb').read().decode('utf-8').splitlines(): # do something.... with open(cache_file, 'wb') as cf: marshal.dump((object_a, object_b), cf)
能省则省,虽然memcache免费的,但还想省掉cpu怎么办?
self.response.headers['Cache-Control'] = 'public, max-age:300' self.response.headers['Pragma'] = 'Public'
节约数据库存储空间最简单的方法,就是删掉过时的数据,而对于ndb,不存在Object.query().del() 这样的方法,需要使用:
earliest = datetime.datetime.now() - datetime.timedelta(days=10) keys = EntryCollect.query(EntryCollect.published <= earliest).fetch(keys_Only=True) ndb.delete_multi(keys)
减少搜索引擎对app的负载,不失为一个办法,一个个位数pv的app,被bot拖到配额超限真的好23333...
然后?然后就没有然后了...
我用一个周末django写的app,用了2个周末迁移到gae上,跟配额,特别是Datastore write/read Op奋斗了2个星期,经验写出来,希望同样蛋痛的V友们少走弯路。
本人不是职业程序员,金融从业者,希望少拍代码砖=.=
]]>失败
。我执行过的详细步骤如下: 新建文件夹helloworld
在文件夹内新建helloworld.py,内容如下:
import webapp2 class MainPage(webapp2.RequestHandler): def get(self): self.response.headers['Content-Type'] = 'text/plain' self.response.write('Hello, World!') app = webapp2.WSGIApplication([ ('/', MainPage), ], debug=True)
在文件夹内新建app.yaml文件,内容如下:
version: 1
runtime: python27
api_version: 1
threadsafe: truehandlers:
- url: /.*
script: helloworld.app
在GAE客户端选择加载helloworld文件夹,并且run这个项目,在浏览器里可以看到一行hello world。
这个步骤我没问题。
在GAE console里新建一个项目。将项目ID加入app.yaml文件的首行。
在GAE客户端选择deploy,将项目部进行部署。
我就是失败在这一步,部署失败。log文件显示内容如下:
*** Running appcfg.py with the following flags:
--oauth2_credential_file=~/.appcfg_oauth2_tokens updateNo previously stored oauth2 token found.
A browser will be opened to ask for user permission.07:34 AM Application: my-first-app-967; version: 1
07:34 AM Host: appengine.google.com
07:34 AM
Starting update of app: my-first-app-967, version: 1
07:34 AM Getting current resource limits.
使用命令行进行部署
appcfg.py update my_project_folder
失败。命令行提示同样的错误。
重启电脑,重装GAE客户端
失败。仍然是同样的错误。
增加Extra Flag
--noauth_local_webserver
失败。不仅deploy失败,locally run都失败了。
实在是搞不懂了,挫败感。希望大家忙帮。
]]>