-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInterview-questions.txt
153 lines (113 loc) · 6.38 KB
/
Interview-questions.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Database & Performance Questions
8. "What approaches would you take to optimize bulk photo uploads for travel albums using Python? Consider both storage and processing aspects."
# REST API Design Questions
10. "How would you handle versioning in your REST APIs? Compare different approaches (URL, header, content negotiation)."
11. "Explain how you would implement authentication and authorization in a FastAPI application. How would you handle JWT tokens?"
# Scalability & Architecture Questions
12. "How would you design a background job system using Celery for processing travel photos? Include error handling and retry mechanisms."
13. "Explain how you would implement real-time trip updates using WebSockets in FastAPI. What challenges might you face with scale?"
14. "Design a system to handle offline trip tracking data syncing when users regain internet connectivity. Consider conflict resolution."
# Python-Specific Questions
15. "Compare the performance implications of using dataclasses vs Pydantic models in FastAPI. When would you choose one over the other?"
16. "How would you implement custom middleware in FastAPI to track API response times? Show example code."
17. "Explain Python's async/await syntax and how it could benefit a travel application's backend services."
# Go-Related Questions (Bonus)
18. "Compare implementing middleware in Go vs Python web frameworks. What are the key differences?"
19. "How would Go's goroutines and channels compare to Python's async/await for handling concurrent API requests?"
Key differences:
- Goroutines are lightweight threads managed by Go runtime, while async/await is cooperative multitasking at the application level
- Goroutines can run in parallel across multiple CPU cores, Python async is single-threaded
- Channels provide built-in communication between goroutines, Python needs external queues/events
- Go has simpler error handling with explicit return values, Python uses try/except
- Python async/await requires explicit marking of async functions, Go is more implicit
- Goroutines have lower memory overhead than Python async tasks
Performance implications:
- Go generally handles high concurrency better due to parallel execution
- Python async excels at I/O-bound tasks but limited by single thread
- Go's garbage collection can cause occasional pauses
- Python async has lower context switching overhead within single thread
Use cases:
- Go better for CPU-intensive parallel work
- Python async good for I/O-heavy web services
- Go scales better to many concurrent connections
- Python async easier to reason about for sequential-style code"
20. "What advantages might Go offer for certain microservices in a primarily Python backend architecture?"
Key advantages:
- Performance: Go's static compilation and efficient garbage collection make it ideal for compute-intensive services like image processing or data analytics
- Concurrency: Native support for parallel execution via goroutines makes Go excellent for high-throughput services like real-time tracking or chat
- Memory efficiency: Lower memory footprint compared to Python, beneficial for services handling many concurrent connections
- Static typing: Catches errors at compile time, reducing runtime bugs in critical services
- Simple deployment: Single binary deployment simplifies DevOps compared to Python's dependency management
- Cross-compilation: Easy to build for different platforms from one machine
Example use cases:
- High-performance API gateways/proxies
- Real-time websocket servers
- CPU-intensive data processing pipelines
- Services requiring maximum resource efficiency
- Critical path services where performance matters most
Integration considerations:
- Need clear service boundaries and APIs
- May require protocol standardization (e.g. gRPC)
- Should evaluate operational complexity of managing multiple languages
- Consider team expertise and learning curve
- Ensure monitoring/observability compatibility
# System Design Exercise Example
"Design a system for Polarsteps that allows users to download offline maps for regions they plan to visit. Consider:
- Storage optimization
- Update mechanisms
- Bandwidth considerations
- Offline functionality
- Integration with existing trip planning features"
21. "Explain in detail how Python's asyncio event loop works internally, including how it handles coroutines, tasks, and future objects. How would you implement a custom event loop?"
Key points to cover:
- Event loop internal architecture (selector implementation, ready queue)
- Task scheduling and switching mechanisms
- Integration with low-level callbacks and handle_events()
- Future object state management
- Exception handling across coroutines
- Custom protocol implementations
Advanced follow-ups:
- How would you debug a deadlocked event loop?
- What are the performance implications of task.__step()?
- How does the loop handle thread safety with run_in_executor()?
22. "Design a distributed rate limiter in Python that can handle millions of requests across multiple application servers. Consider:
- Consistency requirements
- Race conditions
- Network partitions
- Performance overhead"
Expected discussion points:
- Redis/distributed cache architecture
- Token bucket vs leaky bucket algorithms
- Clock synchronization challenges
- Failure modes and recovery
- Monitoring and alerting strategy
23. "How would you implement a custom metaclass to create a singleton pattern that's both thread-safe and works correctly with inheritance? What are the pitfalls?"
Key considerations:
- Instance state management
- Thread synchronization
- Method resolution order
- Pickle/unpickle behavior
- Memory leaks
- Inheritance edge cases
24. "Explain Python's memory allocator internals and how you would profile and optimize memory usage in a large-scale application"
Topics to cover:
- PyMalloc implementation
- Memory fragmentation
- Reference cycles
- Generational GC tuning
- Memory pools and arenas
- Large object space
25. "Design and implement a distributed task queue system from scratch without using existing solutions like Celery. Consider:
- Reliability guarantees
- Task prioritization
- Dead letter handling
- Monitoring/observability
- Scaling characteristics"
Architecture components:
- Broker design
- Worker management
- Result backend
- Error handling
- Task routing
- State management
These questions test deep Python knowledge, systems design, and practical experience with large-scale applications.