Client-Server Architechture


Web applications basically involve two computers communicating with each other,
called a server and a client.



 
The server sits in the company office or data center, listens to HTTP requests, and
responds back with answers. The server also accesses the data (stored in a database)
that’s used by the web application.
The user uses their web browser to interact with the web application. The user’s
computer communicates with the server, sending HTTP requests and receiving answers.
Client computers may be a variety of machines, from smart watches to cell phones to
tablets to computers.
On the web, clients and servers communicate using HTTP (HyperText Transfer
Protocol). HTTP works as a request-response protocol between a client and server.


Server-Side Web Applications

A server-side web application is one where most of the application executes on the
server, and the client is only used to display HTML pages one at a time. When the user
performs an action in the web application, the client sends a request to the server, which
does something and returns a brand-new HTML page to be displayed on the client as a response. The web page is regenerated every time and sent back to be displayed on the client’s web browser




Client-Side Web Applications

Client-side web applications (also known as single page apps, or SPAs for short) are a
more recent phenomenon, and the computing industry is moving more towards this
model. Here, a lot of the application still executes on the server, but some code also
executes on the client (the web browser) to avoid the frequent regeneration of pages.
When the user performs an action in the client, it sends a request to the server, which
does something and returns information about the result—not an entirely new HTML
page. The client-side code listens for an answer from the server and itself decides what
to do as a response without generating a new page. Client-side web applications tend
to be more interactive and flexible because they can respond more quickly to user interactions—they don’t have to wait on the server to send back as much data. They only need to wait for the server to respond back with a result, rather than a whole HTML page.




Striking a Balance

So there are basically two types of web applications: server-side and client side (SPA).
If these are thought of as black and white, your web application should be somewhere in
the middle, in the “grey” area.

The server-side should remain the repository for the clever stuff—the business rules,
data storage, and settings should remain on the server and be invoked or retrieved from
the client-side when required.
The client-side (browser) should use the more modern client-side technology to
avoid full-page refreshes. However, it shouldn’t be too smart or too bloated. It should
know enough to do its job of interacting with the user and nothing more. It should
invoke code on the server-side to do smart things or perform business processes. It
shouldn’t have too much business logic, internal system data (data other than that data
the user can view or modify) or hardcoded information because that’s better managed
on the server.


Comments