Api Design easy
A client needs to create 500 users. Making 500 individual POST /users requests is slow. What's a better approach?
- A Implement a Bulk API endpoint (e.g., POST /users/bulk) that accepts an array of user objects.
- B Use GraphQL mutations to batch requests into a single query.
- C Increase the client's rate limit to 500 requests per second temporarily.
- D Require the client to upload a compressed CSV file to an S3 bucket instead.
Answer: A. Implement a Bulk API endpoint (e.g., POST /users/bulk) that accepts an array of user objects.
For bulk operations (like creating 500 users), making individual requests is inefficient due to network latency (RTT) for each call. A dedicated **Bulk API endpoint** (e.g., `POST /users/bulk`) that accepts an array of objects is significantly more performant. It reduces network overhead to a single request and serves as a transactional boundary if needed.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- You're designing a REST API for a blog. Which endpoint best represents 'get all comments for post 123'?
- A client wants to update only the 'status' field of an order, leaving other fields unchanged. Which HTTP method is most appropriate?
- A client calls POST /users with valid data, and the user is created. What status code should the server return?
- A client retries a failed 'POST /payments' request due to network timeout. The server receives the request twice. Without idempotency handling, what can happen?
- An API returns 10,000 products. Returning all in one response is impractical. Which pagination approach is simple and stateless?
- Your API serves both mobile apps and third-party integrations. Which authentication method is most appropriate?