GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

43
SAN FRANCISCO | 10.22.2014 powered by How eBay and Shutl Deliver Even Faster Using Neo4j

Transcript of GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

Page 1: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

SAN FRANCISCO | 10.22.2014

powered by

How eBay and Shutl Deliver Even Faster Using Neo4j

Page 2: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

Volker Pacherhttps://github.com/vpacher@vpacher

Page 3: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

Shutl

Page 4: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

ECOMMERCE IS QUICK & CONVENIENT

Page 5: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

PAYPAL FOR AWESOME DELIVERY

Branded, super quick delivery that people trust, embedded in merchant websites

Page 6: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

A B

Only cost effective means to deliver 10+ miles but slow and unpredictable

HUB & SPOKE

POINT TO POINT

Fast and predictable but cost prohibitive over longer distances

AB

Page 7: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

HUB & SPOKEPOINT TO POINT

97% Courier, Express & Parcel Market3% Courier, Express & Parcel Market

+7,500 more!

Page 8: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

Shutl generates a quote from each relevant available carrier

Best option picked based on price & quality rating

SHOP

££

£££

£

££

£

££

Page 9: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

On checkout, a job is sent via API into the chosen carrier’s transportation system

Courier collects from nearest store and delivers to shopper

SHOP

$$

SHOP

Page 10: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

Track your order online…

Page 11: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

FEEDBACK

Quality is paramountShutl sends feedback email to the consumer seconds after they have received delivery asking to rate qualitative aspects of experienceFeedback streamed unedited to shutl.com/feedback & facebook

Page 12: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

FEEDBACK

Page 13: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

FEEDBACK

Page 14: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

FEEDBACK

Page 15: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

FEEDBACK

Page 16: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j
Page 17: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

Version OneRuby 1.8, Rails 2.3 and MySQL

• Well-known tale: built quickly, worked slowly, tough to maintain

• Getting a quote for an hour time-slot took over 4 seconds

Page 18: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

Here is the Shutl price calendar

To generate this in V1, the merchant site would have had to call Shutl to get available slots (2 seconds)

Then, they would have to call Shutl to generate a quote for each slot - for two days of store opening, that’s 20+ slots

So, that’s 2 + (20 x 4) seconds, 1:22 to generate the data for this calendar

In V1, this UX could never have happened.

Page 19: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

V2

Page 20: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

• Broke app into services

• Services focused around functions like quoting, booking, and giving feedback

• Key goal for the project was improving the speed of the quoting operation, which is where we use a graph database

V2

Page 21: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

graphs to the rescue!

Page 22: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

relationships are explicit stored

Page 23: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

data modelling made easy

Page 24: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

additive domain modelling

Page 25: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

traversals of relationships are easy and very fast

Page 26: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

DB performance remains relatively constant as

queries are localised to its portion of the graph.

O(1) for same query

Page 27: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

a graph is its own index (constant query performance)

Page 28: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

the case for Neo4j

Page 29: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

single image graphdb

Page 30: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

standalone or embedded in jvm

Page 31: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

ruby/jruby

Page 32: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

ruby libraries - neo4j gem by Andreas Ronge (https://github.com/andreasronge/neo4j)

Page 33: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

cypher

Page 34: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

the neotech guys are awesome

Page 35: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

V1

V2

• Quoting for 20 windows down from 82000 ms to 450 ms

• Code complexity much reduced

Page 36: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

• Cypher is easy to learn (and more importantly, easy to remember)

• modelling our domain turned from a chore to an (almost) fun exercise and provided us with insights we could feed back into the business

• code maintenance has become much easier

• new feature requests from the business are implement faster and with less refactoring necessary

What did we learn - the good bits

Page 37: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

• There was a learning curve in switching from a relational mentality to a graph one

• Tooling not as mature as in the relational world

• No out of the box solution for db migrations

• Seeding an embedded database was unfamiliar

Some gotchas

Page 38: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

• Setting up scenarios for tests was tedious

• Built our own tool based on the geoff syntax developed by Nigel Small

• Geoff allows modelling of graphs in textual form and provides an

interface to insert them into an existing graph

(A) {“name”: “Alice”}

(B) {“name”: “Bob”}

(A) -[:KNOWS] -> (B)

• We created a Ruby dsl for modelling a graph and inserting it into the db

that works with factory_girl

• Open source - https://github.com/shutl/geoff

Testing was a challenge

Page 39: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

COMPANYSHUTL IS NOW AN

Page 40: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

powered by

Page 41: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

on

Page 42: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

Wrap Up

• Neo4j enabled Shutl to achieve big performance increases in its most important operation - calculating delivery prices and availabilities

• It’s a new tool based on tested theory, and cypher is the first language that allows you to query graphs in a declarative way (like SQL)

• Tooling and adoption is immature but getting better all the time

Page 43: GraphConnect 2014 SF: How eBay and Shutl Deliver Even Faster Using Neo4j

Thank you!

Any questions?

@vpacherhttps://github.com/[email protected]

Volker Pacher Senior Developer