Creating a realtime application would require the knowledge of the technologies, paradigms and protocols involved according to the use-case you are implementing for.
However even after acquiring this knowledge, it's pretty complex to implement all of these from scratch yourself. The usual way would be to use one of the PaaS or IaaS services/APIs that are available out there like deepstream.io, pusher, socket.io, Firebase, etc.
I've extensively used deepstream.io. It is an open source realtime server with both websockets and http support. Hence, IMO it would be a great option. They have a community that is responsive to any queries in case you get stuck somewhere while implementing it.
Hope this helps.
Mev-Rael
Executive Product Leader & Mentor for High-End Influencers and Brands @ mevrael.com
In 2017 real-time web app is only about a WebSockets (WS). It's easy to use in browser, however, setting up a server for some people might be an issue.
There is also something called WAMP (Web Application Messaging Protocol) (do not confuse with WAMP server), it's a WebSocket sub-protocol which allows you to do pub/sub, auth and other stuff.
On the Implementations page you may find many libraries in different languages. In JS one of the most popular is Autobahn.js. Problem here is the size of code and a lot of extra complexity.
Another problem is, many servers doesn't support WAMP v2 or even WAMP v1 and using plain WebSockets is a much easier and safer way. For PHP I would recommend Ratchet based on ReactPHP
I am currently working for BunnyJS simple standard for plain WebSockets communication which allows pub/sub without WAMP and big libraries like Autobahn. It's gonna be a simple JSON communication standard and client-side JS component is very small. Server push also is implemented easily, server just connects to WS server, WS server detects host 127.0.0.1 and thus doesn't adds a connection to clients array.
Each message (both sent from client to server and from server to client) must have
typeproperty which can be, for example,SUBSCRIBEaltogether withchannelname anddatakey might store all user data.WebSocket server also should not do any complicated job, it only transfers data from client to client or from server to client (push). You have main web server, you have stand alone small worker which listens for websockets and you have client which connects to websocket server after connecting to web server. When user created a new post and you want to display a notification, server handles writing itself and only does a push to websocket server transferring small amount of data, then websocket server transfers that information to all related clients (for example all connections subscribed to specific channel)