[LRUG] AMQP threads. Where did my messages go?

Jim Myhrberg contact at jimeh.me
Fri Mar 21 07:47:05 PDT 2014


Generally, no, pushing a job within a job is fine. It does get a little
less straight forward if you're using the amqp as you're somewhat at the
mercy of the event loop, but that's about it.

But yes, narrow it down to smallest part of the puzzle that's failing, in
this case the Node.js worker's queue consumption, and debug/stress test it
:)


--jimeh


On Fri, Mar 21, 2014 at 1:30 PM, Simon Morley <simon at polkaspots.com> wrote:

> Ok. Back to the drawing board. I'll try that.
>
> I'm assuming therefore there's no biggy running a job within a job, so to
> speak..
>
> Simon Morley
> Big Chief | PolkaSpots Supafly Wi-Fi
>
> simon at PolkaSpots.com
> 020 7183 1471
>
> Follow our updates on twitter: twitter.com/polkaspots
> Try Wi-Fi As A Service (WaaS) here: http://bit.ly/15UymJ8
>
>
>
>
>
>
>
>
> On 21 March 2014 13:11, Jim Myhrberg <contact at jimeh.me> wrote:
>
>> In that case I'd take your Ruby worker out of the equation, and stress
>> test your notification queue and Node.js worker by having a custom script
>> or something flood the notification queue with messages, upping the message
>> rate until you're starting to see the Node.js worker misbehaving. In theory
>> you should be able to do this even on your local dev machine, unless
>> production and dev run different OSs and the issue stems from something OS
>> specific that RabbitMQ or Node.js relies upon.
>>
>>
>>
>> --jimeh
>>
>>
>> On Fri, Mar 21, 2014 at 12:47 PM, Simon Morley <simon at polkaspots.com>wrote:
>>
>>> Hi Jim
>>>
>>> Thanks for the email. I have two coffees on my desk right now, I can
>>> send one over..
>>>
>>> We were actually using bunny until last night but swapped over to AMQP
>>> gem as a test. There's a bunny issue that's just been closed that sort of
>>> addressed our problem (
>>> https://groups.google.com/forum/#!topic/ruby-amqp/_ZShRP6FRXI). Wanted
>>> to eliminate that part despite running a later version.
>>>
>>> It's actually the latter we seem to be struggling with. They seem to
>>> disappear between Rabbit and Node. Thanks for the info though, good to
>>> learn new stuff.
>>>
>>> S
>>>
>>>
>>>
>>> Simon Morley
>>> Big Chief | PolkaSpots Supafly Wi-Fi
>>>
>>> simon at PolkaSpots.com
>>> 020 7183 1471
>>>
>>> Follow our updates on twitter: twitter.com/polkaspots
>>> Try Wi-Fi As A Service (WaaS) here: http://bit.ly/15UymJ8
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On 21 March 2014 12:30, Jim Myhrberg <contact at jimeh.me> wrote:
>>>
>>>> Hey Simon,
>>>>
>>>> My AMQP skills have been gathering dust for a couple of years at this
>>>> point, but I'll see if I can help.
>>>>
>>>> First, maybe I haven't had enough caffeine today, so would mind
>>>> clarifying if the issue is that the notification messages don't get pushed
>>>> from the Ruby worker, or they do show up fine in RabbitMQ and then
>>>> disappear between RabbitMQ and the Node.js worker?
>>>>
>>>> If it's the former, one thing to keep in mind when using the amqp gem,
>>>> is that calling #push doesn't mean the message has been pushed, it means it
>>>> will be pushed at some point in the future when the event loop gets to it.
>>>> Typically if I recall, anything/everything pushed within processing one
>>>> AMQP message, get's all gets pushed at once after the ACK for the initial
>>>> message being processed is sent back to RabbitMQ. Another thing to keep in
>>>> mind is that killing the connection/process/whatever even after finishing
>>>> processing the initial message might cut off your messages being pushed.
>>>>
>>>> The async nature of the amqp gem can cause some weird timing issues.
>>>> Hence when I last used AMQP we ended up replacing the amqp gem where async
>>>> wasn't specifically required with the synchronous bunny gem instead to make
>>>> things simpler.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> --jimeh
>>>>
>>>>
>>>> On Fri, Mar 21, 2014 at 12:10 PM, Simon Morley <simon at polkaspots.com>wrote:
>>>>
>>>>> Hi Tom, Steve
>>>>>
>>>>> Thanks for your emails.
>>>>>
>>>>> We have ack on for everything right now. We can see the 'parent' job
>>>>> being queued, the follow up jobs don't seem to be queued - I'll confirm
>>>>> this shortly.
>>>>>
>>>>> I have no unacked messages either right now.
>>>>>
>>>>> I'd thought the consumer might be dying which is why we ran the child
>>>>> job in a loop. No problems encountered.
>>>>>
>>>>> Just can't see why they work independently, just not as one.
>>>>>
>>>>> S
>>>>>
>>>>> Simon Morley
>>>>> Big Chief | PolkaSpots Supafly Wi-Fi
>>>>>
>>>>> simon at PolkaSpots.com
>>>>> 020 7183 1471
>>>>>
>>>>> Follow our updates on twitter: twitter.com/polkaspots
>>>>> Try Wi-Fi As A Service (WaaS) here: http://bit.ly/15UymJ8
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On 21 March 2014 11:59, Tom - Droplet <tom at dropletpay.com> wrote:
>>>>>
>>>>>> Hi Simon,
>>>>>>
>>>>>> What are your publisher confirm settings and consumer ack settings?
>>>>>> Could it be that the consumer dies during processing the job but you have
>>>>>> subscribed to the queue without requiring acks, so the message is
>>>>>> essentially lost?
>>>>>>
>>>>>> The RabbitMQ management page can be pretty useful for debugging this
>>>>>> kind of stuff sometimes, you can check that messages are getting put in the
>>>>>> queue as you expect and pull them out to see the message.
>>>>>>
>>>>>> --
>>>>>> Tom Livesey
>>>>>> Lead engineer - Droplet
>>>>>> dropletpay.com
>>>>>>
>>>>>>
>>>>>> On 21 March 2014 at 11:48:05, Simon Morley (simon at polkaspots.com)
>>>>>> wrote:
>>>>>>
>>>>>> Morning All
>>>>>>
>>>>>> Having asked SO, I remembered we were supposed to be encouraging more
>>>>>> questions here! I hope you can help (sorry this is a long message).
>>>>>>
>>>>>> Relatively new to the world of RabbitMQ, I'm getting stuck debugging
>>>>>> the problem of missing messages. All was / is fine in my dev. environment,
>>>>>> the problems arise when we start chucking thousand of messages at things.
>>>>>>
>>>>>> I've narrowed the problem down to messages that are sent from within
>>>>>> another job. For example, we have a job that moves a customer's
>>>>>> subscription when they sign up. We publish this to our rabbit servers using
>>>>>> the AMQP gem and EM using something like this:
>>>>>>
>>>>>> https://gist.github.com/simonmorley/9684010
>>>>>>
>>>>>> def queue_process_subscription
>>>>>>    user. process_subscription
>>>>>> end
>>>>>>
>>>>>> def process_subscription
>>>>>>   hammer_time
>>>>>>   MESSAGE_QUEUE.push(json_message, 'ps.routing.key')
>>>>>> end
>>>>>>
>>>>>> After the job's been completed, we use MESSAGE_QUEUE to push a
>>>>>> message to our notification servers (which run NodeJS, node-amqp and
>>>>>> SocketIO).
>>>>>>
>>>>>> On my lonely laptop, the jobs process perfectly, the notification are
>>>>>> sent and my SocketIO client receives them. Happy days.
>>>>>>
>>>>>> On my production servers, the job is queued in RabbitMq, processed
>>>>>> perfectly and the notification is published apparently. The problem is, it
>>>>>> doesn't appear to be received by the node amqp consumer 100% of the time.
>>>>>> Maybe 1 in 10 get delivered (and sometimes they don't look like the full
>>>>>> message). The rest just vanish.. It gets worse as we load the servers up.
>>>>>>
>>>>>> I thought it was the AMQP on the Node servers but I created a loop to
>>>>>> run MESSAGE_QUEUE 10,000 times and they were all consumed..
>>>>>>
>>>>>> So, I'm assuming the problem is that we're sending a message from
>>>>>> within another thread. At least, that's what I think it is. My knowledge of
>>>>>> such things has now come to an end...
>>>>>>
>>>>>> We've now replaced the last notification with Redis publish which
>>>>>> works a treat. But that's another cog to think about.
>>>>>>
>>>>>> Like I said, I'm new to this messaging / threading stuff,  and would
>>>>>> appreciate it if someone can point me in the right direction, tell me what
>>>>>> to read or suggestion something else to try. Or tell me to give up and go
>>>>>> home.
>>>>>>
>>>>>> Cheers
>>>>>>
>>>>>> Simon
>>>>>>
>>>>>>
>>>>>>
>>>>>>  Simon Morley
>>>>>> Big Chief | PolkaSpots Supafly Wi-Fi
>>>>>>
>>>>>> simon at PolkaSpots.com
>>>>>> 020 7183 1471
>>>>>> @polkaspots
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>     ---------------------------------------------------------------------------------------
>>>>>> The information contained in this email and its attachments is confidential and may be the subject of legal, professional or other privilege. It is intended only for the named addressees and may not be disclosed to anyone else without consent from PolkaSpots Limited. If you are not the named addressee you must not use, disclose, distribute, copy, print or rely on the contents of this email and should destroy it immediately. Whilst PolkaSpots Limited takes care to protect its systems from electronic virus attack or other harmful event, the firm gives no warranty that this email message (including any attachments to it) is free of any virus or other harmful matter and accepts no responsibility for any loss or damage resulting from the recipient receiving, opening or using it. If you need any further information, please contact the originator of this message on +44 (0) 20 7183 1471.
>>>>>>
>>>>>> PolkaSpots Limited is registered in the UK, number 05508105. Registered Office: 62 Britton Street (behind the bike sheds), Clerkenwell, London EC1M 5UY
>>>>>>
>>>>>> Website: polkaspots.com
>>>>>> WiFi Shop: shop.polkaspots.com
>>>>>> Blog: polkaspots.com/blog
>>>>>> ---------------------------------------------------------------------------------------
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Chat mailing list
>>>>>> Chat at lists.lrug.org
>>>>>> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>>>>>>
>>>>>>
>>>>> ---------------------------------------------------------------------------------------
>>>>> The information contained in this email and its attachments is confidential and may be the subject of legal, professional or other privilege. It is intended only for the named addressees and may not be disclosed to anyone else without consent from PolkaSpots Limited. If you are not the named addressee you must not use, disclose, distribute, copy, print or rely on the contents of this email and should destroy it immediately. Whilst PolkaSpots Limited takes care to protect its systems from electronic virus attack or other harmful event, the firm gives no warranty that this email message (including any attachments to it) is free of any virus or other harmful matter and accepts no responsibility for any loss or damage resulting from the recipient receiving, opening or using it. If you need any further information, please contact the originator of this message on +44 (0) 20 7183 1471.
>>>>>
>>>>> PolkaSpots Limited is registered in the UK, number 05508105. Registered Office: 62 Britton Street (behind the bike sheds), Clerkenwell, London EC1M 5UY
>>>>>
>>>>> Website: polkaspots.com
>>>>> WiFi Shop: shop.polkaspots.com
>>>>> Blog: polkaspots.com/blog
>>>>> ---------------------------------------------------------------------------------------
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Chat mailing list
>>>>> Chat at lists.lrug.org
>>>>> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>>>>>
>>>>>
>>>>
>>> ---------------------------------------------------------------------------------------
>>> The information contained in this email and its attachments is confidential and may be the subject of legal, professional or other privilege. It is intended only for the named addressees and may not be disclosed to anyone else without consent from PolkaSpots Limited. If you are not the named addressee you must not use, disclose, distribute, copy, print or rely on the contents of this email and should destroy it immediately. Whilst PolkaSpots Limited takes care to protect its systems from electronic virus attack or other harmful event, the firm gives no warranty that this email message (including any attachments to it) is free of any virus or other harmful matter and accepts no responsibility for any loss or damage resulting from the recipient receiving, opening or using it. If you need any further information, please contact the originator of this message on +44 (0) 20 7183 1471.
>>>
>>> PolkaSpots Limited is registered in the UK, number 05508105. Registered Office: 62 Britton Street (behind the bike sheds), Clerkenwell, London EC1M 5UY
>>>
>>> Website: polkaspots.com
>>> WiFi Shop: shop.polkaspots.com
>>> Blog: polkaspots.com/blog
>>> ---------------------------------------------------------------------------------------
>>>
>>>
>>>
>>
> ---------------------------------------------------------------------------------------
> The information contained in this email and its attachments is confidential and may be the subject of legal, professional or other privilege. It is intended only for the named addressees and may not be disclosed to anyone else without consent from PolkaSpots Limited. If you are not the named addressee you must not use, disclose, distribute, copy, print or rely on the contents of this email and should destroy it immediately. Whilst PolkaSpots Limited takes care to protect its systems from electronic virus attack or other harmful event, the firm gives no warranty that this email message (including any attachments to it) is free of any virus or other harmful matter and accepts no responsibility for any loss or damage resulting from the recipient receiving, opening or using it. If you need any further information, please contact the originator of this message on +44 (0) 20 7183 1471.
>
> PolkaSpots Limited is registered in the UK, number 05508105. Registered Office: 62 Britton Street (behind the bike sheds), Clerkenwell, London EC1M 5UY
>
> Website: polkaspots.com
> WiFi Shop: shop.polkaspots.com
> Blog: polkaspots.com/blog
> ---------------------------------------------------------------------------------------
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20140321/d4a1da51/attachment-0003.html>


More information about the Chat mailing list