-1

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?

1 Answers1

0

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.

frost-nzcr4
  • 1,540
  • 11
  • 16
  • I am using Pika&docker. How can i start the consuming process if my base microservice is a wsgi server?, should i create i a new thread and bind it to the worker script? or maybe start a new container with a different CMD ? – Itay Bardugo Oct 15 '20 at 17:58
  • I recommend the new container as the easiest method, but it may take some practice in Docker. – frost-nzcr4 Oct 16 '20 at 07:58