Professional Documents
Culture Documents
Architecture
Memi Lavi
www.memilavi.com
System Architecture
• Includes:
performance, etc.)
System Architecture
• Includes:
performance, etc.)
Our Topics
• Loose Coupling
• Stateless
• Caching
• Messaging
• Without:
Service A
Service B Service C
Loose Coupling
• Without:
Service A
Service B Service C
Loose Coupling
• Without:
Service A
Service B Service C
Loose Coupling
• With:
Service A
Service B Service C
Loose Coupling
• With:
Service A
Flexible, Easy to
Maintain
Service B Service C
Loose Coupling in Services
Java RMI
Portfolio
PortfolioService
Service
(Java)
Loose Coupling in Services
Recommendation
Service
(Python)
Loose Coupling
Service A
Service B Service F
The Spiderweb
Service C Service E
Service D
Loose Coupling
Service A
Service B Service F
The Spiderweb
Service C Service E
Service D
Loose Coupling
Service A
Service B Service F
The Spiderweb
Service C Service E
Service D
Loose Coupling - Directory
Query for URL Yellow
Service A
Pages
Service B Service F
Services only
Use
need to know
URL
the Directory’s
Service C Service E URL
Service D
Loose Coupling - Gateway
Service A
Service B Service F
Services only
Gateway need to know
the Gateway’s
Service C Service E URL
Service D
Stateless
State = Application’s
Stateless Example
User
Interface
Log In Service
Database
Scalability - A Reminder
is not working
• Example:
working
Scalable & Redundant Architecture
User
Interface
Database
Stateful Example
User
Interface
Send user / password
Load Balancer
User / password sent to
Service #1
1 2 3
Retrieve user details
1 2 3
Database
Stateless Example
User
Interface
Add item to shopping cart
Load Balancer
Action sent to
Service #2
Cart Service Cart Service Cart Service
Database
Stored user details
Stateless
Browser Cache
Server
Service Cache
Service
Cache
Reliability Performance
Single Source Database High Good
of Truth Data is saved to disk Data is retrieved from disk,
then serialized
Stock Quotes
Service
Cache
Database
Example
Load Balancer
Request
Stale
Database
Cache Types
Distributed Cache
Distributed Cache
Distributed Cache
Distribution among servers
Failover capabilities
Large Cache storage
Choosing Cache Type
Means of communication
between the various services
Messaging
• Not Exclusive
Messaging Criteria
• Performance
• Message Size
• Execution Model
• Complexity
REST API
POST http://server/api/orders
{order data…}
HTTP API
Service
REST API
Subscribe Notify
Service
HTTP Push Notifications
Performance Excellent
HTTP Push Notification
Performance Excellent
Message Size Limited
Usually no more than a few KB
HTTP Push Notification
Performance Excellent
Message Size Limited
Usually no more than a few KB
Execution Model Web Socket connection / Long Polling
HTTP Push Notification
Performance Excellent
Message Size Limited
Usually no more than a few KB
Execution Model Web Socket connection / Long Polling
Feedback & None (Fire & Forget)
Reliability (Can be implemented, quite complex)
HTTP Push Notification
Performance Excellent
Message Size Limited
Usually no more than a few KB
Execution Model Web Socket connection / Long Polling
Feedback & None (Fire & Forget)
Reliability (Can be implemented, quite complex)
Performance Excellent
Message Size Limited
Usually no more than a few KB
Execution Model Web Socket connection / Long Polling
Feedback & None (Fire & Forget)
Reliability (Can be implemented, quite complex)
Problems:
Service #2
1. File locked File Folder Service #2
Instance #2
2. Duplicate processing
Service #2
Instance #3
Messaging Summary
REST API HTTP Push Queue File- & DB-based
Performance Very fast Excellent Not so good Not so good
Message Size Same as Limited Technically Unlimited
HTTP unlimited
limitations
Execution Request / Web Socket / Long Polling Polling
Model Response Polling
Feedback & Immediate None Very reliable Very reliable
Reliability feedback
Complexity Extremely Extremely easy Requires training Requires training
easy and setup and setup
Useful For Traditional Chat, Monitoring Complex system Complex system
web apps with lots of data, with lots of data.
where order and Better use queues
reliability are top
priority
Logging & Monitoring
Central Logging Service
Database NoSQL
Central Logging Service
Logging Service
Database
Central Logging Service
• Implementation:
• API
• Watch folders
Correlation ID
Recommendation
Log
X
Stock Quotes
Log
Log Log
CorID 17 CorID 17
CorID 18 CorID 18
System Architecture- Summary