couchbase_tlv_2014_couchbase_at_liveperson
TRANSCRIPT
I get by with a little help from my friends
Ido Shilon | 7/22/2013
Today’s programme
Who is LivePerson?
What was our journey?
Why was Couchbase chosen?
How did we build the new platform?
What can you take with you?
@idoshilon
{
name: "Ido Shilon",
age: 37,
kids: [
"illy"
],
wife: "Oshrat",
Title: "Group Manager @ LivePerson (Heading the
platform group)",
Lived_Worked_At: [
"Silicon Wadi (Israel)",
"Silicon Alley (NYC)",
"Silicon Valley (Bay Area)"
]
}
8,500
customers
Creating Meaningful Customer Connections
LivePerson is…
SaaS pioneer since 1998
Mission
Customers
Technology
Optimize Customer Acquisition & Reduce Bounce Rate
Live engagement for lingering customer Rich multimedia to
drive sales closure
Recommended use case
Technology @ LivePerson
Application Stack
JVM heavy - Java & Scala
Private cloud based on openstack
Linux on commodity servers Client side – js, backbone, iOS and Android
Data @ LP
13 TB per month 20 M
Engagements per month 1.8 B Visits per month
VOLUME
Data stack
LiveEngage DASHBOARD
MONITORING CHAT/VOICE system
Batch track Real-Time track APACHE KAFKA
STORM
COMPLEX EVENT PROCESSING
PERPETUAL STORE
RT REPOSITORY
Cassandra BUSINESS INTELLIGENCE
ANALYTICAL DB
Web agent console
Enables your agents to interact with
website visitors
Improve agent efficiency
Reduce chat time
The use case
The story - once upon a time
Visitor’s Events
Agents console (Java app)
Web Tier
Visitors
And then the story continues
Data center 1
Data center 2
Kafka & Strom (Event bus)
Web Agent
???
Possible solutions we considered
Why did we pick Couchbase
Always on
Linear scale
Searchable
Document store
Key Value
High throughput (R/W)
XDCR
Cassandra
Architecture
Couchbase Java SDK
Application server Tomcat
M/R views
cluster
M/R views
cluster
XDCR
REST API
Couchbase Java SDK
Storm Topology
Couchbase Java SDK
Storm Topology
Data flow
Visitor
Visitor Feed - Storm Topology
Agent
Kaf
ka
Couchbase
Visitor Monitoring
Service
(1) Visitor browsing
(2) Visitor events
(4) Write event to visitor document
(6) Return relevant visitors
(7) Return relevant visitors
(5) Get visitors List Every 3 sec
Visitor Feed API
(3) Analyze relevant events
Data modeling - doc
Visitor type doc
Document = Active visitor
Contain session level attributes
Multi tenant bucket
Views
Used for secondary indexes
{
"accountId": "64302875",
"id": 121640710013,
"rtSessionId": "643028754295878498",
"eventSequence": 5104,
"ipAddress": {
"fieldValue": "194.39.63.10",
"seq": 1
},
"browser": {
"fieldValue": "Chrome 27.0.1453.116",
"seq": 1
},
"state": {
"fieldValue": "LEFT_SITE",
"seq": 5104
}
......................................
}
Document structure
Multi tenant DB
Basic visitor
information
Sequence use
due to Kafka
Cross data center replication
Using Bi Directional replication (A/A)
Tips :
Key space is the same across the two
clusters (avoid conflicts)
Impact on the sizing
Couchbase in production
What did we learn till now ?
Test in production
Use the Couchbase sizing guidelines
RAM and IO (SSD) are key factors in
Disk write queue for views
Data stack now with Couchbase
LiveEngage DASHBOARD
MONITORING CHAT/VOICE system
Batch track Real-Time track APACHE KAFKA
STORM
COMPLEX EVENT PROCESSING
PERPETUAL STORE
RT REPOSITORY
Cassandra BUSINESS INTELLIGENCE
ANALYTICAL DB
Couchbase in LP - Strategic choice
Visitor session store/ Server side cookie
Fast RW persistent store
Generic caching layer (Memcached
style)
RDMB replacement (MySQL)
Couchbase in LP – What are we looking for ?
N1QL
Inmemory indexing
Better security model
Summary
Who we are
Our journey
The problem we have encountered
We are not alone - Couchbase helped us
Thank You
We are hiring
Backup slides
Sizing
Key name size(bytes) 100
Average value size(bytes) 10240
Number of replicas 1
Ram node size(GB) 64
Number of keys 2,000,000
Working Set (% of total dataset) 100%
Read ops/sec (sustained) 3,000
Write (Ins / Upd ) (sustained) 3,000
Deletes / Expirations / sec 3,000 Assumptions Same for remote cluster in case of bi-directional XDCR.
Same key space across the two clusters.
Couchbase in production - topology
Couchbase in production
Data modeling - doc
Non reduce views - used for
secondary indexes
Map reduce views – used for
calculating stats
Data sizing
• Numbers
o Avg doc size - 10 K
o Average key size - 10 characters
o 5 2nd level indexes
• Throughput (Final rollout)
o ~ 1 M concurrent documents/visitors
o ~ 100K ops/sec (heavy on insert/update)
Document structure
{
"accountId": "64302875",
"id": 121640710013,
........................
"pages": [
{
"pageLastAccessTime": "1372319894409",
"pageTitle": "Visit Site 64302875",
"pageUrl": "http://www.exaple.com/createSite.jsp?
server=hc1&siteid=64302875",
"seq": 4
},
{
"pageLastAccessTime": "1372323616982",
"pageTitle": "Visit Site 64302875",
"pageUrl": "http://hc1d/createSite.jsp?
server=hc1&siteid=64302875",
"seq": 980
},
]}
List of pages
the visitor has
browsed
Lists of
custom
variables
The story - once upon a time
Visitor’s Events
Agents console (Java app)
Web Tier
Visitors
Insert/Update
public Visitor getVisitor(String visitorSessionId) {
dalMetrics.addCouchbaseReadTotalCount();
Visitor visitor = null;
try {
String visitorDoc = (String) client.get(visitorSessionId);
visitor = gson.fromJson(visitorDoc, Visitor.class); } catch (Exception e) {
LOG.debug("Failed to retrieve or convert visitor: " + e.getMessage());
dalMetrics.addCouchbaseReadErrorCount();
throw e;
}
return visitor;
}
public void setVisitorWithFields(String rtSessionId, Visitor visitor) {
try {
client.set(rtSessionId, defaultTtl, gson.toJson(visitor)); } catch (Exception e) {
LOG.error("Error occurred while updating visitor fields: " + e.getMessage());
}
}
Views/ Design doc
Use the view to set the keys and sorting function (doc, meta) {
order = ....
if (order, doc.accountId, doc.visitStartTime.fieldValue) { emit([doc.accountId, order,
doc.visitStartTime.fieldValue],null); } }
Retrieve data
.../_view/by_accountid_state_timestamp?
limit=10&skip=0&startkey=["qa15020713", 0 ]&endkey=["qa15020713" , 9 ]
ComplexKey startKey = null;
// Create a new View Query
Query query = new Query();
query.setIncludeDocs(true); // Include the full document as
if (startValueToFilterBy != null) {
startKey = ComplexKey.of(accountId, startValueToFilterBy);
}
if (endValueToFilterBy == null && startKey != null) {
query.setKey(startKey);
} else {
ComplexKey endKey = ComplexKey.of(accountId, endValueToFilterBy);
query.setRange(startKey, endKey);
}
if (limit > 0) {
query.setLimit(limit);
}
if (skip > 0) {
query.setSkip(skip);
}
Send a message to our live service reps for immediate help
Me: Hi. I’m having trouble with reserving this flight.
Mitch: Hello. No problem, I can help you with that.
The Moment of Truth: Close sales from any location
Customer initiates chat to get assistance and close the purchase
25-30% of retail traffic is now coming from
mobile devices (source: LivePerson Connecting
with Customers Research 2013)
Customer is using wifi at the airport to change flight details (no global calling ability)
Orbitz Mobile: Saving a Sale
Customer having difficulty
booking a flight on a mobile
Data @ LivePerson
• 1.8 billion visitors monitored (sessions)
per month
• 20 million connections per month
• ~0.5TB compressed data is loading into
Hadoop each day
Kafka Storm
Why did we picked Couchbase
High throughput, really fast
Linear scale
Searchable (Views and M/R)
Supports both K/V & Document store
Cross data center replication
“Always on”, Resilience solution