// August 27th, 2009 // No Comments » // Ruby
上一篇的sinatra应用部署在了heroku上。经过几天的试用有几点体会
1. Heroku是架构在Amazon EC2上的,具有不错的扩展性,只要你有钱,拖拉一下鼠标就能实现scaling了。这一点着实很方便。当然代价是价格会比EC2高,毕竟人家提供了增值服务嘛。具体高多少很难比较,连heroku的老板都说对应关系很复杂。基本上要是网站做大了,用heroku就不合算了。
2. 不烧包的就用heroku的free配置,只有一个dyno的,5M存储空间,可以支持绑定自己的域名。
3. 近期遭遇了几次request time out,因此查了一下heroku doc,dyno基本上把它看成一个线程吧,换句话说,这个一个dyno的free版只能支持并发度为1的压力。因此并发连接多的化,你会经常看到time out的。计算容量也是比较寒酸,用ab -n 10 url测一下,10个请求4个fail掉了orz. 看来免费的午餐也不好用啊。大家用来做原型demo就好了,验证好了自己找地方去deploy也挺好。
update:不知道是这次测试当时受海底光缆受损的影响还是其他原因导致结果很差,后来新的测试比较正常,后面我贴了一个新的benchmarking的测试结果。free的计划还是可以承受一些负载压力的。特此给heroku正名
4. heroku提供了deploy代码的好方案,但在DB方面限于技术原因,还比较薄弱,mysql什么的还是用不起来。
5. google map API是跟域名相关的,如果没有自己的域名的话,部署到xxxx.heroku.com这种子域名下面是不能用的,想必早有人在heroku下面申请了key, 后来者都会遇到冲突。花钱买自己域名吧
6. Heroku的想法不错,这也难怪他们会积攒了数万用户,也得到了300万美元的投资。云计算,不再是一个概念了,已经有若干成熟的方案面向消费者了。这一点要向先行者amazon致敬
7,最后一点就是heroku的支持做的不怎么样,文档也很不完整。遇到问题还是要自己摸索解决。
add-on: AB benchmarking result:做了两个测试,一个是简单到极致的逻辑,另一个相反,是复杂到极致的逻辑,看看两个边界状况的对比和共性应该更能说明问题:case1表现不错(里面就两行code当然不错了,呵呵),case2太复杂了,failed了88个(一共100个请求,FT).
case1: light code:
localhost:sinatra tony$ ab -n 100 -c 10 http://ip2loc.dazhe.me/counter/
This is ApacheBench, Version 2.3 < $Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking ip2loc.dazhe.me (be patient)…..done
Server Software: nginx/0.6.38
Server Hostname: ip2loc.dazhe.me
Server Port: 80
Document Path: /counter/
Document Length: 15 bytes
Concurrency Level: 10
Time taken for tests: 7.828 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Non-2xx responses: 100
Total transferred: 26200 bytes
HTML transferred: 1500 bytes
Requests per second: 12.77 [#/sec] (mean)
Time per request: 782.820 [ms] (mean)
Time per request: 78.282 [ms] (mean, across all concurrent requests)
Transfer rate: 3.27 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 309 389 192.2 317 1233
Processing: 316 378 272.2 337 3050
Waiting: 314 377 272.3 335 3050
Total: 627 767 332.5 661 3370
Percentage of the requests served within a certain time (ms)
50% 661
66% 677
75% 705
80% 815
90% 1017
95% 1543
98% 1570
99% 3370
100% 3370 (longest request)
case2: heavy code:
localhost:sinatra tony$ ab -n 100 -c 10 http://ip2loc.dazhe.me/
This is ApacheBench, Version 2.3 < $Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking ip2loc.dazhe.me (be patient)…..done
Server Software: nginx/0.6.38
Server Hostname: ip2loc.dazhe.me
Server Port: 80
Document Path: /
Document Length: 696 bytes
Concurrency Level: 10
Time taken for tests: 24.932 seconds
Complete requests: 100
Failed requests: 88
(Connect: 0, Receive: 0, Length: 88, Exceptions: 0)
Write errors: 0
Non-2xx responses: 88
Total transferred: 36676 bytes
HTML transferred: 10992 bytes
Requests per second: 4.01 [#/sec] (mean)
Time per request: 2493.243 [ms] (mean)
Time per request: 249.324 [ms] (mean, across all concurrent requests)
Transfer rate: 1.44 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 310 328 28.1 316 410
Processing: 614 2067 790.9 1961 3904
Waiting: 613 2066 790.9 1960 3903
Total: 977 2395 788.1 2370 4214
Percentage of the requests served within a certain time (ms)
50% 2370
66% 2645
75% 2888
80% 3086
90% 3569
95% 4036
98% 4177
99% 4214
100% 4214 (longest request)