php - storing chat messages for chat app at backend -


i making chat app android phone gap , php @ end. first time building chat app,so m little confused how store chat messages,

  1. storing messages in database

    a. 1 row each message (but size of db gonna large , speed slow)

    b. 1 row messages not think

  2. storing messages in text file , appending feel gonna slow , hard maintain

  3. storing messages in xml time in parsing xml , storing complexity gonna create problem

so end no solution,please suggest me solution , m new forum patient @ silly mistakes , how big fishes fb,whats app store messages>

of 3 options go first option (part a) assuming meant relational db (like mysql). size of db large if keep everything. however. need keep everything? 1 option prune old messages periodically.

my preferred option nosql document db (something mongo) won't need model complex relational data. model each "chat" document. each chat have array of messages. way time new message comes in push on messages array relevant chat. consider archiving older messages in array if expected chats persist long time or generate lot of data.

after had done if speed still issue @ adding in memory caching (memcached or apcu or both). messages posted , retrieved cache popular chats going stay in memory giving nice speed boost.

how far go down path depends on needs.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -