i learning web programming. started learn more internet protocols , other internet applications.
so wanna understand how whatsapp working? using xmpp , code communucate server. whats happening @ background?
how whatsapp speaking server? whatsapp's xmpp server ip? type of format using app when communucating server? , why nobody can using directly on pc? if whatsapp communucation software means can communucate server device or os right? couldnt found example it.
and after signed in whatsapp phone number first time sending me sms , making verification. after how whatsapp recognizing me? mac adress? or other special key?
what happens if recognizing key or mac adress same in 2 different devices 2 different ip adress? can server understand it? 1 of them took message or both?
so wanna learn whats happening @ background of whatsapp?
thanks in advance...
keep calm, not trying hack whatsapp servers ;) :p
whatsapp or of other messaging apps work on peer peer basis. wouldn't open connection (from device) each of friends' devices. instead device connects server. use custom tcp protocol or maybe http communicate messages server. server in return dispatch them friends' devices. if friend had app open or @ least app process running there might live connection server. whatsapp use connection send them messages. if app "offline" might choose send them push notification instead. whatsapp has chosen erlang language built writing scalable applications designed withstand errors. erlang uses abstraction called actor model it's concurrency - http://en.wikipedia.org/wiki/act.... instead of more traditional shared memory approach, actors communicate sending each other messages. actors unlike threads designed lightweight. actors on same machine or on different machines , message passing abstractions works both. simple implementation of whatsapp be: each user/device represented actor. actor responsible handling inbox of user, how gets serialized disk, messages user sends , messages user receives. let's assume alice , bob friends on whatsapp. there an alice actor , bob actor.
let's trace series of messages flowing , forth: alice decides message bob. alice's phone establishes connection whatsapp server , established connection alice's phone. alice sends via tcp following message: "for bob: giant monster attacking golden gate bridge". 1 of whatsapp front end server deserializes message , delivers message actor called alice. alice actor decides serialize , store in file called "alice's sent messages", stored on replicated file system prevent data loss due unpredictable monster rampage. alice actor decides forward message bob actor passing message "msg1 alice: giant monster attacking golden gate bridge". alice actor can retry exponential back-off till bob actor acknowledges receiving message. bob actor receives message (2) , decides store message in file called "bob's inbox". once has stored message durably bob actor acknowledge receiving message sending alice actor message of it's own saying "i received msg1". alice actor can stop it's retry efforts. bob actor checks see if bob's phone has active connection server. , bob actor streams message device via tcp. bob sees message , replies "for alice: let's create giant robots fight them". received bob actor outlined in step 1. bob actor repeats step 2 , 3 make sure alice receives idea save mankind.
whatsapp uses xmpp protocol instead of vastly superior protocol outlined above, point.
for own application things consider: might not have control on clients sending gps coordinates server every 10 minutes. if client running on mobile device, os might decide starve resources or kill process. need maintain state clients connected server make sure can send messages active clients when requirements met. slight modification of stock "comet app" example every framework has. establishing tcp connection not big waste of resources either client's side or server's side. if server software ecosystem supports non blocking io, state required per connection tiny. support upwards of 100k connections on mediocre box if tried hard. if on jvm netty might here. python has twisted , tornado. c++/ c can make use of epoll, kqueue or select if on *nix system. golang supports high number of connections through it's standard library. have addressed vertical scalability here i.e. how many users support on simple box. if want scale out , build distributed system maintains state, might want consider erlang (with otp) or other implementations of actor model, akka (jvm) supports remote messages. combination of event sourcing , message passing architecture horizontal scalability need.
Comments
Post a Comment