[文章作者:张宴 本文版本: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格式输出队列状态信息,便于客户端程序进行处理,输出的格式示例如下:
● 增加了以下四项启动参数:
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/


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)
-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/


SDFS
2026-7-1 17:20
You make so many great points here that I read your article a couple of times. Your views are in accordance with my own for the most part. This is great content for your readers. ราคาบอลไหล
성인 PC방 벌금
2026-7-1 19:20
Excellent Submit, I will be a huge believer inside submitting feedback about web sites to be able to allow the website copy writers understand that they’ve extra one thing useful to be able to the net! 성인 PC방 벌금
SDDDS
2026-7-1 21:18
Document thrilled along with the researching you will designed to makes precise put up impressive. Delightful adventure! hargatoto Stick to the fantastic job, That i look over couple articles or blog posts on this subject web-site together with It is my opinion that online webpage is certainly legitimate appealing and features have communities for superb material. koitoto
asdasd
2026-7-2 15:52
I've lately began the weblog, the data a person supply on this website offers assisted me personally significantly. Many thanks with regard to all your period & function. 성인 PC방 수입
RAZA
2026-7-2 16:48
This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. 가락동 노래방
SEO
2026-7-2 16:55
This list helped me find a server with a supportive mentor program. Veteran players guiding newbies fosters growth and retention. Real player rankings reflected that community spirit. 성인 PC방 알바 Very informative — the player-reported bug-fix timelines were helpful. Timely fixes signal active and responsible development. Real votes confirmed consistent maintenance. koitoto
sel
2026-7-2 21:34
That is thus gorgeous and also imaginative. I recently really like the particular shades and also anyone who receives that inside the email will probably be beaming. slot gacor That is thus gorgeous and also imaginative. I recently really like the particular shades and also anyone who receives that inside the email will probably be beaming. naps gear That is thus gorgeous and also imaginative. I recently really like the particular shades and also anyone who receives that inside the email will probably be beaming. slot online
seo
2026-7-4 16:07
I am impressed. I don't think Ive met anyone who knows as much about this subject as you do. You are truly well informed and very intelligent. You wrote something that people could understand and made the subject intriguing for everyone. Really, great blog you have got here. ค่าน้ำบอล
SEO
2026-7-4 18:37
If you are looking for more information about flat rate locksmith Las Vegas check that right away. 인디고 게임We are really grateful for your blog post. You will find a lot of approaches after visiting your post. I was exactly searching for. Thanks for such post and please keep it up. Great work. 인디고 게임I’m going to read this. I’ll be sure to come back. thanks for sharing. and also This article gives the light in which we can observe the reality. this is very nice one and gives indepth information. thanks for this nice article... 인디고 게임
sei
2026-7-4 20:37
The application comes across as being remarkable to enjoy a book this type of insightful and even distinct articles and reviews onto your website pages. human hair extensions
raza
2026-7-4 20:47
This is my first time visit to your blog and I am very interested in the articles that you serve. Provide enough knowledge for me. Thank you for sharing useful and don't forget, keep sharing useful info: 花蓮租機車
toto macau
2026-7-4 21:06
Thank you for taking the time to publish this information very useful! toto macau
raza
2026-7-5 13:40
That is thus gorgeous and also imaginative. I recently really like the particular shades and also anyone who receives that inside the email will probably be beaming. slot gacor That is thus gorgeous and also imaginative. I recently really like the particular shades and also anyone who receives that inside the email will probably be beaming. naps gear That is thus gorgeous and also imaginative. I recently really like the particular shades and also anyone who receives that inside the email will probably be beaming. slot online
ayan ansari
2026-7-5 19:36
Awesome article, it was exceptionally helpful! I simply began in this and I'm becoming more acquainted with it better! Cheers, keep doing awesome! situs toto macau
yedrt
2026-7-6 16:08
Decent Blog post, My group is a good believer on advertisment observations at online sites to help you allow web log people know they’ve applied a product favorable to help you the online world! 오피사이트
as
2026-7-6 19:03
Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. 아이허브할인코드
as
2026-7-7 15:08
Very efficiently written information. It will be beneficial to anybody who utilizes it, including me. Keep up the good work. For sure i will check out more posts. This site seems to get a good amount of visitors. 온라인홀덤
seo
2026-7-7 15:52
You made such an interesting piece to read, giving every subject enlightenment for us to gain knowledge. Thanks for sharing the such information with us to read this... วิเคราะห์บอลสด
raza
2026-7-7 15:55
very interesting keep posting. 인디고 게임
SGG
2026-7-7 19:31
Great article with excellent idea!Thank you for such a valuable article. I really appreciate for this great information.. bmw777
分页: 8/9
3 4 5 6 7 8 9
3 4 5 6 7 8 9
Linux 下 PHP 5.2.x 连接 SQL Server 数据库 FreeTDS 配置笔记
当 MySQL 和 Memcached 遇到尾部空格时

2010-6-29 18:27 | by







