User Tools

Site Tools


skills:interview

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
skills:interview [2026/06/13 07:00] – [Golang] phong2018skills:interview [2026/06/15 10:07] (current) – [Transactions] phong2018
Line 260: Line 260:
  
 18. What are deadlocks? 18. What are deadlocks?
 +<code> 
 +- Deadlock: A situation where two or more transactions hold locks and wait for each other indefinitely. 
 +- How it occurs: Transactions access the same resources in different orders. Long-running transactions hold locks too long. Missing indexes cause unnecessary locking. 
 +- How to detect it: The database detects deadlocks automatically. MySQL returns: ERROR 1213: Deadlock found when trying to get lock. Investigate with SHOW ENGINE INNODB STATUS. 
 +- How to prevent it: Keep transactions short. Always access tables/rows in a consistent order. Add proper indexes. Avoid large batch operations in a single transaction. 
 +- How to recover: The database rolls back one transaction automatically. Catch the error in the application and retry the transaction with backoff. 
 +</code>
 ==== Large Scale Databases ==== ==== Large Scale Databases ====
  
Line 491: Line 497:
  
 7. What backend technology trends are you currently following? 7. What backend technology trends are you currently following?
 +
 +  
 +====== System Design Interview Questions ======
 +
 +===== Interview Framework =====
 +
 +Always follow this order:
 +
 +  - Clarify requirements
 +  - Estimate scale
 +  - Define APIs
 +  - Design data model
 +  - Draw high-level architecture
 +  - Explain data flow
 +  - Identify bottlenecks
 +  - Discuss scaling
 +  - Discuss trade-offs
 +  - Explain failure handling
 +
 +===== Questions =====
 +
 +==== Beginner to Intermediate ====
 +
 +  - Design a URL shortener
 +  - Design a file storage service
 +  - Design a chat application
 +  - Design a notification system
 +  - Design a rate limiter
 +  - Design a distributed cache
 +  - Design a search autocomplete service
 +  - Design an API gateway
 +  - Design a job queue system
 +  - Design a payment processing system
 +
 +==== Intermediate to Advanced ====
 +
 +  - Design a ride-sharing platform
 +  - Design a food delivery system
 +  - Design a social media news feed
 +  - Design a video streaming platform
 +  - Design an e-commerce platform
 +  - Design a real-time collaboration tool
 +  - Design a monitoring and logging platform
 +  - Design a recommendation engine
 +  - Design a distributed lock service
 +  - Design a multi-tenant SaaS platform
 +
 +==== Senior Backend Engineer Topics ====
 +
 +  - Design an order management system
 +  - Design an inventory system that prevents overselling
 +  - Design a coupon and promotion engine
 +  - Design a loyalty points system
 +  - Design an invoice generation system
 +  - Design a webhook processing platform
 +  - Design an OAuth2 / SSO authentication system
 +  - Design an event-driven microservices architecture
 +  - Design a distributed scheduler service
 +  - Design a monolith-to-microservices migration strategy
 +
 +===== Drawing Template =====
 +
 +For every question, draw the following components:
 +
 +<code>
 +Users / Mobile App / Web Browser
 +                |
 +                v
 +        CDN / Load Balancer
 +                |
 +                v
 +            API Gateway
 +                |
 +                v
 +         Application Services
 +          /        |        \
 +         /                 \
 +        v          v          v
 +     Cache      Database    Queue
 +      |                      |
 +      |                      |
 +      v                      v
 +    Redis      MySQL/NoSQL   Workers
 +
 +                |
 +                v
 +      Monitoring / Logging
 +</code>
 +
 +===== What Interviewers Expect =====
 +
 +For each component, explain:
 +
 +  * Why it exists
 +  * How it scales
 +  * Single points of failure
 +  * Data consistency requirements
 +  * Availability requirements
 +  * Security considerations
 +  * Monitoring and alerting
 +
 +===== Non-Functional Requirements Checklist =====
 +
 +  * Availability (99.9%, 99.99%, etc.)
 +  * Scalability
 +  * Reliability
 +  * Latency
 +  * Throughput
 +  * Durability
 +  * Consistency
 +  * Security
 +  * Cost
 +
 +===== Estimation Checklist =====
 +
 +Estimate before designing:
 +
 +  * Daily active users
 +  * Requests per second (RPS)
 +  * Peak traffic
 +  * Storage requirements
 +  * Read/write ratio
 +  * Bandwidth requirements
 +
 +===== Deep Dive Topics =====
 +
 +Discuss when prompted:
 +
 +  * Database sharding
 +  * Caching strategy
 +  * Queue design
 +  * Event-driven architecture
 +  * Replication
 +  * Multi-region deployment
 +  * Disaster recovery
 +  * Rate limiting
 +  * Idempotency
 +  * Distributed locking
 +  * CAP theorem
 +  * Eventual consistency
 +
 +===== Common Trade-offs =====
 +
 +^ Choice ^ Pros ^ Cons ^
 +| SQL | Strong consistency | Harder to scale horizontally |
 +| NoSQL | High scalability | Eventual consistency |
 +| Sync communication | Simple | Tight coupling |
 +| Async communication | Resilient | Increased complexity |
 +| Cache aside | Simple | Stale data risk |
 +| Write through cache | Consistent cache | Higher write latency |
 +
 +===== Example: URL Shortener =====
 +
 +==== Requirements ====
 +
 +  * Shorten long URLs
 +  * Redirect users quickly
 +  * High read traffic
 +  * Custom aliases (optional)
 +  * Analytics (optional)
 +
 +==== APIs ====
 +
 +<code>
 +POST /api/v1/shorten
 +
 +Request:
 +{
 +  "url": "https://example.com/very/long/url"
 +}
 +
 +Response:
 +{
 +  "shortUrl": "https://short.ly/abc123"
 +}
 +</code>
 +
 +<code>
 +GET /abc123
 +</code>
 +
 +==== High-Level Design ====
 +
 +<code>
 +Client
 +  |
 +  v
 +Load Balancer
 +  |
 +  v
 +URL Service
 +  |       \
 +  |        \
 +  v         v
 +Redis     MySQL
 +</code>
 +
 +==== Data Model ====
 +
 +<code>
 +urls
 +----
 +id
 +short_code
 +long_url
 +created_at
 +expires_at
 +</code>
 +
 +==== Scaling ====
 +
 +  * Cache popular URLs in Redis
 +  * Read replicas for MySQL
 +  * Shard by short_code
 +  * CDN for global traffic
 +
 +==== Failure Handling ====
 +
 +  * Retry failed writes
 +  * Circuit breaker for dependencies
 +  * Database replication
 +  * Multi-region backup
 +
 +===== Whiteboard Tips =====
 +
 +  * Start simple
 +  * Draw before explaining
 +  * Label every component
 +  * State assumptions clearly
 +  * Ask clarifying questions
 +  * Explain trade-offs
 +  * Think out loud
 +  * Optimize only after the basic design works
 +
 +===== Golden Rule =====
 +
 +Do not jump directly into technology choices.
 +
 +Always follow:
 +
 +Requirements -> Scale -> APIs -> Data Model -> Architecture -> Bottlenecks -> Trade-offs
 +
 +
  
 ====== More detail versions ====== ====== More detail versions ======
Line 511: Line 760:
   13. What is Swoole or RoadRunner and how do they differ from the traditional PHP-FPM request model?   13. What is Swoole or RoadRunner and how do they differ from the traditional PHP-FPM request model?
   14. What do the three numbers in Semantic Versioning (MAJOR.MINOR.PATCH) mean, and when should each be incremented?   14. What do the three numbers in Semantic Versioning (MAJOR.MINOR.PATCH) mean, and when should each be incremented?
 +   
 +  
 ===== Laravel & Symfony ===== ===== Laravel & Symfony =====
  
skills/interview.1781334022.txt.gz · Last modified: by phong2018