Archive for the ‘feedlr’ Category

Temporarily suspending feedlr for an overhaul

Sunday, April 12th, 2009

As some of you may have noticed, feedlr has the problem of sporadically repeating posts and it’s been happening more often recently. This bug is due to some mysterious errors that somehow skip my try/catch blocks and throw tons of stacktraces in the logs. Also due to the problem of there being too much noise in the logs from Grails and the lack of spare time I have lately, it’s been quite a pain for me to track down and eradicate this problem. And I feel very sorry for the users who have suffered from repeated posts.

The current implementation of feedlr is a result of the resource limitations of the server where it’s hosted, which is an everlasting problem for the Grails service. So I’ve always wanted to thoroughly refactor the code and find a better hosting service. With the problem of repeated posts aggravating, I’ve decided to temporarily suspend the current feedlr service while I migrate the whole site to Google App Engine, which means a rewrite of the existing code in Python.

This complete refactory (or rather, rewrite) won’t be completed very soon but I’ll make it happen as soon as I can. Meanwhile, I’ll keep this blog updated. Thank you very much for using feedlr and let’s meet again later on Google App Engine!

由于近期feedlr重复播发消息的问题变得严重,彻底重构feedlr的需求变得越来越紧迫。feedlr的实现是对于目前使用的服务器上有限资源的妥协的结果,随着feedlr支持的feed数量越来越多,服务器性能显得越来越突出。而由于近来我的时间非常有限,还有Grails在日志方面的过多噪音,我很难马上彻底解决重复播发消息的问题。对重复播发给大家造成的麻烦我深表歉意!

于是我现在决定暂时停止目前版本的feedlr服务,花一些时间把feedlr移植到Google App Engine上,彻底解决可扩展性的问题。由于需要用Python重写整个服务,需要花一定的时间。具体需要多久我也说不准,只能利用有限的时间尽快完成,请各位关注本blog,有更新会在这里发布的。在此对所有feedlr用户表示诚心的感谢,让我们在Google App Engine上再见!

feedlr的2008

Thursday, December 18th, 2008

08年初,我在开发feedlr的时候,就只是想做一个对人们有用而且好用的工具。虽然我是个程序员,但是我向来热爱设计,精巧而优美的事物总是最能吸引我(天秤座?)。其实如果我在中学没有读理科班,到现在很可能是个设计师,因为在那个时候我就非常对设计方面非常感兴趣。有点扯远了:)

我对自己的作品一直是很挑剔的,我为feedlr设定的标准很简单,要让我自己爱用它。那么feedlr做到了吗?我觉得80%做到了吧。自从feedlr上线开放以来,我自己就一直订阅着好几个feedlr驱动的微博机器人,每天可以直接在im上快速阅览我感兴趣的新闻,用了feedlr机器人确实大大提高了我的feed阅读速度。

feedlr的定位本身就决定了它只可能在略geek的群体中传播,但是看着每天新增的feed机器人,我感到非常欣慰。刚开始,feedlr上线的只有英文版。大家可能觉得奇怪,还有人问过我是不是中国人。其实,虽然我从小在上海长大,但是我确实一直对中文互联网没多大兴趣和接触。因为我英文还不错,在上个世纪末通过14.4k modem接触网络的时候,网上的中文内容还非常贫乏,所以我从一开始就是喜欢浏览英文内容。而且对一个标准geek来说,也确实在英文互联网上有多得多的吸引的内容。中文世界呢?新浪?网易?还有百度?我都几乎从来不上。看着这些弹出窗口花花绿绿满屏的广告毫无设计可言的页面就烦。中文互联网是不属于geek的。

我这么说可能很有争议。我在之前对中文互联网最多的接触,还是在兼职solidot.org的主编的那段时间。但自从feedlr项目起深入接触中文互联网,认识了很多朋友,却更巩固了我这样的认识:中文互联网也不缺少才华横溢的geek,但是统治这个江湖的却是一批中年商人。这只是一个商业世界的延伸,而不是一个容得下创新和geek精神的地方。人们谈论和崇拜的是马云,而不是戴志康。叽歪是我一年多来用得最多的国内web2.0服务,创始人李卓桓也是我很敬佩的一位朋友。但在csdn英雄会上,大家争相握手献媚的却是垃圾网站51.com的庞升东,那位号称只找60年代人合伙的商人。

没错,不管是不是做互联网,business的目的总是赚钱。但其实,就像Paul Graham说的那样,我们想要的其实是财富,而不是钞票。那么,在一个理性的世界,你创造出了人们想要的东西,就是创造了财富。所以,你应该努力做到的,是不断创造出人们想要的,有用的东西来。而不是挖空心思想着怎么从无辜的人兜里抢钱。这个世界也不能离开商人,但是真正创造财富的,是创造商品的人,而不是把商品卖到不可思议的高价的人。更重视前者的社会,才是一个理性的值得尊敬的社会,也是一个有持续发展动力的社会。因为这样,这个社会里的人才会整天想着怎么做出更棒的产品,而不是做梦都想明天怎么去忽悠下一个客户或者投资人。当人们崇拜的是钞票而不是财富时,这个社会就失去了创新的动力。

而我们的互联网,其实和整个社会一样,是个浮躁浅薄的地方。只要这样的状态不改变,这里不会真正有中国的google,中国的facebook,当然也不会有中国的TechCrunch,更不可能出现Y Combinator。有的只能是C2C(Copy To China),只能是忽悠了钱走人的MBA,还有拿个ecshop几分钟搭个网店就认为是互联网创业的青年。

一不小心就说了那么长一通,其实我打算写这篇文章是想感谢一下分享web2.0的盗盗同学,把feedlr提名为“2008 最值得关注的15个 China Web2.0 Startup”。和那些我很喜欢和尊敬的web2.0项目摆在一起,其实颇不好意思。话说我差不多也有半年没有改进feedlr了。我希望的只是feedlr能继续对人们有用。在feedlr之后的时间里,我其实放弃了一些hardcore geek的想法,认真尝试了中文互联网创业的方式,为钱做过了妥协,圈了几十万的用户,也有日pv一百几十万的成果。但是在2008年即将过去的时候回头看看,还是feedlr为我带来了最多的快乐。

一个人能有一些值得坚持的原则是应该珍惜的,所以我想,在即将到来的新的一年,不管金融危机怎么恶化,不管“业界”热点转成抄袭哪个另外的国外网站,我还是会照着自己的原则做事,做出更多对人们有用的东西来。feedlr也会继续办下去的,因为至少,我还需要用它来每天快速接收新闻呢!另外,我也可能比较彻底的改写一下feedlr,让它变的更有用。

如果你喜欢和支持feedlr,现在可以通过文章底下的tipjoy来方便的支付一小笔零钱了。

新服务器:Linode和Nginx

Wednesday, June 4th, 2008

Feedlr搬到新服务器了!

Feedlr经过一段时间的改进,程序性能已经比刚开始优化了不少。而另一个反映相对较多的问题是访问速度。原先的服务器由于无法克服的客观原因从大陆某些地区访问速度不理想。新服务器由Linode提供,位于美国加州,连接速度更理想。于是经过最近的一些准备,今天Feedlr正式搬迁到新服务器。

另外,除了硬件服务器,现在Feedlr的web前端服务器也从Apache换到了Nginx。轻量高效的Nginx比Apache更节省服务器资源,也为Feedlr性能的提高提供了支援。

Feedlr一直进行着这样一些表面上不易察觉的改进,希望能继续给大家提供一个稳定好用的服务。

新增功能:关键词过滤播发

Saturday, May 24th, 2008

今天Feedlr的关键词过滤功能面世了。现在起可以给Feed指定一系列关键词,这样在播发新闻的时候,只有匹配到了关键词的内容才会播到微博客机器人帐号上。在新建Feed或者编辑Feed页面上,在关键词过滤一项填上用空格或逗号分隔的关键词就行了。在这一项为空白的时候就不会进行过滤。

另外,还可以选择匹配全部关键词还是任何关键词。比如有关键词“苹果”和“电脑”。默认的匹配方式是匹配任一关键词,那么只要新闻标题或内容里提到了“苹果”或者“电脑”就会播出去,如果有关于苹果丰收的新闻也能播出去。而如果选择了全部匹配,那么只有同时提到了“苹果”和“电脑”的新闻才会播出去,有时候这才是你想要的结果:)

keywords

利用关键词过滤,我建立了一个“中国地震监测”机器人:http://jiwai.de/中国地震监测 利用USGS的地震监测Feed,过滤关键词“China”,就能把发生在中国的地震过滤出来了。

除此以外,关键词过滤还可以用在从不能分类的综合新闻Feed里筛选感兴趣的内容,建立特定主题的机器人。比如“cnbeta Linux新闻”等等,就等着你去自由发挥了~

增强的feed解析能力

Thursday, May 22nd, 2008

有用户反映过,有些feed在feedlr无法正常解析,feedlr对一些feed的容错能力不高。

现在,feedlr能利用Google新近开放的Ajax Feed REST API来作为备用的后台feed解析工具了。如果feed解析出现错误,就会自动调用Google API来再次尝试,这样就提高了feed解析的容错能力。而Google Ajax Feed API就是Google Reader使用的解析器,所以feedlr现在能做到Google Reader能正常访问的feed就能正常解析。

如果大家发现feed解析方面还有什么问题,请通过留言版告诉我,谢谢!

另外,这次更新还修正了标签功能的一些bug并进行了一些改进。标签输入的时候现在可以用包括全角和半角的空格以及逗号来分隔了。之前分隔有问题的一些标签也全部整理了一下。

Feedlr支持做啥微博客,并即将支持OAuth认证

Tuesday, May 6th, 2008

大家可能已经发现,在新建和编辑Feed的时候,可以选择微博客服务为做啥了。没错,Feedlr开始支持广播到做啥了。使用方式和其他支持的服务一样。而且类似叽歪,在做啥,你也可以通过播发完整链接(选择不使用TinyURL转换),来在网页上直接内嵌多媒体内容。目前由于API的差别,暂时无法在Feedlr显示做啥帐号关注者人数和总消息数。

另外,Feedlr即将支持最新的OAuth认证方式。OAuth是一种开放的API安全认证标准,通过OAuth,大家就不必在Feedlr提供微博客帐号的用户名和密码,也能建立广播机器人了,这样能最大程度地保证用户账户的安全性。目前叽歪已经开始支持OAuth,Twitter也有非正式的支持,正式支持应该也快了。Feedlr将首先支持叽歪的OAuth认证。

Feedlr支持OpenID登录了

Friday, May 2nd, 2008

今天起,Feedlr开始支持(先进的,时髦的)OpenID登录方式了!大家快来试试吧。

普及篇

什么是OpenID?访问OpenID主页就可以看到详细介绍。简单的讲,OpenID就是“一个以用户为中心的数字身份识别框架”。对用户来讲,可以用唯一的OpenID来登录任何支持OpenID的网站。这样一来就不用在不同的网站重复注册,记住一堆用户名,密码了。

这里有一段很有意思的视频,为大家通俗地解释OpenID的概念(英文)。

使用篇

那么,在Feedlr怎么使用OpenID呢?有两种方式。

如果你已经注册过一个帐号了,那么

  1. 以普通方式(email地址加密码)登录你的帐号
  2. 在“我的帐号”页面上点“绑定OpenID”按钮进入OpenID登录页面20080501233035285
  3. 在完成OpenID登录以后,你提供的OpenID就自动绑定到你的Feedlr帐号了。在“我的帐号”里会列出已经绑定的OpenID。你可以对一个帐号绑定多个OpenID,然后用任一个OpenID登录这个帐号。绑定的OpenID也可以随时删除,重新绑定。20080501233724254

如果你还没在Feedlr注册过,那么可以直接通过OpenID登录来得到一个Feedlr帐号

  1. 在登录对话框里,选择“使用OpenID”进入OpenID登录页面
  2. 完成OpenID登录,会进入到自动新建帐号的页面。如果你的OpenID帐号里已经保存了email和昵称,Feedlr会自动帮你填入,不需要再填密码。确认并新建帐号以后就完成登录了,新建的帐号也自动和OpenID绑定了。
    这里有点需要注意的是,Feedlr不允许重复的email地址和用户名。所以如果Feedlr提示你OpenID里的email或者用户名和已有用户冲突,那么有可能你已经在Feedlr用这个email或用户名注册过帐号了。那么请用本文以上第一种方式,先登录帐号再绑定OpenID来启用OpenID登录。
  3. 直接用OpenID注册的帐号也可以用普通的email地址加密码来登录,只需要先在帐号设置里填上你自己的密码就行了。

这样就可以开始用OpenID登录了。目前,提供OpenID的基本都是国外网站。Feedlr通过ID Selector了提供常用的OpenID供应者菜单。当然,你也可以使用在菜单列出以外的网站注册的OpenID。openid

Performance tuning for Grails app in a memory constrained environment

Sunday, April 20th, 2008

Feedlr has been running quite well for a while, until a couple weeks ago, the server started to choke a lot. And I realized I had to do something to improve the performance. Actually, until then I had barely paid any attention performance-wise - getting the app up and running was the goal. And then with the growth of the app it’s time to do some work for that.

The Problem

The symptom of the performance bottleneck was that from time to time Tomcat would take a long time to respond, resulting in timeouts at the browser clients. This is caused by heavy swapping - apparently the 512MB RAM shared by all the services on the VPS, including Apache (with worker mpm), php, MySQL, and Tomcat, is less than abundant. But before upgrading my VPS, I want to see how far I can go with the current specs.

Attempting to optimize the code

My first attempt was to review my code and try to identify any possible memory leaks and memory inefficient spots. After working with profiling tools (I used an evaluation version of JProfiler, which is very good), and several refractory efforts, there was no obvious improvement. It didn’t look like a memory leak. And the effort trying to squeeze more memory from the code didn’t seem to pay off.

Tuning the JVM

Then I began to focus on tuning the JVM. The sporadic heavy swapping hints at inefficient garbage collections. But why is GC taking so much resources? Using GCViewer, I can see that the throughput can be as low as around 70%. And full GC time constantly reaches several minutes. (SliceHost has sent me a dozen heavy swap usage report already)

After some searching and study, first thing I tried was to decrease the maximum heap size. Yes, decrease it. Previously, I was assigning 384MB to the heap. Because while Tomcat is not running, I have a little less than 440MB free physical memory. Leaving some buffer, 384MB seems a reasonable number. But the excessive swapping and very long full GC time indicates that part of the heap must be slipping into the virtual memory. And virtual memory is the biggest enemy of JVM garbage collection. So I decreased the heap size incrementally, arriving at 270MB. And the GC log shows that the time full GC takes has considerably dropped.

To further improve the situation, I tried different GC policies. First I tried the Concurrent Mark Sweep GC policy, which is supposed to work very well with multi-processor servers and is optimized for response time. Profiling with the CMS options on my local workstation shows good results. And since “cat /proc/cpuinfo” shows that my VPS is equipped with 4 CPU’s, I was expecting to see obvious improvements.

However, to my great disappointment, CMS totally strangled my VPS. Soon after Tomcat starts up, CPU usage became constantly high and the Grails app responds even slower! I’m not exactly sure why, but it looks like the number of CPU’s shown at your VPS doesn’t mean it has the comparable concurrent processing power.

Then I gave up the CMS policy and tried the other GC policy suitable for servers, the Parallel policy. This turned out to work quite well on the VPS, together with “-XX:+UseParallelOldGC” which is available since Java 5 update 6 and enhanced in Java 6 which I’m running my app on.

The Results

I experimented with a few other JVM options, and finally achieved a throughput of above 98%. Full GC now usually takes around 1 second, occasionally maxing at over 10 seconds. I think there are some hard limitations to the server, but the results are already good enough for now. Here are the current ones which have achieved reasonable performance for my Grails app. These may not be the perfect setup since I haven’t tried the combinations exhaustively.

-server -Xmx270m -Xms270m -XX:MaxPermSize=80m -Xverify:none -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:+UseAdaptiveSizePolicy -XX:SurvivorRatio=4 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=31 -XX:+AggressiveOpts

References

Below are some useful articles I’ve come across while tuning the JVM.

Further thoughts

I really love Grails for what it is: remarkably agile development with real joy. But as the person running the app, I have to deal with various issues of the stack that Grails sits on, which sometimes frustrates me.
On one hand this robust stack really grants Grails an advantage in the enterprise market. But on the other hand, this is no good news for the creators of hundreds and thousands of small web apps, pet projects, interesting weekend hacks and alike. The most obvious obstacle is Java hosting. It’s 2008 already, and there are still simply _no_ easily affordable and good enough hosting services for the Java stack! The entry cost is too high. With innovative services like Heroku and Googel App Engine emerging, the gap is even increasing. The barrier to actually making something useful on the web is being dramatically lowered. But yet, the Java stack is left out in the cold.

While this is a problem, it’s also an incredible opportunity. With Grails emerging, the Java stereotype can be changed. People can build agile web apps on top of the proven stack, which is the core competency of Grails as I see it. I want to build things with Grails. But I don’t want to worry about how to host my app. Now, who’s gonna give us the ultimate service to grow little ideas into reality?

Feedlr新功能:预览消息样例

Tuesday, April 8th, 2008

在Feedlr建立一个新Feed的时候,现在可以直接预览在当前设置下播发到微博客帐号上的消息格式样例了!

image

在新建Feed向导的Feed信息设置页面上,如果在Feed地址里填上了正确的地址,点击“预览消息样例”按钮,就能看到以最新一条Feed内容为例子,机器人将会播发的消息格式。

如果没有正确的Feed地址,那么样例会用“标题”,“摘要”和“链接”来代表Feed的内容部分。在修改了Feed地址以及“更多选项”里面的消息前缀,播发标题、摘要、和链接的选项后,再点预览按钮就能更新消息格式。

消息预览是为了让用户更方便的理解并选择合适的选项,但并不一定100%和最终播发的消息完全一致。比如Feed条目的链接默认会转换成tinyurl以后再播发出去,但也会根据Bot选项来决定是否使用原来的完整地址。

希望这项小功能给各位带来一些实用的帮助。

Feedlr十八般用法之:消息前缀的妙用

Sunday, April 6th, 2008

不知道大家有没有注意到,在新建一个Feed广播的时候,可以在Feed信息的“更多选项”里填上给每条消息加上的前缀。

image

这个功能有什么用呢?最简单的用法,可以用博客的标题,Feed的内容关键字,等等作为前缀,这样关注者收到就知道消息是从哪里来,关于什么的了。但今天我想介绍的是几种更有趣的用法。

@通知某人

如果设定了前缀“@用户名”,那么发送的每条消息都能通过@功能让某人(用户名)收到。目前Twitter,叽歪,饭否都支持@功能。

有什么用呢?比如你向自己的微博客帐号发送消息,如果不加@前缀,那么新消息别人都能收到而你自己收不到。如果加上前缀“@你自己的用户名”,那么你和你的帐号的关注者都能收到新消息了。

另外,@功能可以让不关注这个帐号的人也能收到消息通知。

把消息做为私信发送给某人

想到了@的用法,可能你也就想到了d的用法。在Twitter和叽歪,支持用格式“d 用户名 消息内容”来直接发送私信给某人。如果给你的feed消息加上前缀“d 用户名”,那么每条feed消息都会直接做为私信发送给这个用户。

这样的话,你的feed机器人就成为某人(大多是你自己吧)的专用了,feed的消息不会被微博客上的其他人看到。

用前缀定义track关键字

Twitter和叽歪都支持关键字track功能,但是各自的使用方式有所不同。

在Twitter,用户可以通过GTalk或者手机发送“track 关键字”来自定义关键字跟踪。这样,只要有人在Twitter发表了包含关键字的消息,用户就能收到这条消息。

而在叽歪,如果一条消息带有“[关键字]”的内容,那么方括号里的关键字就自动成为一条线索。用户可以通过访问“http://jiwai.de/t/关键字”的地址来看到所有带有这个关键字的消息。在关键字页面上,用户可以订阅feed或者关注这个关键字。在IM和手机上,也可以发送“on [关键字]”来直接关注。

那么,如果你用feedlr广播到Twitter或者叽歪的话,你自然可以给你的feed加上相应的关键字前缀,就能保证关注这个关键字的用户都能收到feed的更新了,而不论用户是不是关注了你的机器人帐号。