Mojolicious and RabbitMQ

瀏覽次數:268 次
跳到第一則未讀訊息

Bakanov Dmitriy

未讀,
2015年5月30日 晚上11:30:252015/5/30
收件者:mojol...@googlegroups.com
Hello, community

Currently I have 2 Mojolicious applications. I want first application notify second application about some messages it receives. I decided, that RabbitMQ will be the best way to implement it, because RabbitMQ tool is widespread, it has monitoring features, it's fast and allow flexibility. But, I have some troubles to use RabbitMQ from mojolicious. There are clients to RabbitMQ that allow non-blocking mode, but due to company's coding standards I don't want to use unsupported client like AnyEvent::RabbitMQ. Now I have the following Idea:
1. I found a client https://github.com/markwellis/net-amqp-rabbitmq that has some support and has commits in a recently few months
2. Unfortunately, it's blocking.
3. But I can call method 'get' to get messages from RabbitMQ if they exist, or it will return undef, if there no messages
4. I want to emit event 'receiving' in IOLoop and call Rabbit's 'get' method.
5. If there is a message I will emit 'received' event in IOLoop and then will be handle it in callback.
6. After this handling I will emit 'receiving' again.
7. If there are no messages in 'receiving' call, I will start IOLoop's timer to fire after 0.1 sec and emit 'receiving' in timer's callback
8. So, I will have the system, that works non-blocking, using blocking library (?)
9. But I will have some overhead when RabbitMQ is idle, and I will be check it every 0.1 sec. I think it's not a problem for me, because RabbitMQ always should have a load in production. I did measured, that idle Mojolicious in this 'receiving' mode don't consume much resources. Just a 1-2% of CPU. But again, I think it really never will be idle.

QUESTION: Do you see some pitfalls in this schema I have described? Is it OK?
QUESTION 2: Maybe some advices to use another configuration or instruments to achieve my goals?

Thanks,
Dmitry

Denis Fedoseev

未讀,
2015年6月5日 凌晨3:24:532015/6/5
收件者:mojol...@googlegroups.com
Hi, Dmitry

What problem with AnyEvent::RabbitMQ do you have? Right now, I see that this module is updated 21th of march and it doesn't looks like unsupported.

Anyway, blocking library in non-blocking system is not a problem. But you should understand that is a potential bottleneck in whole application. Because if this library blocks - all your apllication will blocks.

For example, if single request costs 1ms and you have 10rps - your application will locks for 10ms. But, if one of requests is longer than 1s - you will have the DOS.


Best regards,
Denis

--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious...@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.



--
С уважением, Денис Федосеев

Bakanov Dmitriy

未讀,
2015年6月8日 凌晨3:05:422015/6/8
收件者:mojol...@googlegroups.com
Thanks, now I see it's currently supported by bobtfish. If you use it in production, could you please share your impressions?

пятница, 5 июня 2015 г., 12:24:53 UTC+5 пользователь alpha6 написал:

Denis Fedoseev

未讀,
2015年6月10日 上午8:00:102015/6/10
收件者:mojol...@googlegroups.com
Sorry, I don't use Mojo and RabbitMQ together.

Sebastian Podjasek

未讀,
2015年6月29日 上午8:56:052015/6/29
收件者:mojol...@googlegroups.com
If you're still interested in using RabbitMQ with Mojo, please take a look at this:

https://github.com/InWayOpenSource/mojo-rabbitmq-client

I just started to rewrite AnyEvent::RabbitMQ to work on Mojo::IOLoop and Mojo::EventEmitter.
Any help or criticism would be greatly appreciated.

回覆所有人
回覆作者
轉寄
0 則新訊息