benmfaul / XRTB

A Real Time Bidding (RTB) 2.1 bidding engine written in Java 1.8
http://rtb4free.com
Apache License 2.0
121 stars 67 forks source link

why make new thread to each campaign instead of using some index tech when process bid request? #17

Open yyforever opened 6 years ago

yyforever commented 6 years ago

i have read the code. can't understand why not using index. if there is thousands of campaign. new thread for each one of them and foreach. i think it's unacceptable.

benmfaul commented 6 years ago

Your suggestion seems like the right way to go. However...

In practice the SSPs will make thousands of connections to the bidder, each one is already a thread spawned by Jetty, then you multiply that number of threads times the campaigns and your bidder performance will suffer dramatically.

Unless you are bidding at low percentages, statistically you will resolve a campaign, even in an O(N) manner quite quickly. So as long as you shuffle the campaigns first and every campaign gets a fair chance to bid, performance will remain good under high load.

-Ben Faul

On Sun, Nov 5, 2017 at 2:18 AM, Alex Yang notifications@github.com wrote:

i have read the code. can't understand why not using index. if there is thousands of campaign. new thread for each one of them and foreach. i think it's unacceptable.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/benmfaul/XRTB/issues/17, or mute the thread https://github.com/notifications/unsubscribe-auth/ACoB4jyIwUHFVbqM8csWX-GzcHK0tefrks5szYuQgaJpZM4QSU56 .

thedamnedrhino commented 6 years ago

Hello and thank you for the great library. Although could you elaborate on this a little more:

So as long as you shuffle the campaigns first and every campaign gets a fair chance to bid, performance will remain good under high load.

- I thought threads would be spawned for each campaign for every bid request regardless if it's going to be a no-bid or not.