We list cars on the platform that dealers can bid upon within a certain time frame. With the high frequency of cars coming in, multiple cars can get auctioned at the same time. Each car auction is allowed to run for a specific time duration and the time remaining for each car is displayed clearly on the app interface. To prevent auction sniping, we extend the closing time whenever any dealer bids in the last two minutes of an auction, implementation of which we will cover in another blog post. Once the timer ends for a particular car, the auction is closed and the dealer with the highest bid gets the car.

At the core of the auction platform lies the dealer’s ability to bid and view other bids in realtime. Similar to a traditional auction, a dealer can only bid an amount which is higher than the latest bid. They are also notified immediately whenever any other dealer outbids them. We also provide a comprehensive information of each car (car specifications, image gallery, detailed reports by Truebil car inspectors) which helps dealers in making an educated estimate of their bids. An initial minimum bid price is set using the Trueprice Engine (our proprietary in-house machine learning algorithm) which suggests a dynamic sale price for every car based on the car’s parameters.

Displaying realtime bid information

In a traditional auction, an auctioneer shouts (broadcasts) the current highest bid which allows other bidders to immediately place a new higher bid. Similarly, in the Truebil for Business app, since multiple dealers can bid on the same car (sometimes as many as 1000!), we need to display the latest bid amount to all bidders immediately in realtime. To build this, we needed a system that allowed all apps to listen to changes in the bid values for every live auction car without having to make API calls repeatedly.

Firebase and Django Architecture

Firebase and Django Rest Framework allow bids to propagate in realtime

Django REST Framework + MySQL

In our MySQL database, each auction is represented by a unique auction ID. We store additional auction information such as corresponding car ID, dealer IDs, dealer bids, minimum auction price, auction status, auction start/end times in appropriate tables. Through a POST API defined using Django REST framework, only new and higher bid values are accepted and stored. Further, database constraints defined in MySQL help to maintain integrity of unique bids against each auction id.

For closing the auction at its specified end time, we initiate a Celery worker. Celery is an asynchronous task queuing system that could be used for triggering jobs at a given time. In our case, a celery worker modifies the auction status to an appropriate state whenever the GMT time equals the actual auction end time.

Firebase

Firebase is a NoSQL cloud database that stores data in a JSON format. The realtime database provided by Firebase allows apps to listen to data changes for any JSON node or subtree in the database, keeping data synced in realtime with all apps connected to the database instance. Further, Firebase Realtime Database is easily scalable to upto 100,000 concurrent users and provides extremely low latency which is suitable for near instant bid amount sync.

For android apps, Firebase provides ValueEventListener interface that allows connected apps to read and listen to data changes to the content of a database JSON node.

Further, Firebase offers a suite of products such as Crashlytics, Analytics, Remote Config, etc. that are extremely crucial for efficient mobile app development, quality assurance and scaling.

Sending data from Django to Firebase

We use the python-firebase library to push new valid bid values for a particular auction to Firebase DB whenever users make a bid POST call to the Django servers. For every new bid on a live auction car, we send the auction id and corresponding bid amount and user id to the Firebase DB. Apps that have subscribed listeners to this particular auction id node will immediately receive the latest bid information. Stringent checks have been implemented to keep MySQL and Firebase DB synchronised.

Overall performance

At Truebil, we have set an internal benchmark for receiving new bid updates in a blink of an eye, i.e. in approximately 100ms or lesser.

Currently, the time taken for making the POST API call, parsing the API, updating MySQL DB, pushing bid values to Firebase and receiving the bid values through Firebase listeners is 250ms on 3G devices. Bid update times are even lesser on a stronger Wifi connection. This makes the latest bid price available to all other bidders almost instantaneously. We are also considering alternative technologies such as Firebase Admin SDK, web sockets, server push notifications that may significantly reduce the propagation delay while increasing the throughput.

Conclusion

Through the Truebil for Business app, we are providing an online platform for dealers to purchase cars by placing realtime bids on live auction cars. For providing instant broadcast of bids placed by other bidders, we are using the Firebase realtime database that fits perfectly with our preexisting MySQL and Django framework. Firebase has turned out to be an excellent BaaS (Backend-as-a-Service) for app development teams that are looking to integrate realtime data sync in their apps.

In our internal tests, we have been able to easily scale the platform for 5000 concurrent bids on a single car auction. Since Truebil for Business is still in its growth stage, we are confident that current level of testing is sufficient to release the app publicly. We are aware that going ahead there are going to be challenges in terms of scalability and bottlenecks in the service we provide, however our team is dedicated and continuously planning to scale further both in terms of concurrent bidders and concurrent live auction cars.