๐น SQL Example
BEGIN;
UPDATE accounts
SET balance = balance - 100
WHERE id = 1;
ROLLBACK;
๐น Interview Tip
Transactions protect data integrity.
๐ 78. What is connection pooling?
Opening DB connections repeatedly is expensive.
Connection pooling: Reuses existing connections
๐น Flow
App โ Connection Pool โ Database
๐น Benefits
โ
Faster performance
โ
Reduced overhead
โ
Better scalability
๐น Popular Tools
โข HikariCP
โข PgBouncer
๐น Interview Tip
Connection pools are critical in high-traffic backend systems.
๐ 79. What is the CAP theorem?
CAP theorem states distributed systems can only guarantee TWO of:
๐น CAP
C
โข Meaning: Consistency
A
โข Meaning: Availability
P
โข Meaning: Partition Tolerance
๐น Explanation
๐น Consistency
All nodes return same data.
๐น Availability
System always responds.
๐น Partition Tolerance
System survives network failures.
๐น Reality
In distributed systems: Partition tolerance is mandatory
So trade-off becomes: Consistency vs Availability
๐น Interview Tip
CAP theorem is fundamental for distributed systems interviews.
๐ 80. How do you design a scalable schema for user-generated content?
Examples:
โข Social media posts
โข Comments
โข Reviews
โข Videos
๐น Core Tables
๐น Users
โข user_id
โข name
๐น Posts
โข post_id
โข user_id
โข content
๐น Comments
โข comment_id
โข post_id
โข user_id
๐น Scalability Techniques
โ
Indexes
โ
Caching
โ
CDN for media
โ
Database sharding
โ
Async processing
๐น Media Storage
Store images/videos in:
โข Amazon Web Services S3
โข Object storage systems
๐น Feed Optimization
Use: Precomputed feeds for faster timeline generation.
๐น Interview Tip
Scalable schema design focuses on:
โข Read efficiency
โข Write scalability
โข High traffic handling
๐ฅ Double Tap โค๏ธ For Part-9
Post #2981
1.51K
- โค 3