---
# System prepended metadata

title: 'Req:'

---

# Req:
1.chat one - one
2.Web
3.Store Persitently chat history
4.Present status (online, offline)
5.Check read or not
6.Text 
7.Real time?? peer to peer ??
8.Number of users: 1 million
50:50 read/write


Extends:
1. Mobile
2. send message with attachments
3. chat group.


# Flow:
A Login -> A Choose contact to B -> A Type text -> Send to B -> Message saved on server
1.Reciever B active -> B Recieve text -> B Reply mess -> A Recieve mess
2.Reciever B unactive -> mess marked as send unread -> Reciever B active -> Read mess

# Db: FaceBook (MySQL for user, ralation), message in distributed data. Line Hbase
    HBaseH
    Cassandara
**CAP theorem**:

**Consistency**: 
    n node:
        write -> n -> w node xac nhan da write xong roi thi la write thanh cong
        read -> n -> r node da co data thi moi cho doc
        
        w + r = 


**Avaiability**: Write nhanh, nhung

**Partition Tolerance**:
    n -> 1 2 node is down : OK



1 Master => N slave: Write in to master only


Cassandara: **Leaderless**: Depend on Key: Write to multi server at the time <- Write nhanh hon sql
HBase:




ACID : ~ Transtion in SQL RDBMS 

Atomic        :
Consisten     :
Isolation     :
Durability    :




## --User:
UserId
friend list
mess list

## --UserStatus
UserId
Status
LastTimeActive

A: abc 10:01
B: hhu 10:02
A: jjj 10:02
A:hhh. 10:02

## --ChatMatch // Message In Conversation

Time
Sender
Reciever
Message 
Conversation_id <- 

## --Conversation
UserId
Contact list
Last time contact

## Protocal : 
Http Long polling 
WebSocket <- 

## System Design


User 1 
 
              chat server            DB
 
User 2 



 
