troubleshooting Question

Alternatives to Rand() or mt_rand() - interested in perspectives.

Avatar of erzoolander
erzoolander asked on
PHP
6 Comments1 Solution218 ViewsLast Modified:
I have an app that I'm developing.  It's essentially a voting app - where user submissions are reviewed/voted upon/etc.

On the server side, when I originally began developing it, I figured the most democratic way of approaching submission selection would be through a randomized function like rand() or mt_rand().  In practice, however, both are turning out to be pretty crappy solutions since it's not true randomization.  We currently have about 300 submissions - and as we're doing testing it seems like 40-50 of those entries are disproportionately "randomly" selected relative to all of the other ones.  

So I'm thinking about approaching it a different way - each of which has it's potential pitfalls.

#1 - return to the app an array of all possible submissions - and have the app just iterate through them.
Pros of this: Every entry - provided the user keeps progressing - has a shot of being reviewed.
Cons of this: The array could potentially get quite large...which would mean at some point I'd have to segment it up (maybe only return a list of 100 possible candidates for review later on).
#2 - Instead of returning the list of possible candidates - handle the selection via sessions.
Pros of this: Every entry - provided the user keeps progressing - has a shot of being reviewed.
Cons of this: A huge number of open sessions possible.

What would you do in such a scenario?  I've read that large numbers of sessions being open simultaneously can cause memory problems...  How big of a concern ought that be?  Or - is there a different way you can picture to approach this issue?  :)

Thanks!
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros