apache cassandra at narmal 2014

16
Narmal C*

Upload: planet-cassandra

Post on 05-Dec-2014

227 views

Category:

Technology


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Apache Cassandra at Narmal 2014

Narmal C*

Page 2: Apache Cassandra at Narmal 2014

● iOS / Scala / C* / AWS

Another Email App

● Email “broken” / “sucks”

Page 3: Apache Cassandra at Narmal 2014

Concept

Page 4: Apache Cassandra at Narmal 2014

ConceptConversation

Topic Topic

Email Email Email Email

Page 5: Apache Cassandra at Narmal 2014

CREATE TABLE conversations ( user_id uuid, ts big_int, recipients_hash text, PRIMARY KEY(user_id, ts);

Data Model - Conversations

Page 6: Apache Cassandra at Narmal 2014

Data Model - Conversations

1

INSERT INTO.conversations (user_id, ts, rec_hash) VALUES (1, ‘141...x‘, pr135t’);

INSERT INTO.conversations (user_id, ts, subject) VALUES (1, ‘141...y‘, ‘ra881’);

INSERT INTO.conversations (user_id, ts, subject) VALUES (1, ‘141...z‘, ‘pr135t!’);

141y:rec_hash

ra881

141x:rec_hash

pr135t

141z:rec_hash

pr135t

Page 7: Apache Cassandra at Narmal 2014

def mostRecent[T](models: List[T])(implicit tc: MostRecentItems[T]): Seq[T] = { models.groupBy(model => tc.member(model)) .map(_._2.headOption) .filter(_.isDefined) .map(_.get).toSeq .sortBy(model => tc.ts(model)).reverse}

Data Model - Edge Case

2x recipients_hash => ‘pr135t

141y:rec_hash

ra881

141x:rec_hash

pr135t

141z:rec_hash

pr135t

Page 8: Apache Cassandra at Narmal 2014

Data Model - TopicsCREATE TABLE topics ( user_id uuid, rec_hash text, ts bigint, thread_id, PRIMARY KEY((user_id, rec_hash), ts);

Page 9: Apache Cassandra at Narmal 2014

1 | pr135t

INSERT INTO topics (user_id, rec_hash, ts, thread_id) VALUES (1, ‘pr135t’, ‘141...x‘, ‘d97’);

INSERT INTO topics (user_id, rec_hash, ts, thread_id) VALUES (1, ‘ra881’, ‘141...y‘, c24);INSERT INTO topics (user_id, rec_hash, ts, thread_id) VALUES (1, ‘pr135t!’, ‘141...z‘, ‘d97’);

141y:thread_id

c24

141x:thread_id

d97

141z:thread_id

d97

1 | ra881

Page 10: Apache Cassandra at Narmal 2014

Data Model - Emails

CREATE TABLE emails_by_topic ( user_id uuid, thread_id text, ts big_int, id text, body text, PRIMARY KEY(user_id, thread_id), ts, id);

Page 11: Apache Cassandra at Narmal 2014

1 | d97

INSERT INTO emails (user_id, thread_id, ts, id, body) VALUES (1, ‘d97’, ‘141...x‘, ‘32’, “GO”);

INSERT INTO emails (user_id, thread_id, ts, id, body) VALUES (1, ‘c24’, ‘141...y‘, 99, “YEAH”);INSERT INTO topics (user_id, thread_id, ts, id, body) VALUES (1, ‘d97’, ‘141...z‘, 33, ‘ROYALS’);

141y:99:body

YEAH

141x:32:body

GO

141z:33:body

ROYALS

1 | c24

Page 12: Apache Cassandra at Narmal 2014

Concept 2

Page 13: Apache Cassandra at Narmal 2014

Concept 2Conversation

Email Email Email Email

Page 14: Apache Cassandra at Narmal 2014

Data Model - Emails 2

CREATE TABLE emails_by_conversation ( user_id uuid, rec_hash text, ts big_int, id text, body text, PRIMARY KEY(user_id, rec_hash), ts, id);

thread_id

Page 15: Apache Cassandra at Narmal 2014

1 | pr135t

INSERT INTO emails (user_id, rec_hash, ts, id, body) VALUES (1, ‘pr135t’, ‘141...x‘, ‘32’, “YEAH!”);

INSERT INTO emails (user_id, rec_hash, ts, id, body) VALUES (1, ‘ra881’, ‘141...y‘, 99, “GO”);INSERT INTO topics (user_id, rec_hash, ts, id, body) VALUES (1, ‘pr135t’, ‘141...z‘, 33, ‘ROYALS’);

141y:99:body

GO

141x:32:body

YEAH

141z:33:body

ROYALS

1 | ra881

Page 16: Apache Cassandra at Narmal 2014

Other● EC2

● Multiple data centers

● Spark