[文章作者:张宴 本文版本:v1.0 最后修改:2010.06.29 转载请注明原文链接:http://blog.zyan.cc/httpsqs_1_3/]

  HTTPSQS(HTTP Simple Queue Service)是一款基于 HTTP GET/POST 协议的轻量级开源简单消息队列服务,使用 Tokyo Cabinet 的 B+Tree Key/Value 数据库来做数据的持久化存储。

  项目网址http://code.google.com/p/httpsqs/
  使用文档http://blog.zyan.cc/httpsqs/
  使用环境:Linux(同时支持32位、64位操作系统,推荐使用64位操作系统)
  软件作者:张宴

  队列(Queue)又称先进先出表(First In First Out),即先进入队列的元素,先从队列中取出。加入元素的一头叫“队头”,取出元素的一头叫“队尾”。利用消息队列可以很好地异步处理数据传送和存储,当你频繁地向数据库中插入数据、频繁地向搜索引擎提交数据,就可采取消息队列来异步插入。另外,还可以将较慢的处理逻辑、有并发数量限制的处理逻辑,通过消息队列放在后台处理,例如FLV视频转换、发送手机短信、发送电子邮件等。

  HTTPSQS 具有以下特征:

  ● 非常简单,基于 HTTP GET/POST 协议。PHP、Java、Perl、Shell、Python、Ruby等支持HTTP协议的编程语言均可调用。
  ● 非常快速,入队列、出队列速度超过10000次/秒。
  ● 高并发,支持上万的并发连接,C10K不成问题。
  ● 支持多队列。
  ● 单个队列支持的最大队列数量高达10亿条。
  ● 低内存消耗,海量数据存储,存储几十GB的数据只需不到100MB的物理内存缓冲区。
  ● 可以在不停止服务的情况下便捷地修改单个队列的最大队列数量。
  ● 可以实时查看队列状态(入队列位置、出队列位置、未读队列数量、最大队列数量)。
  ● 可以查看指定队列ID(队列点)的内容,包括未出、已出的队列内容。
  ● 查看队列内容时,支持多字符集编码。
  ● 源代码不超过800行,适合二次开发。



  HTTPSQS 1.3 版本增加的功能:

  1、服务器端:

  ● 增加了重要功能:定时将内存缓冲区内容写到磁盘的功能。
  HTTPSQS 1.2 及以前的版本,只有当内存缓冲区满的时候,才将内存中的内容写到磁盘,如果这期间服务器宕机,将导致一部分数据丢失。从 1.3 版本开始,支持了定时(默认5秒钟/次)将内存缓冲区内容同步到磁盘的功能,可以在启动 HTTPSQS 时使用“-s <second>”参数设置同步间隔。在 HTTPSQS 运行过程中,可以通过浏览器访问“http://host:port/?name=your_queue_name&opt=synctime&num=间隔秒数”来实时修改同步间隔,无需重启。

  ● 增加了辅助功能:以JSON格式查看队列状态。
  原有的查询队列状态功能“http://host:port/?name=your_queue_name&opt=status”,适合通过浏览器访问,人工查看,不便于程序处理。新增加的功能“http://host:port/?name=your_queue_name&opt=status_json”,以JSON格式输出队列状态信息,便于客户端程序进行处理,输出的格式示例如下:
{"name":"xoyo","maxqueue":1000000,"putpos":4562,"putlap":2,"getpos":900045,"getlap":1,"unread":104517}


  ● 增加了以下四项启动参数:
-s <second> 同步内存缓冲区内容到磁盘的间隔秒数(默认值:5)
-c <num> 内存中缓存的最大非叶子节点数(默认值:10000)
-m <size> 数据库内存缓存大小,单位:MB(默认值:100)
-i <file> 保存进程PID到文件中(默认值:/tmp/httpsqs.pid)


  2、客户端:

  ● PHP客户端Class增加了Keep-alive长连接断线自动检测、自动重连功能,PHP客服端守护进程从HTTPSQS读取数据时,不用考虑连接异常断开处理。非常适合PHP客服端作为守护进程,从队列GET读取数据,或者批量往队列中写入数据的应用。

  ● PHP客户端Class增加了函数$httpsqs->status_json($host, $port, $charset, $name);、$httpsqs->synctime($host, $port, $charset, $name, $num);、$httpsqs->pstatus_json($host, $port, $charset, $name);、$httpsqs->psynctime($host, $port, $charset, $name, $num);,详细使用说明请见:http://blog.zyan.cc/httpsqs/



  HTTPSQS 1.1/1.2 版本如何升级到 HTTPSQS 1.2 版本:

  ●服务器端版本完全兼容:编译安装 HTTPSQS 1.3,替换 HTTPSQS 1.1/1.2,然后“kill httpsqs的进程ID”,按原来的启动参数启动 HTTPSQS 即可,数据完全兼容。

  ●客户端版本完全兼容:HTTPSQS 1.3 版本的PHP客户端,仍可以直接操作 HTTPSQS 1.1/1.2。两个版本的PHP客户端函数使用方式、参数相同,1.3 版本的PHP客户端与 1.2 版本相比,增加了status_json()、synctime()、pstatus_json()、psynctime()四个函数。



  HTTPSQS 的生产环境应用:

  ●金山通行证(https://my.xoyo.com
  队列应用类型:手机短信上行、手机短信下发、邮件下发
  队列应用要求:稳定性高,存储数据量大
  队列部署结构:一主、一备两台 HTTPSQS 热备模式

  ●金山用户行为分析系统(http://kbi.xoyo.com
  队列应用类型:用户鼠标点击、访问URL原始数据采集
  队列应用要求:并发性能高,存储数据量大
  队列部署结构:多台 HTTPSQS 应用层哈希分布式模式

  ●金山逍遥网站内搜索
  队列应用类型:索引准实时更新。在金山游戏官网中,新闻、论坛帖子、客服公告、SNS社区等发生的增、删、改操作,文本内容实时写入HTTPSQS队列,全站搜索引擎增量索引准实时(1分钟内)更新的数据源取自HTTPSQS。

  ●金山逍遥网全站通用评论系统
  队列应用类型:评论发表

  ●金山《剑侠情缘》电视连续剧四大角色人物选秀活动(http://zt.xoyo.com/haixuan/
  队列应用类型:用户上传的照片异步裁剪、缩放处理

  ●新浪邮箱(http://mail.sina.com.cn
  队列应用类型:用户登陆日志记录



  HTTPSQS 1.3 版本的详细使用说明,请访问: http://blog.zyan.cc/httpsqs/






技术大类 » Cache与存储 | 评论(77) | 引用(0) | 阅读(53441)
jay Homepage
2011-4-10 16:31
此篇博文很好,帮了我大忙,谢谢博主!
qq
2011-4-12 16:02
顶一下!
rick Email Homepage
2011-4-16 17:14
Good work, your articles are very interesting, i am glad that i googled your blog
louis vuitton uk Email Homepage
2011-11-22 17:07
This louis vuitton uk for sale belongs to the sounding just what are termed as Louis Vuitton vintage best sellers, many other products and services for the reason that range appearing companies.You will easily notice the unfold zippers of this coach outlet store online. That is the decoration. There are some inside pockets for you as well. They are easy to match your clothes and to carry.Let us inspire your inner beauty with fine christian louboutin sale. Purse the elegance in bridal wedding. Enjoy the fashion.
armani watches Email Homepage
2011-11-23 10:10
If you are looking for armani Bags, our armani watches Handbags Canada outlet store is your first choice. We promise Original Packing and Best Discount,3-5 Workdays To Your Door!If you buy bags and purses of the latest new designs from the louis vuitton outlet now, you can enjoy special discounts. What else are you waiting for?After you choose the right kind of plants and the size pot for the plant.
wedding520 Email Homepage
2011-12-27 15:52
ワイドネックライン、'V'ネックやボートネックラインは、一般にキャップスリーブとドレスのために選ばれている。ボートスタイルのネックラインと幅広いネックラインのためには、オフショルダーのキャップスリーブを追加することができます。オフショルダーのウエディングドレスは、数年以来、結婚式の摩耗で人気のパターンになっても流行で、今日でもあります。カラードレス 格安.のこのスタイルで素敵に見える模様のオフショルダーの袖に行く同じシースのサテンからステッチ/オフショルダーのキャップスリーブの上に薄いと飾ったときに裾フレアのビットとシースのサテンのイブニングドレスとスパゲッティネックラインがすごい見えます。
Hogan Email Homepage
2012-5-10 17:51
Ci sono diversi motivi principali per cui si può sicuramente trovare sul proprio volere le soluzioni contabili che coinvolgono tutta Stansted, anche se alcune persone potrebbero uomini e donne, probabilmente si dovrà disporre di soluzioni contabili rispetto con la gente. Stai con me per scoprire di più su molti dei motivi per prendere in considerazione l'impiego contabili in tutta Hogan Stansted. Costruire un businessIf vi capita di essere in funzione, è abbastanza possibile che si può fare uso di soluzioni contabili. Non date per scontato tutte le società hanno abbastanza soldi per utilizzare a tempo pieno il personale fiscali, così utilizzando una conditi insieme con l'agenzia affidabile che coinvolge tutta commercialisti Stansted potrebbe rendere meno difficili problemi.
hogan280 Email
2012-5-10 18:05
Non tanto è stato fatto perché le accuse della ragazza giovane non si pensava in primo luogo. Né come la segnalazione di Hogan questo caso potrebbe portare ad un simile tipo di stereotipo e mito attorno alla violenza sessuale.
lirourou77 Email Homepage
2012-9-5 13:24
in a new mechanism of system to replace the old in medicine have medical mechanism, which is the cheap designer handbags      
cattle nets", and click "online voting" found that, the original vote is paid, 1 yuan 1 ticket.

"If you have to vote online, by pay treasure, net silver or cell phone pays fee." HeXianSheng cheap designer clothes        
said, let people will choose the doctors like this is a good thing, but if will pay it is stale, "so, mean who's money, who can election?"

【 operation 】 can buy tickets into batch quantity
discount designer handbags        

According to HeXianSheng provide web site, reporter found "purple cattle nets", "popular activities" column in the article 1 is: ningxiang county "open the door the medical" advanced unit and "top ten doctors, top ten nurses, top ten technicians" selection activities to officially wholesale designer handbags
Coach Email Homepage
2012-11-3 14:45
"The Coach Outletengines that will likely power the J-31 we do know a bit mor.Coach Outlet  Those engines were actually revealed at the Zhuhai showCoach Outlet in 2008," Fisher said referring to an annual China air show. He beCoach Outletlieves the new J-31 engine is undergoing preliminary
磨延城 Email Homepage
2013-10-21 20:38
磨途歌学习了
walson rockabilly dresses Email Homepage
2014-3-18 17:43
The Vintage Wholesale Company The Vintage Wholesale Company.Walson Rockabilly are a vintage wholesale company who focus on vintage fashion wholesale. WalsonRockabilly Vintage Clothing wholesalers are the UK's leading,Shop wholesale vintage dress, cheap silk dress, vintage jewelry products from reliable vintage dress wholesalers on walsonrockabilly and get worldwide,We know wholesale vintage clothing. We're the only vintage clothing wholesaler that knows what it's like to be in your shoes,because we run stores ourselves.Always Vintage is a Wholesale Vintage Clothing Distributor. We offer more than ninety different categories of vintage clothing for you to choose from.
walson rockabilly dresses
walsonrockabilly
rockabilly
Steven Email Homepage
2015-3-19 02:31
Thank you for this post Weight Loss Tea
sdfsdf Email Homepage
2015-3-20 05:37
app开发公司 Email Homepage
2015-12-24 17:09
现在有很多可以在线制作app平台,不会编程技术和UI设计也没有关系,这些平台一般给你提供了很多app模板,只要你选择合适的模板,添加相应的素材,就可以制作出一款专业的app,比如应用公园就采用控件式的操作方式,灵活而易操作,素材添加完后安卓、苹果系双系统同时生成!
William
2019-6-6 16:53
Such an informative discussion here on lightweight open source simple queue service of HTTP. Also it is best website for SQL users and developers including students who are receiving non-copied, modified and error free business essay help from essay writers of Elite Assignment in UK. Happy to be a part of this community.
Lauren
2019-6-6 16:59
Nice to visit this website and Good luck and tons of best wishes. God bless you in whatever you do. Thank you for sharing this information of Ms. K.R.Suriya. - Lauren,Senior CV writer and CV Help provider at CV Folks
分页: 2/4 第一页 上页 1 2 3 4 下页 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]