loading...

How would you create a web API with streaming input and output (eg stocks monitoring system) without tools like Kafka and Spark?

perigk profile image Periklis Gkolias ・1 min read

Discussion

pic
Editor guide
 

Long Polling

Is probably the oldest method. It is considered to be near real-time. It is essentially an improved version of constantly making get requests to receive updates.

Websockets

Are truly real-time due to the use of an ever open TCP connection that allows to send data in both directions.

Server Sent Events

It opens a one directional stream that allowed the server to send events to the client. The client cannot use this stream to send data back tough. Normally regular HTTP requests are used if information needs to be sent back to the server.

gRPC

Using the HTTP/2 protocol. gRPC revolves around calling methods remotely. Its has a streaming service that can be used bi directional real time communication. The data is commonly sent as protocol buffer.

 

Thank you Nico. Not sure if long polling is a viable option in my book, but I will totally try the rest :)

 

Maybe using websocket? Or Redis pubsub feature?

 

I also thought first of websockets. gRPC is also worth looking into. Or maybe GraphQL streaming, don't know how that works nowadays.

 

Websockets sounds a great idea. And it is relatively easy to implement a WS client/server.

I have never heard GQL streaming and redis pubsub. Will totally look into

Thank you guys

 

My first choice would probably be WebSockets, but it might be worth a look at server-sent events for a possible simpler solution.