Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use Kafka queue in my Rest WEBSERVICE

Tags:

I have a rest based application deployed in server(tomcat) , Every request comes to server it takes 1 second of time to serve, now I have a issue, sometimes Server receive more request then it is capable of serving which making server non responsive. Now I was thinking if I can store the requests in a queue so that server can pull request and serve that request and handle the pick time issue.

Now I was thinking can Kafka be helpful for this, if yes any pointer where I can start.

like image 377
Vawani Avatar asked Apr 07 '17 12:04

Vawani


1 Answers

You can use Kafka (or any other messaging system for this ex- ActiveMQ, RabbitMQ etc).

When WebService receives request, add request (with all details required to process it) in Kafka queue (using Kafka message producer details)

Separate service (having Kafka consumer details) will read from topic(queue) and process it.

In case need to send message to client when request is processed, server can push information to client using WebSocket (Or client can poll for request status however this need request status endpoint and will cause load on that endpoint).

like image 127
Kaushal Avatar answered Sep 22 '22 10:09

Kaushal