This inference pipeline is composed by a producer, a RabbitMQ queue and a consumer. FYI, in the text below each variable written in CAPITAL-YELLOW
is defined in the docker-compose.yaml
.
- The producer receives post requests (base64 encoded images) and pushes messages to the RabbitMQ queue where each message is composed by a unique id (UUID), an image, a
CALLBACK_URL
(webhook for asynchronous response) and the time.time() where the image was sent. If no response is received afterTIMEOUT
seconds, the client will receive an error 400. Check files at src/producer. - The consumer receives simoultaneously up to
MAX_BATCH_SIZE
and processes them in batches. However, once the first message is received, all messages will be processed afterBATCH_TIMEOUT
seconds, even if they are fewer thenMAX_BATCH_SIZE
. Once a message is processed, it is removed from the RABBITMQ queue (channel.basic_ack) and is sent back to the producer. - Response to client: once the processed message is sent back to the producer, if the response if received within a
TIMEOUT
time, then it is stored in a local dictionary. The initial asynchronous function used to receive client requests, checks every 0.01 seconds (sleeps asynchronously) if the server response is present within the local dictionary. If is present, it sends the response back to the client.
This pipeline could be further improved by using a "not TCP protocol" in the consumer-producer response.
docker compose up -d
FYI: RABBITMQ takes a while to setup, even if the container are present, wait some seconds before staring to send requests.
bash send_requests.sh
-
Create a password hash with:
python src/rabbitmq/password.py your_password
-
Open
src/rabbitmq/definitions.json
, add create a dict within users:{ "name": "your_user_name", "password_hash": "password_hash_created_at_point_1", "hashing_algorithm": "rabbit_password_hashing_sha256", "tags": "" }
-
Still in
src/rabbitmq/definitions.json
make sure the user has the the specified permission under the permissions key:{ "user": "your_user_name", "vhost": "\/", "configure": ".*", "write": ".*", "read": ".*" }