[文章作者:张宴 本文版本: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) | 阅读(52102)
jenny Email Homepage
2023-1-19 22:33
initially gmail login  systems required the author and the recipient https://www.rss.org/eng/gmail-login.html
flevin Email Homepage
2023-1-19 22:34
is a one-stop solution for all urgent assignment help needs https://www.brownbooks.com/blogs/assignment-help.html
kessi Email Homepage
2023-1-19 22:36
msn hotmail email systems are based on a ‘store and forward’ model.  https://www.brownbooks.com/blogs/msn-hotmail.html
sara Email Homepage
2023-1-19 22:36
Popular email platforms include msn ,Gmail, Hotmail, Yahoo! Mail, Outlook, and many others. https://clinmedjournals.org/articles/cmil/msn-login.html
hotmail.com Email Homepage
2023-2-12 05:14
hotmail.comhttps://clinmedjournals.org/article/en/hotmail-login/  Be free from your internet service provider!” Proclaimed the world's first web-based email when it launched on 4th July 1996.
tom Email Homepage
2023-9-21 18:16
I haven't been able to find any receiptify spotify  websites or other things that show end-of-month numbers for ytm. Does anyone know of any?
receiptify spotify Email Homepage
2023-9-21 18:18
I haven't been able to find any receiptify spotify websites or other things that show end-of-month numbers for ytm. Does anyone know of any?
receiptify spotify Email Homepage
2023-9-21 18:20
I haven't been able to find any receiptify spotify websites or other things that show end-of-month numbers for ytm. Does anyone know of any?
receiptify spotify Email Homepage
2023-9-21 18:21
I haven't been able to find any receiptify spotify websites or other things that show end-of-month numbers for ytm. Does anyone know of any?
saqlain Email
2023-9-21 18:23
I haven't been able to find any receiptify spotify websites or other things that show end-of-month numbers for ytm. Does anyone know of any?
saqlain Email
2023-9-21 18:23
I haven't been able to find any receiptify spotify  websites or other things that show end-of-month numbers for ytm. Does anyone know of any?
hotmail.com Email Homepage
2023-9-21 18:28
Why doesn't hotmail.com work? My bank told me that this is a typical problem with outlook.com emails right now. I can't receive e-transfers on my bank account through email.
yahoo.com Homepage
2023-9-21 18:32
I know this is a long shot, but I wanted to know if there was a way to get yahoo.com  email from 20 years ago that I still have access to.
fb.com Email Homepage
2023-9-21 18:34
Can't post in  fb.com groups for 364 days, but there's no message in the support inbox?
gmail.com Email Homepage
2023-9-21 18:35
Only one gmail.com  account is rejecting email as spam, not all of them.
mj123123 Email
2024-1-3 18:23
If you have trouble signing in, you can click on the "Can't access your account?" link under the hotmail sign-in button for assistance. You may also need to verify your identity using your phone number, alternate email address, or security questions to regain access to your account.
分页: 4/4 第一页 上页 1 2 3 4 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]