AI image generation in production has three problems: it’s slow, it’s expensive, and quality depends on serving configuration. A team building a content pipeline or creative tool hits all three at once. Users stare at spinners, GPU bills climb with traffic, and outputs look different depending on which replica handled the request. At AWS Professional Services, we built a solution that generates high-quality images at low cost by running Z-Image-Turbo , a 6-billion-parameter diffusion transformer, on AWS Inferentia2 accelerators.

The service runs on Amazon Elastic Container Service (Amazon ECS) as a standard containerized microservice. It uses three ECS services (one per resolution), each backed by an internal Application Load Balancer (ALB) . Compiled model artifacts are cached on Amazon Elastic File System (Amazon EFS) so containers start fast and scale out without recompilation. This post covers the cost problem, how we solved it with ECS, and how to deploy the solution. A diffusion model generates an image by starting from random noise and refining it over a series of denoising steps.

Each step is one full forward pass through the model. Z-Image-Turbo needs 8 steps where most models need 20–50, but each step still requires the full 6 billion parameters to be resident in accelerator memory. 8xlarge instance, a 512px image (4. 003 and a 1024px image (19. Those numbers are low enough for an embedded feature, but only if containers start fast. The bottleneck is model compilation. These cost estimates are accurate as of publication. Verify current pricing for your AWS Region. In this post, we walk through deploying our sample inference architecture in your AWS account.

The solution is composed of six AWS Cloud Development Kit (AWS CDK) stacks that deploy in dependency order: The following architecture diagram shows how a prompt flows from the React frontend through API Gateway and Lambda to the Inferentia2-backed ECS services. Figure 1: Request flow from the React frontend through API Gateway and Lambda to the Inferentia2-backed Amazon ECS services The ECS tasks in this architecture run on Amazon Elastic Compute Cloud (Amazon EC2) inf2. 8xlarge instances in an Auto Scaling group. Amazon ECS Managed Instances now supports Inferentia2 and is a great fit for this workload.