The eBay Secret to Database Scaling
Join the DZone community and get the full member experience.Join For Free
tl;dr: ebay uses mongodb to perform a number of tasks involving large amounts of data. such projects include search suggestions, cloud management, storage of metadata, and the categorization of merchandise. the search suggestions are a key feature of their web site, and mongodb provides them with a way to provide these suggestions to users quickly.
what are search suggestions?
ebay's search suggestions at work. source: auctionbytes blog
when you begin typing in a query into ebay’s search box, a list of suggested completed queries will appear underneath the box. if one of these suggestions matches what you planned to type in, you can immediately select it by using the mouse or your arrow keys rather than having to type out the remainder of you search query.
this is a great feature to have for users, as it not only may complete the intended query, but can also bring up a similar query the user may prefer over the original one. the suggestions feature provides the user with a convenient and helpful way of searching for particular items of interest.
what has to be done
to provide such assistance requires a large amount of possible suggestions to be stored, and these must be returned extremely quickly to the user to be even remotely useful. ebay determined that any query to the database to return suggestions must make the round trip in less than 60-70 milliseconds!
this could be very challenging with a traditional relational database. ebay instead decided to try out a document store, mongodb, to see if they could achieve the needed performance.
how ebay implemented mongo
ebay made the search suggestion list is a mongodb document. this document was then indexed by word prefix, and in addition by certain pieces of metadata, such as product category. the multiple indexes provided them with flexibility in looking up suggestions and also kept the queries speedy.
ebay was able to use a single replica set which made sharding unnecessary. in addition, data was placed in memory, which again provided a speed boost for the queries.
database sharding visualized. source: cubrid shard
with all this in place, could the queries to the database still return suggestions to the user in the allotted time (less than 60-70 milliseconds)? as it turned out, mongodb was able to make the round trip in less than 1.4 milliseconds!
given this incredible performance, ebay was able to safely rely on mongodb to provide speedy search suggestions to its users.
could your business do the same?
if your business needs to query a large amount of data quickly, mongodb may be a good choice for you. one way to easily get mongodb working for you quickly is to use a provider that offers the database as a service.
morpheus provides mongodb (and several other popular databases) as a service, with easy setup and maintenance. the service is easily scalable, allowing you to add or remove space as your needs change. additional services include online monitoring, vpn connections to databases, and excellent support.
all databases are backed up, replicated, and archived automatically on an ssd-backed infrastructure, ensuring you do not lose any of your important data. so, try out morpheus today and get your data into a fast, secure, scalable database!
Published at DZone with permission of Gen Furukawa, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.