PazoozaTest Pazman
PazoozaTest Pazman

Reputation: 749

Azure SDK causes Node.js service bus call to run slow

I am using this piece of code to call the service bus queue from my node.js server running locally using web matrix, I have also upload to windows azure "web sites" and it still performs slowly.

var sb1 = azure.createServiceBusService(config.serviceBusNamespace, config.serviceBusAccessKey);
sbMessage = {
    "Entity": {
        "SerialNumbersToCreate": '0',
        "SerialNumberSize": config.usageRates[3],
        "BlobName": 'snvideos' + channel.ChannelTableName,
        "TableName": 'snvideos' + channel.ChannelTableName
    }
};

sb1.getQueue('serialnumbers', function(error, queue){
    if (error === null){
        sb1.sendQueueMessage('serialnumbers', JSON.stringify(sbMessage), function(error) {
            if (!error)
                res.send(req.query.callback + '({data: ' + JSON.stringify({ success: true, video: newVideo }) + '});');
            else 
                res.send(req.query.callback + '({data: ' + JSON.stringify({ success: false }) + '});');
        });
    }
    else res.send(req.query.callback + '({data: ' + JSON.stringify({ success: false }) + '});');
});

It can be up to 5 seconds before the server responds back to the client with the return result. When I comment out the sb1.getQueue('serialnumbers', function(error, queue){ and just have it return without sending a queue message it performs in less than 1 second. Why is that? Is my approach to using the azure sdk service bus correct?

Any help would be appreciated.

Upvotes: 0

Views: 385

Answers (2)

PazoozaTest Pazman
PazoozaTest Pazman

Reputation: 749

Thanks mark for replying. The problem I was experiencing was to do with IISNode, apparently if somebody is using console.log in their program then IISNode will crash eventually at some stage. In web.config if you tweak this setting every now and then:

loggingEnabled="true"

to false no more crashes, and queue calls work. I should have pointed out all my queue calls are done within the same thread, to which I have a cron job check the queue for messages, hence why when IISNode crashed, and rebooted again it appeared like the queue was delayed somehow.

Cheers

Upvotes: 1

Mark Cowlishaw - MSFT
Mark Cowlishaw - MSFT

Reputation: 441

Your getQueue call really isn't very functional in this scenario, since you're not using the output, you might try CreateQueueIfNotExists, to see if there's a perf difference

Upvotes: 0

Related Questions