I have been testing some code lately and I found myself in a weird situation. Let me try to explain a bit. I have multiple pieces of code (more than 500) that do the following: - Parse a string - Parse a JSON - Parse an array - Run HTTP/HTTPS requests via Faraday
Basically they all work together in background to extract and parse data.
I have a 30/40 sidekiq workers that are working perfectly. At some point, randomly (but typically after 1 day) the workers get stuck. They normally take 1 second to 1 minute, at some point, HTTP/HTTPS workers get stuck and takes forever and the system gets slower and slower.
I have read from different places like: - https://github.com/mperham/sidekiq/issues/862 (HenleyChiu commented on Oct 5, 2013 - and few others) - https://github.com/mpowered/sidekiq-nag
That sometimes Sidekiq workers get stuck and people are writing codes (or hacks) to restart Sidekiq if this happens. Did you guys find the same problem with Sidekiq especially if the background job is related to HTTP/HTTPS request?
So my questions are:
- Anyone found him/herself in a similar situation? What did you do?
- Is there a way in the background job to ensure that all the HTTP/HTTPS connections gets dropped? Like for example I can ensure to close all MYSQL connections with the following code (at the end).
- Is it actually HTTP/HTTPS that might create issues in Sidekiq? Is there a way to kill pending HTTP/HTTPS connections? Not sure as using Timeout in Ruby is not ideal...
Anyone has some example of code that want to share or some ideas on how to fix it?
ensure
ActiveRecord::Base.clear_active_connections!
ActiveRecord::Base.connection.close
Thank you very much and I look forward to hearing from you.