DEV Community

Periklis Gkolias
Periklis Gkolias

Posted on

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

Discussion (6)

Collapse
codingsafari profile image
Nico Braun • Edited on

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.

Collapse
perigk profile image
Periklis Gkolias Author

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

Collapse
felipemsfg profile image
Felipe Marques

Maybe using websocket? Or Redis pubsub feature?

Collapse
ksaaskil profile image
Kimmo Sääskilahti

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

Collapse
perigk profile image
Periklis Gkolias Author

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

Collapse
matthewbdaly profile image
Matthew Daly

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