0

I have a RESTful web service- for which I wish to pick up 30% of the random requests which I need for training. Very easy to achieve- but I don't want to do any bookkeeping for the same- which adds an overhead. On a small scale this "small" overhead won't matter- but in case of internet scalability- this would be undesirable. Would anybody have any idea how I can achieve the same without the use of any counter?

PS: The sampling is unbiased- and all the requests can be treated as same. Currently I am maintaining a counter in the Django Middleware.

Ajay Pal Singh
  • 682
  • 1
  • 5
  • 16
  • Why not just `if random.random() <= 0.3:`? Over enough requests, that will give you 30% of them. – jonrsharpe Oct 26 '15 at 11:51
  • Makes perfect sense! For some reason I was trying to find a way around Probabilistic constructs- but sounds reasonable! Thanks a tonne! – Ajay Pal Singh Oct 26 '15 at 11:59

0 Answers0