couchbase_tlv_2014_couchbase_at_liveperson

39
I get by with a little help from my friends Ido Shilon | 7/22/2013

Upload: couchbase

Post on 29-May-2015

22.538 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Couchbase_TLV_2014_Couchbase_at_LivePerson

I get by with a little help from my friends

Ido Shilon | 7/22/2013

Page 2: Couchbase_TLV_2014_Couchbase_at_LivePerson

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?

Page 3: Couchbase_TLV_2014_Couchbase_at_LivePerson

@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)"

]

}

Page 4: Couchbase_TLV_2014_Couchbase_at_LivePerson

8,500

customers

Creating Meaningful Customer Connections

LivePerson is…

SaaS pioneer since 1998

Mission

Customers

Technology

Page 5: Couchbase_TLV_2014_Couchbase_at_LivePerson

Optimize Customer Acquisition & Reduce Bounce Rate

Live engagement for lingering customer Rich multimedia to

drive sales closure

Recommended use case

Page 6: Couchbase_TLV_2014_Couchbase_at_LivePerson

Technology @ LivePerson

Application Stack

JVM heavy - Java & Scala

Private cloud based on openstack

Linux on commodity servers Client side – js, backbone, iOS and Android

Page 7: Couchbase_TLV_2014_Couchbase_at_LivePerson

Data @ LP

13 TB per  month 20 M

Engagements  per  month 1.8 B Visits  per  month

VOLUME

Page 8: Couchbase_TLV_2014_Couchbase_at_LivePerson

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

Page 9: Couchbase_TLV_2014_Couchbase_at_LivePerson

Web agent console

Enables your agents to interact with

website visitors

Improve agent efficiency

Reduce chat time

The use case

Page 10: Couchbase_TLV_2014_Couchbase_at_LivePerson

The story - once upon a time

Visitor’s Events

Agents console (Java app)

Web Tier

Visitors

Page 11: Couchbase_TLV_2014_Couchbase_at_LivePerson

And then the story continues

Data center 1

Data center 2

Kafka & Strom (Event bus)

Web Agent

???

Page 12: Couchbase_TLV_2014_Couchbase_at_LivePerson

Possible solutions we considered

Page 13: Couchbase_TLV_2014_Couchbase_at_LivePerson

Why did we pick Couchbase

Always on

Linear scale

Searchable

Document store

Key Value

High throughput (R/W)

XDCR

Cassandra

Page 14: Couchbase_TLV_2014_Couchbase_at_LivePerson

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

Page 15: Couchbase_TLV_2014_Couchbase_at_LivePerson

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

Page 16: Couchbase_TLV_2014_Couchbase_at_LivePerson

Data modeling - doc

Visitor type doc

Document = Active visitor

Contain session level attributes

Multi tenant bucket

Views

Used for secondary indexes

Page 17: Couchbase_TLV_2014_Couchbase_at_LivePerson

{

"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

Page 18: Couchbase_TLV_2014_Couchbase_at_LivePerson

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

Page 19: Couchbase_TLV_2014_Couchbase_at_LivePerson

Couchbase in production

Page 20: Couchbase_TLV_2014_Couchbase_at_LivePerson

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

Page 21: Couchbase_TLV_2014_Couchbase_at_LivePerson

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

Page 22: Couchbase_TLV_2014_Couchbase_at_LivePerson

Couchbase in LP - Strategic choice

Visitor session store/ Server side cookie

Fast RW persistent store

Generic caching layer (Memcached

style)

RDMB replacement (MySQL)

Page 23: Couchbase_TLV_2014_Couchbase_at_LivePerson

Couchbase in LP – What are we looking for ?

N1QL

Inmemory indexing

Better security model

Page 24: Couchbase_TLV_2014_Couchbase_at_LivePerson

Summary

Who we are

Our journey

The problem we have encountered

We are not alone - Couchbase helped us

Page 25: Couchbase_TLV_2014_Couchbase_at_LivePerson

Thank You

We are hiring

Page 26: Couchbase_TLV_2014_Couchbase_at_LivePerson

Backup slides

Page 27: Couchbase_TLV_2014_Couchbase_at_LivePerson

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.

Page 28: Couchbase_TLV_2014_Couchbase_at_LivePerson

Couchbase in production - topology

Page 29: Couchbase_TLV_2014_Couchbase_at_LivePerson

Couchbase in production

Page 30: Couchbase_TLV_2014_Couchbase_at_LivePerson

Data modeling - doc

Non reduce views - used for

secondary indexes

Map reduce views – used for

calculating stats

Page 31: Couchbase_TLV_2014_Couchbase_at_LivePerson

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)

Page 32: Couchbase_TLV_2014_Couchbase_at_LivePerson

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

Page 33: Couchbase_TLV_2014_Couchbase_at_LivePerson

The story - once upon a time

Visitor’s Events

Agents console (Java app)

Web Tier

Visitors

Page 34: Couchbase_TLV_2014_Couchbase_at_LivePerson

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());

}

}

Page 35: Couchbase_TLV_2014_Couchbase_at_LivePerson

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); } }

Page 36: Couchbase_TLV_2014_Couchbase_at_LivePerson

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);

}

Page 37: Couchbase_TLV_2014_Couchbase_at_LivePerson

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

Page 38: Couchbase_TLV_2014_Couchbase_at_LivePerson

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

Page 39: Couchbase_TLV_2014_Couchbase_at_LivePerson

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