[nanomsg] Re: Concurrency problem

  • From: Robert Bielik <Robert.Bielik@xxxxxxxxx>
  • To: "nanomsg@xxxxxxxxxxxxx" <nanomsg@xxxxxxxxxxxxx>
  • Date: Sat, 28 Mar 2020 13:35:58 +0000

Question asked, question answered! RPiZ has only one core, thus, the number of 
tasks in queue = 2. Bumping up NNG_NUM_TASKQ_THREADS to 8 solved it.

/R

From: nanomsg-bounce@xxxxxxxxxxxxx <nanomsg-bounce@xxxxxxxxxxxxx> On Behalf Of 
Robert Bielik
Sent: Saturday, 28 March 2020 13:59
To: nanomsg@xxxxxxxxxxxxx
Subject: [nanomsg] Re: Concurrency problem

Oh, forgot to mention that the problem occurs when running this on a Raspberry 
Pi Zero (Raspbian Stretch with RT kernel patch).

It works fine on Windows 10.

Regards
/Robert

From: nanomsg-bounce@xxxxxxxxxxxxx<mailto:nanomsg-bounce@xxxxxxxxxxxxx
<nanomsg-bounce@xxxxxxxxxxxxx<mailto:nanomsg-bounce@xxxxxxxxxxxxx>> On Behalf 
Of Robert Bielik
Sent: Saturday, 28 March 2020 13:56
To: nanomsg@xxxxxxxxxxxxx<mailto:nanomsg@xxxxxxxxxxxxx>
Subject: [nanomsg] Concurrency problem

Hi all,

I have a problem that has me tearing hair off my head. Context: I have a system 
of servers which use nng (ipc) for communication (based on the request/response 
demo on nng github) . The calls are synchronous and fast. I also have a REST 
API built on nng which I use to control the main server 
(https://github.com/robiwano/siesta<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frobiwano%2Fsiesta&data=02%7C01%7Crobert.bielik%40dirac.com%7C1c4375e8fb6943a2a91e08d7d317cb5b%7C266f25c575d44d978f448d816a1f6a35%7C1%7C0%7C637209971456083367&sdata=zOGijmRfEF%2FTF2KzsClX%2BzBxHsPFdckl7RC7Zv9%2BqLc%3D&reserved=0>).
 One of the REST API calls is an “inverted callback” which hangs for ten 
seconds if nothing happens, but returns as soon as something is updated (but 
only for the webclients not doing the change, identified with a 64 bit ID). 
This in order to let multiple REST clients to be notified.

Now to the problem: As long as there is only one webclient using the REST API, 
everything works fine. But as soon as two are connected (i.e. with two 
outstanding “inverted callbacks”) everything grinds to a halt. It seems that 
the IPC communication stops working properly.
Now, since nng is used in the both the IPC parts and REST server, these parts 
share the underlying nng task management I would presume.

Can anyone spot anything obvious I’m doing wrong here?

Regards
/Robert
Ps. This is why I’m eager to use websockets instead of the “inverted callback” 
REST calls.
The information in this email (including any attachments) may contain 
confidential and/or proprietary material. Any review, retransmission or use of 
this information by persons or entities other than the intended, authorized 
recipient is prohibited. If you received this email in error, please notify the 
sender and delete the material. For information regarding how Dirac handles 
personal data, please visit 
https://www.dirac.com/privacy-policy<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.dirac.com%2Fprivacy-policy&data=02%7C01%7Crobert.bielik%40dirac.com%7C1c4375e8fb6943a2a91e08d7d317cb5b%7C266f25c575d44d978f448d816a1f6a35%7C1%7C0%7C637209971456083367&sdata=jinH%2B6c%2FDdpjLRK3UTC6e3sIudVfgWGx6cTnh0mTAxc%3D&reserved=0>.

Other related posts: