This is a demo project for usage of my bundle ddd-maker-bundle.
It is a middleware that retrieves a prompt, adds it to the Redis queue, and asynchronously connects to a configured AI.
This project is generated by my bundle ddd-maker-bundle.
git clone [email protected]:coundia/ddd-maker-bundle-usage-ia-middleware-redis-queue.git
composer install
docker compose up -d --build
docker compose up -d --build
Api docs http://127.0.0.1:8000/api/docs
curl -X 'POST' \
'http://127.0.0.1:8000/api/v1/prompts/create/' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"prompt": "This is a test prompt"
}'
curl -X 'GET' \
'http://127.0.0.1:8000/api/v1/messageloggers/findbyrequestid?requestId=your_requestId' \
-H 'accept: application/json'
docker-compose exec php bin/console mess:cons -vv
docker-compose exec redis redis-cli MONITOR
curl -X 'GET' \
'http://127.0.0.1:8000/api/v1/messageloggers/findbyrequestid?requestId=your_requestId' \
-H 'accept: application/json'
The architecture of this middleware application can be broken down into the following key components:
-
Client Interface (Prompt Handler):
- Receives a prompt from the user, which will be processed by the middleware.
-
Redis Queue:
- The prompt is placed into a Redis queue to manage the order of tasks and asynchronous processing.
-
AI Processing (Async Connector):
- An AI service is configured to consume the prompt from the queue and process it asynchronously.
-
Middleware:
- Acts as the coordinator between the client interface, Redis, and AI, ensuring smooth operation and task delegation.
+-------------------+ +-----------------+ +-----------------------+
| Client Interface | ---> | Redis Queue | ---> | AI Processing |
| (Prompt Handler) | | (Task Queue) | | (Async Connector) |
+-------------------+ +-----------------+ +-----------------------+
- Client Interface sends prompts to the system.
- Redis Queue queues the prompt for processing.
- AI Processing handles the prompt asynchronously.
- The Middleware ensures the connection and proper task flow.
IF edit the code restart the QUEUE
https://jmeter.apache.org/usermanual/get-started.html
Samples 1464 Total number of requests sent. Average 31063 ms The average response time (in milliseconds). Median 31010 ms The middle value of response times. 90% Line 55177 ms 90% of requests completed within this time. 95% Line 60001 ms 95% of requests completed within this time. 99% Line 60004 ms 99% of requests completed within this time. Min 381 ms The shortest response time recorded. Max 60020 ms The longest response time recorded. Error % 5.05% Percentage of requests that failed. Throughput 8.0/sec The number of requests handled per second. Received KB/sec 2.85 KB/sec Data received per second. Sent KB/sec 1.94 KB/sec Data sent per second.
The error rate (5.05%) means some requests are failing (it's ok)