Search code examples
microservices

Task distribution across microservices


We are building our first microservice architecture using Spring Boot and Kubernetes. I have a general question about scaling up one of our microservices which processes RSS feeds.

Currently we have about 100 feeds and run one instance of the microservice to process them. The feed sources are stored in a database and once the feeds are processed they are written to a central Kafka queue.

We want to increase the number of feeds and the number of instances of the microservice to process the feeds.

Are there any design patterns which I could follow to distribute the RSS feeds across the number of instances available? How would I dynamically allocate which microservice instance processes which set of feeds.

Any recommendations or best practice advice would be appreciated.


Solution

  • The first attempt is to use some messaging system.

    You could send a message that some "rss feed must be processed" with essential information about this task (feed id, link whatever).

    Then make all instances implement logic of consumption from the queue. This way, the instances will compete for processing the job. The more messages you have in the more tasks to do you'll have (obviously). You can then scale out the number of microservices.