[文章作者:张宴 本文版本: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) | 阅读(52214)
alex
2019-7-5 16:21
nice post.
Alex
2019-7-5 16:24
Thanks for providing here characteristics of HTTPSQS. This post on lightweight open source simple queue service HTTPSQS 1.3 release would be improve knowledge of IT learners. Alex,With nursing assignment writers assisting students at Quality Assignment.
annashetty Email
2019-8-12 12:53
有意义,非常精心的课程,谢谢你有意义的文章   happy wheels
ronn Email Homepage
2019-8-26 14:11
I unquestionably getting a charge out of each and every piece of it. It is an awesome site and pleasant offer. I need to bless your heart.. Thanks  atari breakout
hotmail login Email Homepage
2019-9-25 12:57
Things are very open and intensely clear explanation of issues. was truly information. Your website is very beneficial.
hotmail login Email Homepage
2019-9-25 12:57
Things are very open and intensely clear explanation of issues. was truly information. Your website is very beneficial.
hotmail login Email Homepage
2019-9-25 12:58
Things are very open and intensely clear explanation of issues. was truly information. Your website is very beneficial.
nguyenthaovan Homepage
2019-10-9 11:29
I love what you guys tend to be up too. This type of clever work and reporting!Keep up the amazing works guys I’ve included you guys to our blogroll.I loved the way you discuss the topic great work thanks for the share. gmail login
masonsetup Email Homepage
2019-12-10 15:22
If you’re facing 123.hp.com setup the problem, you can get online help remotely available round the clock. HP printer setup expert helps you to set up the HP printer in the right ways. It supports all types of systems, so you can take proper technical support. Still, if you’re facing any issue, our techies are available 24/7 to assist you remotely.
Midwifery Writing Services Homepage
2020-7-22 19:22
Midwifery assignment writing service learners have an advantage of hiring the best midwifery research paper help writer that is familiar with midwifery coursework writing services for their Midwifery Writing Services.  https://researchpapers247.com/midwifery-writing-services/
Paulojimmathew Email
2021-7-29 12:33
Much obliged. Thanks! , dude. As usual, you come through like a champ! I like your work.  เล่นบาคาร่า
Ieuan Ventura Email
2021-10-20 18:01
An organization’s long-term victory will depend on the execution of its workers. I believe you have already yours. Maybe you also lift my side.  เกมส์สล็อตออนไลน์
JoeKevin Email
2021-12-4 16:25
In addition to physical training, brain training is also indispensable for anyone. But, if we can choose to passively train our brains with highly entertaining games, why not give it a try? And The Match 3 is a recommendation of mine! (if you have a better and more useful game, please share it with me! Thanks for that!).
markjohn123123 Email
2022-5-4 05:48
hotmail is a free email service provided by Microsoft. It was first known as "Hotmail.com", but on April 3rd, 2013 Microsoft changed its website to "Outlook.com".If you don't own a Microsoft account it takes only a few minutes to create an outlook.com account for free. With a free hotmail.com account, you can access your emails, calendars, tasks from any place which has an internet connection.
markjohn123123 Email
2022-5-4 05:49
Creating a hotmail/Outlook account is an easy process. If you want to make one follow the steps below to sign up:Visit the outlook website at "https://login.live.com/" and click on "Create One".On the next page, choose your desired email address and click onnext. You can select your email with @hotmail.com or @outlook.com extensions.Next, it will ask you for the password. Make sure to enter a strong password (that contains an Upper case letter, Number, and Special characters).In the next window enter your First Name and Last Name and click on the Next button.Onthe next screen, you have to enter your Country/Region and Date of Birth. (Make sure you enter your details correctly because even if you lost your password these details will help you in recovering your email account).
Alisha Email Homepage
2022-12-1 19:24
Find the perfect escort for any occasion. Our company offers a variety of beautiful, intelligent and educated escorts who are available 24/7 to serve you. Call us today!
tobby Email Homepage
2023-1-19 22:24
Aol mail Inc. operates: America Online with more than 24 million members, and CompuServe, with more than 2.8 million members, the company's two worldwide Internet services; several leading Internet brands including AOL Instant Messenger and Digital City and Mapquest; the Netscape Navigator and AOL.com portalshttps://www.brownbooks.com/blogs/aol-mail.html
kenny Email Homepage
2023-1-19 22:28
<a href="https://www.brownbooks.com/blogs/eshram-card.html" target="_blank" rel="dofollow">eshram card</a> A person working in an unorganised sector should apply for a Shramik card or e-Shram card
dolly Email Homepage
2023-1-19 22:30
AOL service provides customers with a world-wide, interactive community offering a wide variety of content, features and tools https://www.rss.org/eng/aol-mail.html
terra Email Homepage
2023-1-19 22:32
hotmail login uses technology to communicate a digital message from a sender to receiver over the internet https://www.rss.org/eng/hotmail-login.html
分页: 3/4 第一页 上页 1 2 3 4 下页 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]