Singleton Network Connection in Sidekiq Process shared among Multiple Threads.

22 views
Skip to first unread message

Rahul Gupta

unread,
Dec 21, 2016, 12:06:34 AM12/21/16
to Sidekiq
Hello Group,

I am confuse should I use singleton network connection for my application which process the logic in sidekiq job.

My application is using Net::LDAP which open/close a network connection on each request and these sockets are open/close very frequently.
I was asked to make a singleton class which gives me 1 socket using get_instance method on class and this socket will be shared among 10 threads of 1 sidekiq process.

I tried to use Mutex/syncrohnize to avoid race condition, but still there are multiple socket in system if I check using netstat.(Problem is still unsolved as of now).

Is it a correct approach or could you suggest how to keep 1 connection per sidekiq process.

Thanks,
Rahul.

Rahul Gupta

unread,
Dec 21, 2016, 12:15:04 AM12/21/16
to Sidekiq
Hello,

I forgot to add some details...


On Wednesday, December 21, 2016 at 10:36:34 AM UTC+5:30, Rahul Gupta wrote:
Hello Group,

I am confuse should I use singleton network connection for my application which process the logic in sidekiq job.

My application is using Net::LDAP which open/close a network connection on each request and these sockets are open/close very frequently and each connection socket is open/close in individual thread, so there is no sharing of socket among the threads in sidekiq process.

Mike Perham

unread,
Dec 21, 2016, 1:17:48 PM12/21/16
to sid...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Sidekiq" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sidekiq+unsubscribe@googlegroups.com.
To post to this group, send email to sid...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sidekiq/a5bf4536-f201-456a-968b-57beb4430493%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Mike Perham – CEO, Contributed Systems
Smart, effective open source infrastructure for your apps.

Rahul Gupta

unread,
Dec 21, 2016, 9:02:48 PM12/21/16
to Sidekiq
Thanks, will try that....


On Wednesday, December 21, 2016 at 11:47:48 PM UTC+5:30, Mike Perham wrote:
On Tue, Dec 20, 2016 at 9:15 PM, Rahul Gupta <rahu...@gmail.com> wrote:
Hello,

I forgot to add some details...

On Wednesday, December 21, 2016 at 10:36:34 AM UTC+5:30, Rahul Gupta wrote:
Hello Group,

I am confuse should I use singleton network connection for my application which process the logic in sidekiq job.

My application is using Net::LDAP which open/close a network connection on each request and these sockets are open/close very frequently and each connection socket is open/close in individual thread, so there is no sharing of socket among the threads in sidekiq process.
 
I was asked to make a singleton class which gives me 1 socket using get_instance method on class and this socket will be shared among 10 threads of 1 sidekiq process.

I tried to use Mutex/syncrohnize to avoid race condition, but still there are multiple socket in system if I check using netstat.(Problem is still unsolved as of now).

Is it a correct approach or could you suggest how to keep 1 connection per sidekiq process.

Thanks,
Rahul.

--
You received this message because you are subscribed to the Google Groups "Sidekiq" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sidekiq+u...@googlegroups.com.

To post to this group, send email to sid...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages