pythonflaskrabbitmqmicroservicespython-pika

implement a background job inside a http microservice


i have a microservice (written in Python) which exposes a few endpoints, each of these endpoints can be executed by a http request(flask).

I have one specific endpoint which takes a long time to be finished, so I thought to run a background job once this entrypoint is triggered, in order to reduce its respond time.

For example, i want flask to start the process by a http request and when it starts i want to push a task into a rabbitMQ queue.. is the consumer should be in the same app or in a different service?


Solution

  • Consumer could live in the same codebase to share the models, functions and other tools just run it as separate worker process.

    Celery is redundant for such a task, try Pika or Dramatiq.