Published on July 3, 2026 by Machina Muse Team | 5 min read
Generating a single AI image is simple, but generating hundreds of images in parallel using bulk prompt lists can crash servers or hit API rate limits instantly. At Machina Muse, we designed a batch prompt processor utilizing custom concurrency pools and metadata sidecars to make high-volume generations safe and maintainable.
When a user uploads a prompts.json (an array of prompt strings), the backend processes them using a promise concurrency pool pattern (configurable from 1 to 10 parallel tasks). Rather than hitting the API all at once, the queue feeds tasks dynamically as earlier requests complete.
If an API request fails, the queue records the specific failure reason but continues processing the remaining prompts, ensuring a single bad prompt does not halt the entire batch.
For every generated image, we store a matching JSON metadata sidecar (e.g. {id}.json) containing:
This sidecar architecture decouples database records from storage. If the database undergoes maintenance, the server can rebuild the image gallery dynamically by crawling the static JSON sidecars on S3/R2 storage, ensuring near 100% database decoupling and auditability.
단일 AI 이미지를 만드는 것은 간단하지만, 벌크 프롬프트 목록을 통해 수백 개의 이미지를 병렬로 생성하는 것은 API 속도 제한(Rate Limit)을 초과하거나 서버에 막대한 부하를 초래합니다. 마키나 뮤즈는 대용량 생성을 안전하고 유지보수하기 쉽게 관리하기 위해 클라이언트 제어식 동시성 풀(Concurrency Pool)과 메타데이터 사이드카(Metadata Sidecar) 아키텍처를 구축했습니다.
사용자가 prompts.json (텍스트 배열 형태) 파일을 업로드하면, 백엔드는 Promise 기반 동시성 풀 제어기를 작동시킵니다 (동시 실행 수 1~10개 조절 가능). 모든 요청을 단번에 쏘는 대신, 먼저 실행된 생성 요청이 완료될 때마다 큐(Queue)가 비어있는 자리에 새 작업을 주입하는 동적 스케줄링 방식입니다.
만약 특정 프롬프트 생성에 실패하더라도, 오류 내역을 별도 세션 로그에만 기록하고 전체 프로세스를 멈추지 않고 끝까지 작업을 이어가도록 예외 처리를 엄격히 설계했습니다.
생성된 모든 이미지 파일 옆에는 생성 정보와 동일한 고유 ID를 지닌 {id}.json 메타데이터 사이드카가 생성되어 세트로 저장됩니다. 여기에는 다음 정보들이 기재됩니다.
이 사이드카 설계 덕분에 미디어 스토리지(S3/R2)와 데이터베이스의 종속성이 완벽히 분리되었습니다. 만약 메인 DB에 이상이 생기거나 이관해야 하는 경우, 스토리지를 스캔해 JSON 파일들만 파싱하면 전체 갤러리 메타데이터를 100% 복원해 낼 수 있어 인프라 안정성을 확보했습니다.