Implementing Auto-Bidding Functionality with JSP/MySQL

17
April 16, 2019, at 02:00 AM

Currently working on a project and could use some advice for how to approach implementing an Auto-Bidding system for a web application similar to Ebay.

My issue is actually handling to 'Auto' functionality. On initial thought, I figured I could just do a MySQL trigger, however, I quickly learned triggers don't allow you to insert/update the triggering table.

The only other real solution I could think of would be handling this on the server side with Java, however, I could see this implementation having poor time complexity:

e.g.

The auto-bidding works in a way in where it creates new bid items 0.01 above any bid placed on the specified item by a different user, while the auto-bid limit has not been reached

If many users have auto-bidding configured this can iterate for quite a while, and at each iteration the system would be doing an update query and I would imagine this could get slow in any sort of production environment with real users...

Plus, if I did a server side solution, this means that when some given, unlucky user sends a one-time bid or configures auto-bidding, they will be waiting for the server to handle this work before getting a proper response.

While it would make sense in a scenario like this to just create a bid item corresponding the the highest auto-bid limit, I do need to run through this process of +0.01 back-and-forth to actual model an auto-system, unfortunately.

So, any ideas on a better way to go about this?

Answer 1

If you are the operator of both the auction and the autobidding system, you do not need any timer at all. The outcome is determined at the time you know all autobid limits and manual bids: the highest bid wins, tie breaker is usually the earlier bidding time (or whatever you come up with).

For your server, an autobid is the same as a normal bid, they just differ in how the user experience them. Your server only needs to know which bids exists and when they got added.

You can e.g. add and update the effective step bids every time an actual bid or autobid limit get changed. It doesn't even matter how long it takes to process it, the outcome will be the same. If 2 users e.g. add an autobid for $100k 0.2s before the deadline and one user adds a $101k bid 0.1s before the deadline, it will take you more than 0.2s to generate 10 million $0.01-steps. But to answer the most relevant question to most bidders, "Did I win and what do I need to pay?", you do not need to wait for the step creation process to end, you just need to look at the 3 bids and can immediately tell that user 3 wins and has to pay $100k and one cent.

Technically, you would not even need to store the steps in the database, since your serverside code could just generate those (determined) steps from the stored limits and bids every time someone wants to watch the detailed bidding process. This seems to not match your requirements though, but might be a feature. (You can call it "compression" or even "normalization").

To the user, you will obviously only show the resulting bids up to the current time. The client can autorefresh with a timer to make it more exciting (since, in contrast to you, he doesn't know yet who will win), but that is independent of your server side code.

READ ALSO
Calculate duration for bookings in a period between two time slots

Calculate duration for bookings in a period between two time slots

In a booking system I want to calculate the sum of hours a resource has been booked between two dates (2019-01-01 to 2019-01-02) from 8am to 4pm

13
MYSQL: Copy all data and structure if not exist

MYSQL: Copy all data and structure if not exist

i have two database new and old database

17
Mysql Select find third week and day of week from table date

Mysql Select find third week and day of week from table date

I have a MySQL select query that I am trying to get the third Thursday from a date in my table here is what I have for the query any help would be greatly appreciated

21
SQL query for joining four tables

SQL query for joining four tables

I am a newbie to writing SQL queries, Can anyone please help me write SQL query for below conditions and joins?

29