Here are the testing codes:
I think you will be able to reproduce the same issue just by running
this codes.
PHP Pub:
/*
* Weather update server
* Binds PUB socket to tcp://*:5556
* Publishes random weather updates
* @author Ian Barber <ian(dot)barber(at)gmail(dot)com>
*/
// Prepare our context and publisher
$context = new ZMQContext();
$publisher = $context->getSocket(ZMQ::SOCKET_PUB);
$publisher->bind("tcp://*:5556");
$publisher->bind("ipc://weather.ipc");
$counter=0;
while (true) {
// Get values that will fool the boss
$zipcode = mt_rand(0, 100000);
$temperature = mt_rand(-80, 135);
$relhumidity = mt_rand(10, 60);
// Send message to all subscribers
//echo "generating $zipcode ...\n";
$update = sprintf ("game %05d %d %d", $zipcode, $temperature,
$relhumidity);
$publisher->send($update);
$counter++;
if ($counter%1000000==0) {
echo "$counter \n";
sleep(1);
}
}
PHP Sub:
<?php
/*
* Weather update client
* Connects SUB socket to tcp://localhost:5556
* Collects weather updates and finds avg temp in zipcode
* @author Ian Barber <ian(dot)barber(at)gmail(dot)com>
*/
$context = new ZMQContext();
// Socket to talk to server
echo "Collecting updates from weather server…", PHP_EOL;
$subscriber = new ZMQSocket($context, ZMQ::SOCKET_SUB);
$subscriber->connect("tcp://localhost:5556");
// Subscribe to zipcode, default is NYC, 10001
$filter = $_SERVER['argc'] > 1 ? $_SERVER['argv'][1] : "game";
$subscriber->setSockOpt(ZMQ::SOCKOPT_SUBSCRIBE, $filter);
// Process 100 updates
$total_temp = 0;
$counter=0;
while (true) {
$string = $subscriber->recv();
sscanf ($string, "%s %d %d %d", $chancel, $zipcode, $temperature,
$relhumidity);
//echo "$zipcode\n";
$counter++;
if ($counter%1000000==0) {
echo "$counter \n";
}
}
Node.js Sub: (Will need to tune the PHP Pub to sleep 1 s every 70k
messages):
// weather update client in node.js
// connects SUB socket to tcp://localhost:5556
// collects weather updates and finds avg temp in zipcode
var context = require('zmq')
console.log("Collecting updates from weather server…")
// Socket to talk to server
var subscriber = context.socket('sub')
// Subscribe to zipcode, default is NYC, 10001
var filter = null
if(process.argv.length > 2) {
filter = process.argv[2]
} else {
filter = "game"
}
subscriber.subscribe(filter)
subscriber.setsockopt(context.ZMQ_HWM,20000)
// process 100 updates
var counter=0;
subscriber.on('message', function(data) {
var pieces = data.toString().split(" ")
var chanel=pieces[0];
var zipcode = parseInt(pieces[1])
var temperature = parseInt(pieces[2])
var relhumidity = parseInt(pieces[3])
counter++;
if (counter%70000==0) {
console.log(counter);
}
})
subscriber.connect("tcp://localhost:5556")
On Feb 28, 5:38 pm, beckel <[email protected]> wrote:
> Hi, I am.
>
> If you want help determining your system's performance you should
> publish more metrics. What is and how big is a message? What is your
> data throughput and latency?
>
> The memory spike sounds normal for that much throughput though.
>
> On Feb 28, 5:37 pm, Bob SF <[email protected]> wrote:
>
>
>
>
>
>
>
> > Hi all,
>
> > Just wondering if anyone has used Node.js with ZeroMQ?
>
> > I am using the pub/sub pattern of ZeroMQ.
>
> > The publisher is php which can sends about 1 million messages per
> > second within localhost
>
> > The php subscriber can take in the 1 million messages per second rate
> > with no problems
>
> > However, the node.js subscriber starts to get overran around 70k per
> > second even there is a high water mark setting to make the requests
> > exceeding the mark. By overrun, I mean the memory usage start to pile
> > up like crazy. Reaching 1 gb plus within just a few seconds.
>
> > 70k requests per second is by all mean impressive for my need.
> > However, I am just curious if anyone has experienced similar issues
> > with Node.js?
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en