Understanding Web Application and Software Architecture ( Go step by step thru the different concepts, functions, and components involved in architecting a web application) Flashcards
The different tiers in software architecture:
- What is a tier?
- Why do software applications have different tiers?
- How do I decide how many tiers my application should have?
- A tier is a logical separation of components in an application
components are: Database, Backend Server, User Interface, Messaging, Caching
Scalability
High Availability
Load Balancing
Monolith and Microservices
MicroFrontends
Database
Caching
Message Queue
Describe a Single Tier Application and its strengths and weaknesses
Examples; Desktop Apps like MS Office, PC Games, Image editing software like GIMP, Photoshop, etc
the User Interface, Backend Server Business Logic, and Database reside in the same machine
Strengths: 1) low latency due to all 3 components on one machine, 2) higher order of security since the user’s data is on the machine and doesn’t need to be transmitted over a network for persistence
Weakness: 1) NO ROOM FOR MISTAKES OR BUGGY CODE Once the software is shipped the creator does not have any control over the software application. There can not be any code updates or feature updates unless the user manually installs the updated software, 2) the application is vulnerable to being modified or reverse engineered from a competitor or bad actor (depending on your perspective this can be viewed as weakness) 3) Inconsistent user experience since a single tier app’s performance largely depends on the end user’s machine’s power and the configuration of that machine
Describe a Two Tier Application and its strengths and weaknesses
Examples of Two Tier Apps: To-Do List app, Planner App, Productivity App
A Two Tier Application is logically separated into Client and Server. Where the Client includes the User Interface and the Business Logic of the application in one machine. The Backend Server includes the Database is running on a different machine. The Database is hosted by the business, which has control over the database.
Client Server Architecture communicates via Request and Response Cycles
Strengths:
there are less network calls made to the backend server since the user interface and business logic reside on one machine. This results in Low Latency.
example 1: with the To-Do list app a user only makes a network call to the database when they finish creating their list and want to persist the data
example 2: with browser and mobile games, the user only makes network calls to the backend when they want to persist game state
Fewer server calls means less money spent on keeping the servers running
Describe a Three Tier Application, it’s use cases per business requirements, and strengths and weaknesses
Examples: blogs, news websites
Three Tier Applications: all three components; user interface, business logic, and database, are separated onto three different physical machines
A basic Three Tier app would have:
User Interface written in HTML, JavaScript, and CSS
Business Logic will run on Apache
Database will be MySQL
Describe an N-Tier Application, its use cases per requirements, and strengths and weaknesses
An N-Tier application is an application that has more than three components (UI, Backend Server, Database) involved in its architecture
These additional components are:
Cache
Message queues for asynchronous behavior
Load balancers
Search servers for searching through massive amounts of data
Components involved in processing massive amounts of data
Components running heterogenous tech commonly known as web services, microservices, etc
All the social apps like Instagram, Twitter, Facebook, TikTok, and large scale consumer services like Uber, Airbnb, online massive multiplayer games like Pokemon Go, Roblox, etc, are n-tier applications.
N-Tier applications are more popularly known as distributed systems
CRUX: What’s the need for so many tiers?
hint: Single Responsibility Principle, Separation of Concerns Principle
Two key principles to explaining the need for many tiers are: Single Responsibility Principle, and the Separation of Concerns
Single Responsibility Principle: refers to giving one dedicated responsibility to a component and letting that component execute that one responsibility flawlessly. Making a change to one component doesn’t impact the functionality of other components.
example: saving data, running application logic, delivery of messages throughout the system
example: a database should not hold business logic. It should only take care of persisting the data.
Single Responsibility Principle makes are code more flexible, making management easy. It make the components lego blocks. Can have dedicated teams and code repositories for each component
Separation of Concerns: Be concerned about your work/responsibility/component only and stop worrying about the other work. Keeping components separate makes them reusable.
Loosely coupled components allows us to scale our service easily when things grow beyond a certain scale in the future
Tiers vs Layers
in the industry the term Application Layers refers to user interface, business, service, and the data access layers
These layers are the logical/conceptual separation of an application at the code level.
Layers represent the conceptual/logical organization of code
Tiers represent the physical/logical separation of components in an application or service. The components are the database, backend application server, user interface, messaging, and caching