API Design
Inspired by 50 shades of system design
API retries
API Circuit breakers
API short vs long timeouts
REST framework
RPC methods
API Rate limiting
Stateless vs Sticky sessions
API Authentication
Idempotency key
Technologies
In this topic
- WebSocketSeedling
- API AuthenticationGrowing
Maybe not straight user ID in api. Jwt json web token contains signed json data about the user, like what role they have. Every request contains a signature that the server can…
- REST vs GraphQLGrowing
When is GraphQL is a good idea? When flexibility of what data to retrieve is important, but it is possibly rarely worth the overhead.
- API retriesGrowing
Good to handle the odd error. Beware of overloading already failing services with even more load. API Circuit breakers will help.
- API Circuit breakersGrowing
Failing fast is better than failing slow. Circuit breakers allows not calling services that are broken so that they're not overloaded. Half open allows letting a few requests through to see if…
- API short vs long timeoutsGrowing
Set long timeouts intentionally, services should be fast, unless it is purposefully (can't do otherwise) slow.
- REST frameworkGrowing
REST favours plural nouns. Use path parameters for mandatory parameters, and use query parameters for optional ones. Rest is good for public facing Apis, easy to reason about. Http for external is…
- RPC methodsGrowing
RPC tends to be more for internal service communication. REST has a bit more overhead with http. Rpc tends to use more efficient formats like protobuf and grpc rather than http. This…
- API Rate limitingGrowing
Django rate limiter? In memory per server. You don't get a global picture tho. Or separate service but extra latency. Most common is to have it with the api gateway. Rate limiting…
- Idempotency keyGrowing
Client generates an ID to send to the server that is unique when making operations. In case of failures or retries, this ensures operations on the server side are done only once.
- GraphQLGrowing
This is good for when clients need to choose which fields to use and make complex joins in 1 query. With graphql, it's easy to introduce the n+1 query problem where you…
Sources
- 50 shades of system design inspired this note