Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance Issues when publishing #3

Open
keithmorris opened this issue Aug 9, 2016 · 1 comment
Open

Performance Issues when publishing #3

keithmorris opened this issue Aug 9, 2016 · 1 comment

Comments

@keithmorris
Copy link

Hello. Thank you for this library. I have been experimenting with it and love the API. However, I've come up against some pretty significant performance issues when compared to using amqplib directly. I've tried to simply this as much as possible to demonstrate the issue.

If I use the amqpbus library with the following code, I'm achieving about 50 messages per second. Note that if I increase the number inside of range() to 1000000, I get an out of memory error:

import AmqpBus from 'amqpbus';
import {range} from 'lodash';

const bus = new AmqpBus('amqp://guest:[email protected]:32780', () => {
    const stream = bus.getStream('PUSH', 'amqpbus');
    range(100000).forEach((item) => stream.send({message: `This is message number ${item}`}));
});

However, with the following code using amqplib directly, I'm able to get 50,000 messages per second:

import amqplib from 'amqplib';
import {range} from 'lodash';

amqplib.connect('amqp://guest:[email protected]:32780')
    .then((conn) => {
        return conn.createChannel();
    })
    .then((ch) => {
        const q = 'amqplib';
        ch.assertQueue(q, {durable: true});
        range(1000000).forEach((item) => ch.publish('', q, Buffer.from(JSON.stringify({message: `This is message number ${item}`}))));
    });

I'm not sure if this has to do with all of the Event emitting or what.

@cosmin-harangus
Copy link
Member

Hi Keith,

Thanks for reporting the issue. I have not encountered this before, but I will test it asap and get back to you.

At first look it seems that the send method connects to the server on every call and asserts the existence of the queue before sending the message. That is indeed a performance drain and should only be done the first time it connects to the stream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants