API Flashcards

1
Q

RPC

A
  • Utilizes a method invocation paradigm
  • client calls a specific procedure or function on a remote server.
  • synchronous communication.
  • gRPC Is a specific implementation of RPC developed by Google.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Use cases of 4 RestFul, 2 RPC, 2 Graphql

A

RPC:
* in microservices architectures
* communication between services is frequent and performance is critical.

Restful:
* Ideal for systems with a large number of clients requiring standard CRUD operations on resources.
* client-server communication
* scalability is important.
* cacheability is important.

Graphql
* complex data-fetching scenarios
* client’s requirements are constantly evolving.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Tradeoffs of RestFul, RPC, Graphql in terms of Perfomance, Compexity

A

Performance:
* RPC tends to be more efficient for simple, synchronous communication
* GraphQL may be more efficient for complex queries due to its ability to fetch only the required data.
* RESTful APIs fall somewhere in between.
*
Complexity:
* RPC can become complex as the system grows due to tight coupling between client and server.
* RESTful APIs offer simplicity in terms of uniform interfaces but may suffer from over-fetching or under-fetching.
* * GraphQL can be complex to set up initially but offers simplicity for clients and avoids over-fetching/under-fetching.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Long polling vs websocket vs SSE

A

Long Polling:
Pros: Simple to implement, works on most web servers.
Cons: Increased latency, higher server load.
Use Cases: Legacy systems, simple applications with low traffic.

WebSockets:
Pros: Low latency, bidirectional communication.
Cons: Requires server-side support, may be blocked by some proxies/firewalls.
Use Cases: Real-time applications like chat, gaming, collaborative editing.

Server-Sent Events (SSE):
Pros: Simple implementation, built-in reconnection mechanisms.
Cons: Unidirectional (server to client) communication only.
Use Cases: News feeds, real-time notifications, server-initiated updates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Http2 vs Http3

A

HTTP/2:
Pros: Multiplexing, header compression, server push, binary format.
Cons: Head-of-Line Blocking, complexity.
usecase: Faster loading of web pages with multiple resources.

HTTP/3:
Pros: QUIC protocol, multiplexing, improved security, faster recovery.
Cons: Limited browser/server support, potential overhead.
usecase:Real-time applications online gaming, Streaming video with reduced latency and improved reliability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Content Negotiation

A
  • allows a server to serve different versions of a resource based on client preferences
  • such as language, format (HTML, JSON), or encoding.

+ ux , + effciency : reduces the need for multiple URLs for different version of content

  • complecity, - caching challenges

Use Case:

Localization: Delivering content in multiple languages based on the Accept-Language header sent by the client.
Format Flexibility: Serving JSON data to API requests and HTML to web browsers from the same URL, based on the Accept header.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

GraphQL + -

A

+ effciency: reduce over-fetching, and under fetching (combine multiple request in one)
+ single endpoint: simplifize, reduce net requests

  • complex: manage schema, query optimize, caching
  • overhead: additional tool to graph, monitor , testing harder
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

N+1 problem in graphql

A

when resolving multiple nested fields within each item of a list, leading to inefficient and repetitive data fetching processes.

e.g. 10 blog posts along with the author details for each post

case: product, description in different languages, 3 product * 10 language: 30 queries
solution: batch queries in a single query

libraries to solve : use data loaders
https://github.com/graphql/dataloader

How well did you know this?
1
Not at all
2
3
4
5
Perfectly