Is Redd thread-safe?
Is it safe to share a Redd session between two or more threads? Or should I create one Redd session per thread?
Posted Oct 16, 2017, 9:35 PM UTC
32
Is it safe to share a Redd session between two or more threads? Or should I create one Redd session per thread?
Posted Oct 16, 2017, 9:35 PM UTC
Hi again! I'd recommend creating a unique Redd session per thread. Redd typically doesn't hold any shared state, but two issues come to mind when talking about thread-safety:
Kernel#sleep, which isn't exactly thread-safe. You can turn it off usinglimit_time: 0when creating the Redd instance, but I would turn it up from 1 second (default) tonseconds if you're making requests fromnthreads.It's all a lot easier if you create separate instances for different threads. Sorry about the late responses, I've been busy. Hope that helps!
Okay, thank you for the guidance. I went ahead and made it a ConnectionPool of Redd instances. It works like a charm, and everything is much faster to boot.