jondot / sneakers

A fast background processing framework for Ruby and RabbitMQ
https://github.com/jondot/sneakers
MIT License
2.25k stars 331 forks source link

Shared memory space for all workers #413

Open khataev opened 4 years ago

khataev commented 4 years ago

Hi! I'm just curious is it possible to implement such behaviour. The case is that each of my workers establishes some connection to remote server (I'm fetching emails with IMAP protocol). So I'd like to have some kind of pool of established connections in advance. I want this pool to be available to newly spawned worker, so it could fetch connection instead of connecting again and again, wasting time and resources.

jbielick commented 4 years ago

Do you think leveraging the connection-pool gem would help here? You could add n connections to your server into the pool for your workers to share. Then you could limit the number of concurrent connections and reuse connections as long as their alive. The connection pool can handle reconnecting and making sure the pool has sufficient resources according to your limit.