Unit - 2
Unit - 2
Web Architecture?
Web architecture refers to the overall structure of a website or web application, including the
way it is designed, implemented, and deployed. It involves the use of technologies and
protocols such as HTML, CSS, JavaScript, and HTTP to build and deliver web pages and
applications to users.
Web architecture consists of several components, including the client, the server, the network,
and the database.
• The client is the web browser or application that the user interacts with,
• The server is the computer or group of computers that host the website or web application.
• The network is the infrastructure that connects the client and the server, such as the internet.
• The database is a collection of data that is used to store and retrieve information for the
website or web application.
• A server is the one who provides requested services. A server may serve multiple
clients at the same time while a client is in contact with only one server.
1-tier architecture: The data present in this layer is usually stored in local
systems or on a shared drive.
Caches
Caches take advantage of the locality of reference principle: recently requested
data is likely to be requested again. A cache is like short-term memory: it has a
limited amount of space, but is typically faster than the original data source and
contains the most recently accessed items.
How can a cache be used to make your data access faster in our API example? In
this case, there are a couple of places you can insert a cache.
Cache placement
• Request Node: collocate the cache with the node that requests
the data
o Pros
▪ Each time a request is made, the node can quickly
return cached data if it exists, avoiding any network
hops
▪ Often in-memory and very fast
o Cons
▪ When you have multiple request nodes that are
load balanced, you may have to cache the same
item on all the nodes
Proxies:
Proxies are used to filter requests, log requests, or sometimes transform requests (by
adding/removing headers, encrypting/decrypting, or compression).
One way to use a proxy to speed up data access is to collapse the same (or
similar) requests together into one request, and then return the single result to
the requesting clients. This is known as collapsed forwarding.
Another great way to use the proxy is to not just collapse requests for the same
data, but also to collapse requests for data that is spatially close together in the
origin store (consecutively on disk). Employing such a strategy maximizes data
locality for the requests, which can result in decreased request latency.
Indexes :
Indexes are helpful in the data access layers above the database.
Consider a system which is backed by multiple database clusters.
Creating an index that maps keys to the database responsible for
those keys would eliminate the need to query multiple databases.
An index can be used like a table of contents that directs you to the location
where your data lives.
In a distributed system, load balancers are often found at the very front of the
system, such that all incoming requests are routed accordingly. In a complex
distributed system, many load balancers may be used.
Queues : When systems are simple, with minimal processing loads and small
databases, writes can be predictably fast; however, in more complex systems
writes can take an almost non-deterministically long time. For example, data may
have to be written several places on different servers or indexes, or the system
could just be under high load. In the cases where writes, or any task for that
matter, may take a long time, achieving performance and availability requires
building asynchrony into the system; a common way to do that is with queues.
This kind of synchronous behavior can severely degrade client performance; the
client is forced to wait, effectively performing zero work, until its request can be
answered.
Queues enable clients to work in an asynchronous manner, providing a strategic
abstraction of a client's request and its response. On the other hand, in a
synchronous system, there is no differentiation between request and reply, and
they therefore cannot be managed separately. In an asynchronous system the
client requests a task, the service responds with a message acknowledging the
task was received, and then the client can periodically check the status of the
task, only requesting the result once it has completed. While the client is waiting
for an asynchronous request to be completed it is free to perform other work,
even making asynchronous requests of other services. The latter is an example of
how queues and messages are leveraged in distributed systems.
Web Application architecture (WAA) :
• Client-side (front-end): the code that’s stored in the browser and displayed
to a user. Users interact with the client-side of the application.
• Server-side: the code that application runs on the server and uses to communicate with
the hardware.
A web app architecture presents a layout with all the software components (such
as databases, applications and middleware) and how they interact with each other. It
defines how the data is delivered through HTTP and ensures that the client-side server and
the backend server can understand.
Web application architectural patterns are separated into many different layers or
tiers which is called Multi- or Three-Tier Architecture. You can easily replace and
upgrade each layer independently.
Presentation Layer: This layer is accessible to the client via a browser and it includes
user interface components and UI process components. These UI components are built
with HTML, CSS, and JavaScript (and its frameworks or library) where each of them
plays a different role in building the user interface.
• Microservice architecture
Microservice architecture is also becoming the perfect alternative to
service-oriented architecture as well as monolithic architecture. These
services are always loosely coupled for the development, testing,
maintenance, and deployment.
These services can also ensure communication with the other server.
It does so with the help of the API for solving complex business
problems.
• Serverless architecture