I’d like to run a small amount of code asynchronously in my rails application. The code logs some known information. I’d like this task to not block the rest of the response from my app. The operation is way too lightweight and frequent for it to be done as a delayed job tasks.
I’m thinking to just use:
Thread.new do
# my logging code
end
and call it a day. Is this achieving what I want it to achieve? Are there any drawbacks?
Aside from handling some baseline resource contention things, this should be sufficient. The database resource comes to mind if you’re logging there…a file if you’re logging there. But the basic approach is fine I would think. Simpler is better…