usenet :p.infosystems.
land:
subject: real-time data updates with high concurrency - server bottleneck
(主题:高并发下的实时数据更新-服务器瓶颈)
im building a small site that shows fast-changing data. every few seconds the numbers change.
(我在做一个小网站,展示一些变化很快的数据,每几秒钟数字会变化。)
problem: when 50 users refresh at the same time, my cgi scripts lock up.
(问题是:如果50个用户同时刷新,我的cgi脚本就卡死了。)
any way to push the new data to clients without them refreshing? or a lightweight way to handle concurrency?
(有没有办法不用用户刷新就能把新数据推给他们?或者有什么轻量级的并发处理方案?)
hardware: one pentium 75, 16mb ram, linux.
(硬件:一台奔腾75,16兆内存,linux系统。)
thanks.
– land
--------------------------------
下面是wind lf的回复
wind lf:
dont push. let clients pull but with a trick.
(别推送,让用户拉取,但有个小技巧。)
use a tiny hidden iframe that refreshes every 2 seconds, loading a static html file. update that file via cron script every second.
(用一个隐藏的小iframe,每两秒刷新一次,里面加载一个静态html文件,再用定时脚本每秒钟更新那个文件。)
main page reads the latest numbers from that file using javascript. no cgi hit on each refresh.
(主页面用javascript从那个文件里读取最新数据,每次刷新就不会触发cgi。)
concurrency? use flock on a text file. with 100 users, your pentium wont blink.
(对于并发问题,只要对文本文件使用文件锁,哪怕上百个用户,你那台奔腾也没问题的。)
also – ditch cgi. write a small c program as fastcgi or use inetd.
(另外:扔掉cgi,写一个小的c语言程序,做成fastcgi,或者用inetd启动。)
trust me. im from the future.
(相信我,我是从未来来的。)
– wind lf
-----------------------------
苏安心念电转,飞快的脑子里分析着这个wind lf提供的解决方法,让他惊喜的是,这家伙提供的这个解决方案,大概率是真的可行的!
“这家伙还挺有意思,居然还说自己是从未来来的!…他应该还在线,干脆再赶紧问一下方案的细节!…”苏安飞快的敲出了他的追问。
land:
wind lf, iframe? that works? what is fastcgi? i never heard.
(风,iframe?这能行吗?fastcgi是什么?我没听说过。)
from the futur