Software Engineering (Week-6)
Software Engineering (Week-6)
(Week-6)
USAMA MUSHARAF
LECTURER (Department of Computer
Science)
FAST-NUCES PESHAWAR
CONTENTS OF WEEK # 6
A given hardware
Kind
capacity
Performance Problems
How to spot a performance problem? How does it
look like?
Performance Principles
Efficiency Caching
◦ Efficient Resource
Utilization
◦ IO- Network, Memory, Disk Concurrency
◦ CPU ◦ Hardware
◦ Software
◦ Queuing
Efficient Logic ◦ Coherence
◦ Algorithms ◦ Capacity
◦ DB Queries
Throughput
◦ Affects– Number of users that can
be supported
◦ Desired– Greater than the
request rate
Errors
◦ Affects– Functional Correctness
◦ Desired– None
Resource Saturation
◦ Affects– Hardware Capacity
Required
◦ Desired– Efficient utilization of all
system resources.
Serial Request Latency
Disk Latency - Approaches
Parallel Request (Concurrency)
C(N) = theoretical
speed
Parallel + Serial
Concurrent Processing
C is capacity
N is scaling dimension like CPU or load
Alpha represents resource contention
Beta represents coherence delay
Suppose that two threads are working on SharedObj. If two threads run on
different processors each thread may have its own local copy of sharedVariable.
If one thread modifies its value the change might not reflect in the original one in
the main memory instantly. This depends on the write policy of cache. Now the
other thread is not aware of the modified value which leads to data inconsistency.
“Volatile” keyword in java tells the compiler that the value of a variable must
never be cached as its value may change outside of the scope of the program
itself.
Scalability
Performance vs Scalability
FIXED LOAD VARIABLE LOAD
Performance Scalability
Low Latency High Throughput
High Throughput Ability of a system to increase its
Concurrency throughput by adding more
Single-Machine- Multi-Threading
hardware capacity.
Both Ways: Up and Down
Multi-Machine- Multi-Threading +
Multiprocessing = Distributed Processing
Vertical & Horizontal Scalability
Modularity
Scalable architecture starts with Modularity
Provides the foundation for breaking an application into more specialized
functions/services.
Horizontal Scaling Methods
1. Services
2. Replication
1. Stateful
2. Stateless
3. Portioning
1. Vertical / Functionality Portioning
2. Database portioning
4. Asynchronous Calls
Microservices
Reliability
Reliability
1. Reliability
2. Availability
3. Fault Tolerance
Availability
Fault Tolerance
Fault Tolerant Design
1. Redundancy
2. Fault Detection
3. Recovery
Redundancy
Types of Redundancy
Datacenter
Redundancy
Fault Models
Health Checks
External Monitoring
Service
• Ping based
57
Assume ‘Architecting’ a big e-commerce system
58
Use Case Model
y s
Wa
ech
w T
Ne
59
Domain Model
ays
c hW
Te
ew
N y s
Wa
ech
w T
Ne
60
Low Level Design
Behavior
State
Code
Static + Transactional
61
Component Model
62
What About?
63
Going Beyond
64
Application Architecture Vs System Architecture
65
Latency Requirements
66
Scalability Requirements
67
Availability & Reliability Requirements
Unavailability results in
◦ Business loss
◦ Reputation loss
99.95% Availability
◦ Maximum cumulative disruption of 4 hours 22
minutes in a year
Disaster Recovery
◦ Operations to continue even if a region goes
down due to a natural calamity
68
Security Requirements
Infrastructure protection
◦ Network access
◦ System access
◦ Service access
Data Protection
◦ Data sensitivity classification
◦ Protect data at rest
◦ Protect data on wire
◦ Data backup & replication
69
Designing System Architecture
70
Scalability Principle
◦ Independence
◦ Multiple workers are as good as a single worker if they can’t work
independently
◦ They must work concurrently to maximum extent
71
Modularity
Scalable architecture starts with modularity
◦ Provides the foundation for breaking a system function/service into more
specialized functions/services
Web Browser Web Application Business Application DBMS
72
Specialized Services –
WebServices
Services can be scaled differently e.g., Number of instances
Order Service
Web Application
Catalog Service
User Service
73
Aggregator Service & RESTful
API – Mobile Support
REST for external interface interoperability & Mobile Support
Order Service
Web Application
RESTful
Aggregator/ User Service
Gateway
Service
74
Independent Services –
MicroServices
Micro-Services can be scaled differently and deployed independently
Order Service
Web Application
Catalog Service
Aggregator/
User Service
Gateway
Service
75
Asynchronous Services
Updates can be done asynchronously to buffer peak loads and to reduce
response latency
Notificatio Inventory
n
View Create/Update
Order Order
Web
Applicati Orde Order Order
on r Queue Processi
ng
Catalo
Aggregator/ g
Gateway
Service
User
76
Stateless Replication
Replication provides more computation power
Notificatio Inventory
n
Web
Applicati Orde Order
Order
on r Queue
Processing
Catalo
Aggregator/ g
Gateway
Service
User
77
Reliability Principle
78
Single Point Of Failures
Catalo
HTTP Cache Aggregator g
Service Object
Cache
CDN Session
Cache User
79
Redundancy
Notificatio Inventory
n
Discove
ry
Stati
c
HTTP Cache Orde Order Order
Network Dynami r Queu Processi
c
e ng
Catalo
HTTP Cache Aggregator g
Object
Service Cache
CDN Session
Cache User
80
Monitoring For Fault Detection
Catalo
HTTP Cache Aggregator g
Object
Service Cache
CDN Session
Cache User
81
Zonal Redundancy
Zonal redundancy for fault isolation
Backend Replication
Power Supply
y s
HTTP Cache Wa Zone 1
c h
w Te Zone 2
HTTP Ne
Cach
e
Power Supply
CDN
User
82
Security-Web Application
Firewalls
Multiple security related attacks can be prevented by inspecting requests for
common attacks and vulnerabilities by using Web Application Firewalls
Notificatio
TLS n
Injection Attack
Web Orde
DDoS Attack
Applicati r
Session Hijacking
on
TLS Catalo
Aggregator/ g
Gateway
Service
User
Auth
83
HAVE A GOOD DAY!