首页 \ 问答 \ Redis队列在Node.js集群环境中(Redis queue in Node.js cluster environment)

Redis队列在Node.js集群环境中(Redis queue in Node.js cluster environment)

使用Node.js集群支持,我希望主进程生成添加到Redis队列的数据项。 然后,我想运行多个读取Redis队列的工作进程。 当然,只有一个工作进程应该使用从队列中检索的数据项。

为了让我开始,你能建议在哪里查看Node包支持或原始Redis命令来实现这一目标? 让我强调消费者是Node.js集群环境中的独立进程,我们可以调整竞争从单个Redis队列读取的工作进程数,以调整整体系统性能。


Using Node.js cluster support, I would like the master process to produce data items that are added to a Redis queue. I would then like to run multiple worker processes that read the Redis queue. Naturally, only one of the worker processes should consume the data item retrieved from the queue.

To get me started, can you suggest where to look in terms of Node package support or raw Redis commands to accomplish this? Let me emphasize the consumers are separate processes in a Node.js cluster environment, where we may adjust the number of worker processes competing to read from the single Redis queue to tune overall system performance.


原文:https://stackoverflow.com/questions/23529635
更新时间:2023-06-13 18:06

最满意答案

我建议您使用 Chrome扩展程序向REST调用添加请求标头。

它被称为高级REST客户端 ,我能够轻松地将提到的标题添加到GET中。

您只需要粘贴URL,选择GET ,以两种可用方式之一添加标题 (Raw of Form),然后单击Send

编辑:本文一定会帮助您解决206响应代码问题。

Accept-Ranges:字节

Accept-Ranges标头指示服务器接受对资源的范围请求。 远程Web服务器使用的单位是以字节为单位。 此标题告诉我们,服务器支持下载恢复或同时下载较小部分的文件,以便下载管理器应用程序可以加快下载速度。 Accept-Ranges:无响应标头表示下载不可恢复。

我使用文章中的以下URL尝试了Range标头,并获得了第206个响应代码: http//s0.cyberciti.org/images/misc/static/2012/11/ifdata-welcome-0.png


I suggest you using this Chrome extension to add request headers to REST calls.

It is called Advanced REST Client and I was able to add the mentioned header to the GET easily there.

You need just to paste the URL, select GET, add the Header in one of two available ways (Raw of Form) and click Send.

EDIT: This article will surely help you with the 206 response code question.

Accept-Ranges: bytes

The Accept-Ranges header indicate that the server accept range requests for a resource. The unit used by the remote web servers is in bytes. This header tell us that either server support download resume or downloading files in smaller parts simultaneously so that download manager applications can speed up download for you. The Accept-Ranges: none response header indicate that the download is not resumable.

I tried the Range header with the following URL from the article and got the 206th response code: http://s0.cyberciti.org/images/misc/static/2012/11/ifdata-welcome-0.png

相关问答

更多
  • 这是一个语法上有效的请求,但不是可满足的请求。 如果您在该部分中进一步看到: 如果语法有效的字节范围集包含至少一个字节范围规范,其第一个字节数小于实体的当前长度,或至少一个后缀字节范围规范, - 零后缀长度,则字节范围集合是可满足的。 否则,字节范围集不能令人满意。 如果字节范围集不能令人满意,服务器应返回状态为416(请求范围不可满足)的响应 。 否则,服务器应该返回状态为206(部分内容)的响应,其中包含entity-body的可满足的范围。 所以我想在你的例子中,服务器应该返回一个416,因为它不是该 ...
  • 您可以使用可选的非捕获组(?:...)? : bytes=(?\d+)(?:-(?\d+))? 其中\d+匹配1+位数。 或者使用内置的Grok模式: bytes=%{INT:start_range}(?:-%{INT:end_range})? You may use an optional non-capturing group (?:...)?: bytes=(?\d+)(?:-(?\d+))? whe ...
  • 我能够使用下面的代码传递一个头文件: jQuery.ajax({ type: 'DELETE', // must set api key url: 'https://www.googleapis.com/youtube/v3/videos?id='+ thisUniqueID +'&key=api_key_here', beforeSend: function(xhr){xhr.setRequestHeader('Authorization', 'Be ...
  • 你使用什么服务器? 这是mod_headers的apache文档。 您可以将Accept-Ranges标头设置为none http://httpd.apache.org/docs/2.2/mod/mod_headers.html 尝试在httpd.conf文件中设置“Accept-Ranges none”。 mod_headers模块也必须加载到服务器中。 另外,当通过chrome或Adobe插件(其他插件)完成pdf或通常流式传输文件的请求时,它们将始终尝试使用Range:0执行GET请求,并尝试部分请求 ...
  • Fine Uploader通过getFile(id) API方法提供对底层File或Blob对象的直接访问。 一旦有权访问它,就可以使用FileReader读取文件/ blob字节并生成哈希。 为了使散列更容易,请考虑使用像SparkMD5这样的JS库。 计算此哈希的最佳位置可能是onSubmit回调处理程序 。 由于读取文件的过程是异步的,因此您必须在处理程序中返回一个承诺,Fine Uploader支持该承诺。 计算完哈希后,使用Fine Uploader的setParams API方法解析promis ...
  • 我建议您使用此 Chrome扩展程序向REST调用添加请求标头。 它被称为高级REST客户端 ,我能够轻松地将提到的标题添加到GET中。 您只需要粘贴URL,选择GET ,以两种可用方式之一添加标题 (Raw of Form),然后单击Send 。 编辑:本文一定会帮助您解决206响应代码问题。 Accept-Ranges:字节 Accept-Ranges标头指示服务器接受对资源的范围请求。 远程Web服务器使用的单位是以字节为单位。 此标题告诉我们,服务器支持下载恢复或同时下载较小部分的文件,以便下载管理 ...
  • 1.在哪里添加“Range”标头值? PDF.js检测服务器是否返回“ Accept-Ranges:Bytes ”如果服务器返回有效的HTTP请求标头( 按规格 ),则PDF.js(将中止对不允许增量XHR的平台的主要请求)将发出范围请求。 2.如何向客户发送范围请求? 当PDF.js决定服务器可以处理范围请求时,它会自动通过XHR执行此操作。 3.从哪里打电话? 请参见network.js文件。 我应该包括viewer.html吗? 没有 看起来当前提供PDF数据的servlet不支持有效的HTTP范围请 ...
  • Content-Range指示原始实体的哪个范围包含在请求(如PUT请求)或206部分响应的正文中。 Range由客户端而不是服务器设置,以便请求子范围。 我假设您正在与之交谈的服务器不会响应上传的块,因此Content-Range (并且在任何情况下都不会)将不会作为响应头存在。 在您的代码段中, Content-Range缺少实际的上传Content-Range (请参阅更新的HTTP RFC )。 它必须具有以下形式: Content-Range: bytes 42-1233/1234 这意味着:上 ...
  • get_response是提出请求的简写,当您需要更多的控制时 - 自己完成一个完整的请求。 这里有一个ruby标准库的例子: uri = URI.parse("http://www.ncdc.noaa.gov/cdo-web/api/v2/datasets/") req = Net::HTTP::Get.new(uri) req['token'] = 'fjhKJFSDHKJHjfgsdfdsljh' res = Net::HTTP.start(uri.hostname, uri.port) {|htt ...
  • 如果我们应该只有Content-Type,Host和x-amz- *标题,那么列表标题在列表中的作用是什么? 您只需要具有Content-Type,Host和x-amz- *,但您可以添加要添加到要验证的签名的其他标头。 请参阅文档中的说明:“为了计算签名,只需要主机和任何x-amz- *标头;但是,为了防止数据被篡改,您应该考虑包括所有标头。签名计算。“ 如果我们只是想采取所有标题,那么为什么列表中没有Date标题? Date标头是特殊的,因为它是由浏览器根据可能不正确的客户端系统时间添加的。 因此,您可 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。