Same Architecture, Different Deployment: Why Traffic Shape Beats Diagrams
Most deployment advice starts with architecture. Draw the boxes, pick the services, ship it. I believed that was the whole job until a client project showed me otherwise. Two projects can have the same architecture diagram and still need very different deployments. What decides it is the features of the app and the shape of its traffic. This post is about the project that made that clear to me,…
When given a choice between architecture diagrams and deployment methods, the traffic shape of an application often dictates the optimal deployment strategy. This became evident during a client project where two seemingly identical architectures required drastically different deployments due to varying traffic patterns. The project, which involved moving to EC2 and Ansible instead of more fashionable options, demonstrated that features and traffic shape matter more than the initial architecture.
The client's app had modest traffic, approximately 3,000 users per day, but its behavior changed during traffic spikes. Normal days saw about 3,000 users, while product releases and holidays caused double or more users in short bursts. This meant that fixed servers would either be oversized or too small at critical times. To avoid this, a different deployment strategy was needed for each situation.
The main options were EC2 with Auto Scaling and Load Balancer (ALB) for steady loads, ECS on Fargate for unpredictable spikes, and Lambda for small event-driven jobs. Each option had its advantages and disadvantages. EC2 with Auto Scaling was the cheapest at steady load, offered full control, and worked well with the team's Ansible roles.
ECS on Fargate had no patching and scaled per task, but it was more expensive and didn't provide direct server access. Lambda had near-zero idle costs and instant scaling but had limitations like a 15-minute execution limit and potential DB connection pressure. EKS was best for heavy, 24/7 loads with a team already familiar with Kubernetes, but it had a steep learning curve and higher operational costs.
Ultimately, the team chose EC2 with Auto Scaling and ALB for three reasons: the traffic was small, the spike dates were known, and Ansible roles were already in place. Scheduled scaling covered known spikes without paying for Fargate premiums year-round. If the team had wanted to avoid patching, they would have chosen Fargate instead.
To ensure reliability, they set the minimum capacity to two instances across two availability zones, used target tracking for scaling based on CPU or ALB requests, and baked an AMI to speed up new instance provisioning. Health checks were set up to automatically replace any broken instances.
When comparing EC2 with Fargate, EC2's isolation and OS patching were important factors. Fargate eliminates the need for patching but offers less host-level control. Security-wise, EC2 requires more manual hardening but gives the team more control over security agents. The choice between EC2 and Fargate ultimately depends on the specific security and isolation requirements of the project.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.