What is the real need of building a server for a web application?

Viewed 104

I've been learning web development for the past 3 months, so I'm pretty new to it. Since 3 months, I've been working on the client-side of applications using React, and i can build somewhat usable websites using just this. I have even used firebase in some of my projects for the real-time database and for authentication as well. So, when i was able to do all this on the client-side, naturally i started to question the need of a server, or more specifically, server-side scripting. Everywhere I've looked, the most highlighted aspect of server-side scripting was dynamic rendering of webpages. But that can also be done on React and pretty easily. So what is the real need of server-side scripting? Why would I even want to build a server using a server-side language such as NodeJS?

4 Answers

To add to what others have failed to mention: cost and security.

The most valuable thing a company owns is its data. Some of that data is proprietary, some of it may be regulated by law, some of it is personal to a customer but needed in order to do business with them. That data has to be kept safe, and only given to people who are allowed to have it and will safeguard it properly.

Very very few companies allow their database hosts to be accessible directly from the internet. It makes it too easy for attackers to focus their efforts to get at that data.

API services, typically REST or SOAP, grant you the ability to verify someone is allowed to access the data in question, and refine and filter irrelevant data or data they aren't allowed to see from the query prior to sending it into the internet to an end user's computer. You don't want any more data to leave than absolutely necessary for the user to perform some meaningful action. This is for the same security concerns as above, but also to be nice to the user's machine. You don't want to bog their client down with data they don't need, as it slows everything else down.

From the cost angle, any computing you can do on the client machine is free. By moving as much as possible to the client, especially calculations applicable only to their session, that frees your service up to serve other requests for other users. Server side rendering was expensive to scale because every rendering cycle had to be calculated on the server for each individual, converted to html and sent back before the next request could be handled. In order to reliably serve more customers required many more server hosts to keep up with the traffic.

You need to be careful not to move too much to the client, as their device capabilities are unpredictable. It could be a phone, an old laptop, or a gaming pc. If you assume everyone is on a gaming pc and push too much to the client, you'll end up limiting your site to only being functional for users with high end computers.

As a final piece of advice, it never hurts to ask that question in class. Chances are your classmates would benefit from it as well.

Many reasons; e.g. you need interacting with a system, which the end user should have no access to (say writing something to a database), you can only do it server side (cause you don't want to expose sensitive credentials to end users). Also, if you pre-render dynamic content server-side, it will be consumed by search engines; if you don't it likely won't be.

Well firebase is a server side technology. And any website that uses any kind of persistence across different devices or browsers always have a server side services which are backing up this persistence. So anytime you have login or signup, or any other form of authentication or authorisation then its backed up by server side.

Previously most of the logic used to reside on the server side and the client slide was basically extremely dumb with maybe just some ui related logic, with the advance of SPA this pattern became less popular and today new apps are built with the mindset that whatever can be pushed to the client side then it should be in the client side.

A web app is just an app like any other - no different from a desktop app, mobile app, embedded app etc.

You can build a web app and use it personally and/or distribute it as you see fit. You don't need a web server. However, you might find at some point you need backend services to facilitate new capabilities you'd like to add. These services can be deployed in any way you see fit - centralised HTTP servers being most common with decentralised solutions possible too. But they are not mandatory.

Related