skip to Main Content

i’m developing a website with auctions. I’ve programmed my own auction system. The auctions run for a specific period of time, and users place their bid. The highest bidder at the ending time wins the auction (just like ebay). When the user places his/her bid, database checking is done if that was the highest bid and if it is, then the bid gets placed, else not.

Everything works great but the problem is that, i have kept my two laptops aside, logged in from different accounts and submitted the bids at the exact time and both of the bids gets placed (both the bids are greater than the current highest and both are equal). Two equal bids cannot be placed on the same product right? and this happens if two users submit the bid at the same time.

Can anybody tell the logic to get rid of this problem?

2

Answers


  1. you need to implement a way to manage concurrent writes to the database. There are a couple of ways to achieve this. I suggest you start here : http://en.wikipedia.org/wiki/Lock_%28database%29

    Login or Signup to reply.
  2. I think if you work with timestamps to identify the exact point in time when the bids where submited you are not able to submit the bids at the exact same time. That would be a little miracle with timestamps counted in milliseconds.

    But if it happens you could choose randomly between the two bids.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search