Distribute ASCII arts generation with ascii-magic across multiple servers for scalability.
Here is how multiple pieces tie together:
asciilograph-api is a RESTful API which accepts HTTP requests from clients. It streams image bytes to a file server and enqueues image processing via a message broker (rabbitmq). Multiple instances of asciilograph-worker pick up euqueued processing tasks and do all the job using awesome ascii-magic library. After the processing is complete asciilograph-worker
reports results back to asciilograph-api
with a message enqueued to a dedicated callback queue. The asciilograph-api
then responds back to the client with the result text.
Make sure to have the .env
file with all the settings in the ./asciilograph
directory alongside docker-compose.yml
:
RABBITMQ_HOST=rabbitmq
RABBITMQ_USER=admin
RABBITMQ_PASSWORD=admin
RABBITMQ_IMAGE_PROCESSING_QUEUE=image_processing
RABBITMQ_CONNECTION_POOL_SIZE=100
FILESERVER_ADDRESS=fileserver
FILESERVER_USER=fsuser
FILESERVER_PASSWORD=fspassword
then run:
docker-compose up
Start issuing HTTP requests with binary data included. Don't use multipart uploads, they aren't streamable.
curl -X POST 'http://localhost:8000/ascii_arts' --data-binary '@test.jpg'