When there were thousands of users for suggestion, this method seems like cost 2-3 second. Then I google how to get random records by sql in rails, here is the result I got:
Model.first(:order => "RANDOM()") # postgres example
In this way, the solution could be
candidates = candidates.order("RANDOM()").limit(size)
This will more faster then the original code.
But different database get different rand function. See detail in this url:
http://www.petefreitag.com/item/466.cfm
I don't know how many kinds of database SocialStream need to support. With a support list, it might could optimize it with a method to get current random func for current database.
Anyway, for somebody who got this problem, could just use the decorator to rewrite this method.