/ elixir

Real time web app - The future of web development

Web app had heavily evolved from times when web app was just meant to display some data using markup languages. There was a time when every software needed to be installed in every machine that want to use the software. Improvement in server side technologies, browsers and internet speed have fueled the phenomena of SAAS (Software As A Service). The rule of building a software has changed drastically. Most of the software that are developed today is developed by considering "use from any machine at anytime philosophy". There is a boom in SAAS market. More and more SAAS services are popping up and competing for space in the market. This has given rise to of several technologies and frameworks to support the need of s/w industry to build a feature-rich web app.

Most of the SAAS provider have started realizing the need of real-time web app. This traction in real time web app development space is also made visible by various frameworks and technologies that are providing built-in support to build real-time web application. Now web app are not just limited to traditional request-response cycle between client and server. Web app has definitely come a long way from just displaying some content from database to support real-time data sync between client and server. Real-time web app is the future of web development. More and more SAAS services today support some kind of real time feature. Few years back the real time web app had only few use cases like chat application. But now people are exploring other use cases for real-time web app. Companies like Dropbox have realized the need of real time support for their product and they started providing real-time editing of document by multiple users. Different companies are exploring different use case of real-time web app, so that it can be integrated with their already existing app. On of the use case of real-time web app that is under high exploration is collaboration between app users in real time. Collaboration between app users provide app owner to retain their users. The user who collaborate with others using an app is less likely to leave the app unless everyone with which he collaborates moves on. Highly collaborative app would have loyal user base than other app. This is why bigger company like Flipkart are investing in adding some real time support to their app so that user can collaborate in real time. Flipkart had recently integrating chat feature in there app so that user can meet online, chat and shop together.

Enough of talk on how web has changed over time. Let's see how this has impacted technology. Does this trend really matter to developers? Surely it does. Any little movement in technology worlds requires a special attention from the people working on this technologies. We as a developer have to recognize this trends and bend our self to blend with this new trends. You might have heard the proverb "Trees that don't bend with the wind, won't last the storm". This applies to technology world too.

We will talk about technologies which have realized this trends. Real time web app looks not so well suited for Ruby on Rails. People have lots of problem in scaling their Rails app with real-time support. Moreover there is no out of box support for websockets in Rails. Rails developer generally use third party like https://pusher.com to build real-time web app. This trend have been seen by the Rails core team and yes we will have out of the box support for websockets built in Rails 5. It might still have problems with scaling though, but definitely it’s a step in right diection. Other frameworks have also recognized the need to provide support to real-time web app. New frameworks like sails js had been build with websockets support in mind. Sails js specifies in its documentation that "Sails treats both HTTP and WebSocket requests as first-class citizens". They heavily emphasize on built-in support for real-time app. Web frameworks like Phoenix for Elixir also treats websockets as the first class citizens. Supporting real time web app is core to Phoenix framework. There have been lot of work done by Phoenix core team to allow scaling of real-time web app. They recently scaled a single node to support 2 million connection simultaneously. If you interested, you can check here about the great efforts they have put forward to attain this numbers Phoenix - 2 million connection with single node. Meteor js is another framework which supports websockets without having to write a single line to deal with websockets. You can just bootstrap a project and start the development of real-time app without integrating external services or writing any extra line to support real time app. These frameworks have paved a way to accelerate the development of real-time web app.

Now the question is on us. What is holding us back to make the real time app? Why are some developers neglecting use cases for real-time app? Though real-time web app has received some adoptions and lot of research is going on in this field, there are some caveats to it. Scaling is seen as one of the issues for real-time web app. Scaling real time web app is harder then scaling app that don't support real-time feature. For every data change for which clients have subscribed to, server had to broadcast this message to all the connected client. This requires server with higher configuration which comes at high cost. This heavy investment on server will not always be viable for all businesses. But frameworks like Phoenix is changing this and making cost-effective scaling possible. Phoenix is a framework build on Elixir which in fact runs on Erlang VM. Erlang VM is the power house behind scaling of Phoenix framework to a extent where a single node can handle 2 million simultaneous connection. Isn't is awesome? There is also another caveat to building real-time web app. When we build a real-time app we have to write extra code not only on server side but also on client side to handle real-time communication. Sometimes code on client side may become too complex. We have to handle and manipulate data on client side too. It may look like we are having two databases one on client side and one on server side and we are repeating lots on functionality between both client and server. This is the same problem that single page applications face today. Meteor js have taking a right step to solve this problem by allowing client and server to share common code. It's nice to see how frameworks like meteor js have blurred the gap between server and client by using javascript on both sides.

I think much of the thing holding developer community back from developing real-time web app are being addressed by new frameworks like salis js, meteor js for node js and phoenix for elixir. It is the right time to look into the use cases of real-time app and align them with business needs and build a great product. I hope this article may have created some excitement in your mind and may lead you to get you hands dirty with real-time web app.