title: Database design for a chat system
body: <p>I know there is a lot of posts out there discussing Db design for a chat system, but they didn't explain anything about the scalability of that design, so here my question.</p>
  
  <p>I want to design a Db of a real-time chat between 2 or more users, let's take 2 users first, here what I came up with.</p>
  
  <p><strong>Table 1:</strong></p>
  
  <p>name: <em>User</em></p>
  
  <p>fields: id, name</p>
  
  <p><strong>Table 2</strong></p>
  
  <p>name: <em>Chat Room</em></p>
  
  <p>fields: id, user1, user2</p>
  
  <p><strong>Table 3</strong>:</p>
  
  <p>name: <em>Message</em></p>
  
  <p>fields: Chat_room_id, user_id, message</p>
  
  <p>Now considering Facebook in mind, it has around 2 billion active users per month and let say 1 billion of them indulge in chatting and each user sends 100 messages.</p>
  
  <p>which make 100 Billion entries in table: <strong>Message</strong>, so the question is,</p>
  
  <p>"Will Mysql or Postgres be able to handle this much of entries and show particular chat room messages in real-time ?" if not then what should be the best practice to follow that, I know that it also depends on the server on which RDBMS is installed but still want to know the optimum architecture.</p>
  
  <p>PS: I am using Django as backend and AngularJs for asynchronous behavior </p>