Вопрос про production ML
Compare REST and gRPC at a high level. Then explain what a database index does and what simple data structures can back an index.
Ответить самому
Сначала сформулируйте ответ как на собеседовании, затем откройте разбор и оцените себя.
Короткий ответ
REST is commonly HTTP/resource-oriented and often JSON/text based; gRPC uses protobuf contracts over HTTP/2 and supports efficient binary RPC and streaming. Database indexes speed lookups by maintaining auxiliary structures such as B-trees for ranges or hash indexes for equality.
Полный разбор
REST is an architectural style commonly implemented over HTTP with resource URLs, methods such as GET/POST and JSON payloads. It is simple, widely interoperable and human-readable, but may be less efficient for high-throughput service-to-service RPC.
gRPC defines service methods and message schemas with protobuf, usually runs over HTTP/2, uses compact binary serialization and supports streaming. It is useful for internal microservice communication where typed contracts, lower payload overhead and long-lived connections matter.
A database index is an auxiliary data structure that lets the database find rows without scanning the whole table. For equality lookup, a hash table-like structure can work. For range queries, sorting and ordered traversal matter, so B-tree/B+tree-style indexes are common. The trade-off is write overhead and extra storage because the index must be maintained when data changes.
Теория
Index choice follows query shape: equality, range, prefix, geospatial and full-text queries need different structures.
Типичные ошибки
- Call gRPC lower-level than HTTP without noting that it commonly runs over HTTP/2.
- Say an index always makes every query faster.
- Use hash indexes for range queries.
Как отвечать на собеседовании
- Give one use case for REST and one for gRPC.
- For indexes, immediately distinguish equality from range lookup.