How Auto bidding works in auction sites
I am having a question about Auction website. I am not asking about enti开发者_高级运维re process as I know that's impossible to answer here. I just need the lead with explanation
Explanation for Autobids booking :-
If user gives the High and Low value for bidding price with number of bids to place in that range. The system should place the bid automatically even the system in hibernate.
For example :-
High (Bid from) : 10
Low (Bid To) : 20
Number of bids : 5
Let us take current auction price is $11 .Then the machine is active, so it should place a bid with randomly generated time interval.
I did these closely in jQuery. But it should work even it hibernate.
This technique is already used in many live auction websites like
- http://www.beezid.com/
If you login then you can see the machine in auction details page. If you have any previous experience please share it. Does Cron job make sense?
My table structure is mentioned here.
What technique is used for this? How can I do this?
If it's for your own site, then what I would do when any bid is placed on an item, simply check for other auto bids on the same item and apply any which are relevant looping until all auto bids are processed.
Handling auto bidding should be a server side process, where the server get's the value of your high and low bid, and number of bids your willing to make and saves it in a database. This ensures that while you can go somewhere else, surf to another page, that your wishes will still be carried out.
Now, you say this should be done as a second, by second process, but really on the server side the state does not change each second. The state only changes when someone makes a change (f.e. a new bid is placed.) Once a new bid is placed it will check to see if the price of the current bid is within the auto-bid range and follow the process below.
On the server side, the server will collect all auto bids for a current auction. The price of the current bid will be checked to see if it is in range of any auto bid and it will make a list of all auto bids within the range. From here, it processes the auto bids until the price is no longer within range of any auto bids.
First you need a cron job to end the auction and calculate the outcome. That cannot be avoided.
About autobidding it could be simply run when the user places a bid, no cron needed. Your script would do:
- Get the current user's max autobid. (the user that posts the form)
- In the same script run the competition for this action instantly. It it is logical that you would compete only against the current highbidder, because he already outbid the others.
- Get the user that have bigger max bid (one of the both).
- Place him as current highbidder and place for bid the "competitor's max bid" + "the min bid increment"
- Send messages (e.g. email) for what happened to both.
No need of any cronjobs here, all happens instantly
Further if you need to show live biddings, you need an ajax script that fetches the current highbidders in a short period, like 10 secs or minute.
If the client machine is off, then the process is obviously running on a/the server.
Are you trying to add this functionality on your own auction site, or trying to create automated bids on someone else's auction site?
If the former, then you could fire a cron job every minute to see what bids to make. Or you could have a database trigger that looked to see if someone had been outbid and make a new (pre-arranged) bid on their behalf.
If this is someone else's auction site, the your machine must be powered up to make this request of their server.
(Or, this could just be link spam for the two sites listed...)
Hope that helps.
I would not use a cronjob or similar for that.
The principle is easy summarised:
Use new bid
and new created auto-bid
as trigger - no cronjobs or similar. The leader is the one having highest limit. The current price is the 2nd highest limit + bid-step
.
Consider making a loosing bid
from the 2nd highest user right before doing the current leading bid. Therefore it's more transparent for users why auto-bid from leader went that high.
You have to think about some special cases when two auto-bid
having the same highest value etc., but that would make my answer a wall of text. And these cases are easy to handle. (i.e. taking the user with oldest auto-bid creation date as leader.)
And here some reasons why a cronjob is a very bad idea (in my opinion):
- It is slower because it works with an interval. Solution above works with triggers that fire immediatly when needed.
- It consumes more resources than necessary. Solution above works with triggers that fire if and only if something have to be done. Cronjob solution runs over auto-bids over and over again while doing nothing than consuming cpu time, producing disc I/O etc. most of the time.
- Cronjob solution has performance race condition. Job must be finished until next job interval begins. When you have an interval of 1 second every update process must be finished in less a second or they get overlapped. Or you have to sync this ...
And you do not need a cronjob for ending auctions, too. Auctions are ending at a specific date/time and when it is in the past the auction is over. Further bids are not accepted. No need for cronjob here, too.
For auto bidding there will be a field in the database. If it is set for auto bidding we will set a cron job run in server which will run in certain period and check the autobid flag and update the bid
my suggestion is to work out the bidding to each client when they retrieve the html page. e.g When i get to your auction site, your server says that there is a user that auto bids every 5 seconds since 3pm if the high and low is in range and is lower than amount of bids, and if it is now 4:33 pm then calculate the current bid based on time passed since 3pm.
Now the html that I will recieve will update every second on the my browser displaying the current bid, and auto bidding for the previously mentioned user every 5 seconds. Once I bid on an item the server will retrieve the current bid for the item and returns me as the current bidder, if my bid was the highest, or someone else's bid if their bid is higher.
This will make it seem as though it all happens in realtime.
I may be dense here, but isn't it just
- new bid
- highest Low (brr) wins (for instance: Hi/Lo/Step=10/20/5), lets call it A
- get next highest Low ( for instance Hi/Lo/Step=11/17/6) lets call it B
- set new price to
A(Lo) - ( ( A(Lo) - A(Hi) ) / A(Step) ) * FLOOR( ( A(Lo) - B(Lo) ) / ( ( A(Lo) - A(Hi) ) / A(Step) ))
- step 'width' ==
( ( A(Lo) - A(Hi) ) / A(Step) )
=(20-10)/5
=2
- to clarify: target is
A(Lo) - stepwidth * FLOOR((difference between A & B)/stepwidth)
20 - 2 * FLOOR( ( 20-17 ) /2)
=>20 - 2 * FLOOR(3/2)
=20 -2 * 1
=18
for A
Or does the bidding have to be 'played out'? (or having missed doing any action/bids in my life (fixed price or negotiation all the way) am I missing some social education)?
Just guessing but are you trying to write a penny auction with live countdown for closing time and constantly updated bid amounts? With several items on a single page with all this happening?
Best answer: Use iframe for each item on the page, have them refresh every 2 seconds, check the database for info and display bid info in iframe. You can use a java countdown ticker for live close time countdown display in each iframe window as well..
精彩评论