I am using rakismet to check for spam in comments.
Right now, I do it in a before_create callback and I am wondering in a production site, if this is the most efficient way of doing it or should this be done by a background job.
Can you share your experience in terms of how much delay does this add to the responsiveness of your production apps?
I have not used rakisment
, but doing any pre-processing on an action will slow it down, and in the situation of your spam filter, it will slow down more and more as more spam indicators are included in the rakismet
dictionary.
I would recommend a two step process:
before_create
, do a minimal spam check to catch very obvious ones. You can search for words ("viagra", "cialis", "debt", etc), as well as check that the submitter isn't submitting many comments very fast. This will be fairly quick, and not slow your app down too much.This solution limits blatant spam immediately, and will eventually leverage the capabilities of rakismet
to clean up the comments entirely, without causing too much strain or slow down to the system.
One benefit of this approach is that it is extremely easy to scale your Delayed Job processes, but just starting more workers on the same (or different) server(s). This means that your main app won't crawl, as the heavy lifting has been offloaded to multiple instances of the worker process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With