jquery - notification and messaging system in javascript and php (without the need of having to install additional software serverside) -
i'm running social network messaging , notification feature. each time user sends message or places notification user, row inserted table news_updates details message or notification , friends inserted news_seen table. (once message read, or item related notification opened, seen set 1, i'm doing @ end of callback function ajax request - i'm gathering newsitem_ids news items, open , i'm doing big insert newsitem_ids in it).
news_seen: newsitem_id bigint, user_id big int, seen int default '0'
at moment, i'm running ajax request every 3 seconds, check news_updates join news_seen news.
this turns out huge server load i'm getting more , more users. i've been reading lot xmpp , , think push notification service great site.
the thing is, can't decide on way go, since there many options.
also, thought creating own system. i'm planning this:
create xml file each user on initial registration (and run batch registered users)
once user sends out news update (i have own php function writing them db), include small command manipulate xml file respective friends
instead of doing 3sec ajax request, i'd establish long connection xml file using jquery stream , in case changes made since last request, i'd usual ajax request polls data db.
instead of running check_seen inside ajax request, i'd insert new items global array, used intervaled function tests if item in list being viewed.
do think idea?
to honest not think implement specification.
- for example use lighter data-model xml. use json instead.
- i avoid touching disc(database) as possible(slow).
- doing 2 requests instead of one(long-polling/polling). try avoid this.
- i try avoid wasting cpu-time not using interval functions, calling function when needed. use redis's pubsub.
- polling / long-polling (most of times) bad idea in php because of blocking io. found interesting project named react believe non-blocking io(expensive). have not tested this(the performance) myself, option.
- for xmpp have install additional software. instance liked prosody it's easy installation/usage. need have @ bosh. bosh client use strophe.js or jsjac.
- i use socket.io, faye or maybe vertx.io instead, because scale lot better.
Comments
Post a Comment