Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ebay, how do they end their auctions when time expired? [closed]

How does eBay end their auctions and mark the winner? Assume there is an auction end date in the database, once that time has passed the current time, the auction needs to be closed, mark the winner, etc. How is something like this handled in sql 2005? Do they query the db every second to find the expired auctions? Obviously they need to mark it as closed as soon as the auction ends. No way they are creating sql jobs for every single auction, or are they? Any ideas? I have an integration that follows a similar thought process and need help.

like image 926
Brian Salta Avatar asked Oct 21 '10 01:10

Brian Salta


4 Answers

Obviously they need to mark it as closed as soon as the auction ends.

Yes, but not necessarily real time.

How is something like this handled in sql 2005?

Not at all. A DB is a DB. For real time pricing / auction calculation youwould use a program. Basically, update the database, but dont run the logic from the database.

Do they query the db every second to find the expired auctions?

One way. Another is to have a list ofauctions sorted by expiration in memory and just check there which expire.

No way they are creating sql jobs for every single auction, or are they?

Likely not.

What I would do is keep a list of auctions in memory. Scalability by having X auctions per server.

like image 119
TomTom Avatar answered Nov 25 '22 23:11

TomTom


I would consider the state of the auction a result of the end-date of the auction and the current time. You don't have to make a change to the database in order for the state of the auction to change, the current time passing the auction end-date will do that for you.

A user viewing the auction will only view the state on a request basis, so the state can be determined at request-time. Any physical actions (sending email to winner) do not have to be true real-time. Just the closing of the bidding has to be; and the status can be determined on a per-bid basis

like image 31
ontrack Avatar answered Nov 26 '22 00:11

ontrack


I had imagined that an Auction record has an attribute like EndDate. No bids would be accepted beyond that point. When bidding, the client application would compare Now to EndDate. As well, the DB would check Auction.EndDate against Now() when attempting to log that bid.

I'm not sure that clients should be updating the auction.status="Closed" at all. That's a dependency on a client, where perhaps the DB shouldn't have to rely on a client to 'close' an auction. Suggest that should be predetermined, and not require intervention.

like image 25
p.campbell Avatar answered Nov 26 '22 00:11

p.campbell


My guess is a scheduler and a job/task queue where each the execution of each task is timed to coincide with the auction's exipiration. The scheduler periodically checks the queue, and when the auction's time has passed the task is executed. The task changes the auction's state to "closed," so bidding cannot occur after that poiint. That could also trigger some other actions like emailing the winner.

like image 41
Nate Reed Avatar answered Nov 26 '22 00:11

Nate Reed