views:

30

answers:

3

Hi,

I'm building a custom CMS which allow user to post message to it. Messages are short and like tweets.

The problem is that these message are moderated by real moderators. And there are multiple moderators working on the messages stream at the same time. And my concern is that what if these moderator are processing a same message. This is both inefficient and inconsistent. Since one message can be rejected by one moderator and then passed by another.

Therefore I want to build some kind of mechanism so that the CMS can distribute these messages to different moderator and avoiding duplication. The CMS is expecting to deal with large volume of message in a short time. Therefore this problem become more serious.

Any Idea is appreciated. Cheers.

+1  A: 

I would do it like this:

  • Each logged-in moderator gets his own queue of messages to moderate
  • There is a central queue which will be used as a buffert
  • Posted messages go into the central queue
  • Each moderator queue fetches, say, 10 messages at a time.
  • When there's only 5 left in a moderator queue that queue will automatically fetch 10 new messages.

The downside is that you will need a central queue with a locking mechanism. If you want to avoid even that locking I propose one of two solutions:

  1. Remove the central queue entirely and post messages on-the-fly into one of the moderator queues (maybe a randmoly chosen one), or,
  2. Have a central queue and let each moderator have a randmoly chosen message from the top part of the queue (e.g., let them have one from the top-20). If there is "double moderation" due to absense of locking, just ignore the second moderation and accept the time-waste.
Emil Vikström
Great minds think alike ...
Toby Hede
Thank for the idea Emil.
TuanCM
A: 

You could have the moderators pull the message off a queue before moderating. Sort-of like a check-out? So the moderator clicks something that assigns them a number of messages to process. They deal with those, then grab another batch off the queue.

Toby Hede
Yep, and put items back on the queue if they are grabbed and then not moderated.
Matthew Schinckel
A: 

Have your update action for Messages do this

def update
  # perform regular update stuff ;)
rescue ActiveRecord::StaleObjectError
  flash[:message] = "Someone else has updated this message"
  redirect_to message_path(@message)
end

Check out http://railscasts.com/episodes/59-optimistic-locking or other pages on 'locking' (optimistic or otherwise) in Rails.

keeran
Heh misread the actual question, my suggestion prevents moderation conflict, not solving distribution of effort for you, sorry! :)
keeran
Thanks Keeran, very useful resource. I'll definitely use it.
TuanCM