The IoT Fortress

The IoT Fortress

In our previous article, we discussed the "Indestructible Frontend" for static sites. But static files are only half the story.

What happens when you are building a complex ecosystem with heavy backend logic? What if that ecosystem needs to host 7 different applications, talk to thousands of IoT devices via raw TCP, and handle traffic spikes that jump from zero to massive in seconds?

For one of our long-term clients in the IoT sector, we built exactly that: A fully serverless, auto-scaling architecture that balances high performance with aggressive cost optimization.

Here is the anatomy of a battle-tested, 3-year-old architecture that runs on Autopilot.

The Challenge: The "Multiverse" of Load

Our client manages a fleet of IoT devices. This isn't just one website; it is a suite of 6 HTTP applications (api, reporting, administration, billing, loyalty, dashboarding ) and 1 dedicated IoT ingestion service.

We needed a system that could:

  1. Handle standard web traffic and raw TCP communication for devices.
  2. Scale from 1 instance to 20 instances in minutes during peak reporting hours.
  3. Minimize operational overhead (so the client doesn't need to pay us for simple tasks, like adding SSH users).

1. The Compute: ECS Fargate + Spot Strategy

We host all 7 applications on Amazon ECS (Elastic Container Service) on Fargate. Fargate is "serverless for containers", we don't manage the underlying infrastructure; AWS does.

To keep costs low while running 24/7, we implemented a Hybrid Capacity Strategy:

  • The Baseline (Standard Fargate): We keep a minimum number of tasks running on standard Fargate. These are covered by AWS Compute Savings Plans, locking in a ~40% discount for the steady-state traffic.
  • The Burst (Fargate Spot): As soon as traffic spikes, the Auto-Scaling capability kicks in. It spins up additional instances using Fargate Spot.

The Result: Spot instances cost up to 90% less than on-demand prices. When the IoT devices flood the server, we scale out using "spare" AWS capacity for pennies on the dollar.

2. The Network: Dual-Layer Load Balancing

Because IoT devices in this ecosystem communicate differently than standard web browsers, we deployed a dual-layer networking strategy:

  • Layer 7 (HTTP): An Application Load Balancer (ALB) handles the 6 web applications. It routes traffic based on host headers and handles SSL termination.
  • Layer 4 (TCP): A Network Load Balancer (NLB) handles the high-throughput, low-latency TCP traffic from the IoT devices.

3. The "Serverless" Bastion (Ops as Code)

Accessing the private database usually requires a "Bastion Host" (a jump server). Traditionally, this is an EC2 instance that sits idle, costing money and requiring manual updates.

Since we were already paying for an NLB to handle IoT traffic, we maximized its value by placing the Bastion behind it. We created the smallest possible Fargate task to serve as the Bastion, allowing secure SSH connections via port 22 through the existing load balancer.

But the real magic is in the management. We don't manually maintain this instance. The configuration is defined via Dockerfile and stored in GitHub.

  • The Workflow: To give a new developer access, we simply add their public SSH key to the repository code.
  • The Automation: The CI/CD pipeline detects the change, rebuilds the Bastion container, and redeploys it automatically.

This "Ops-Free" approach means the client never has to pay us support hours just to create a user account. It offers the client total autonomy and is handled entirely by code.

4. The Bottleneck Breaker: RDS Proxy

As the traffic grew, we hit a classic scaling problem: Database Connection Exhaustion. When Fargate scaled from 2 to 20 instances, every new container opened multiple connections to the database. During peak load, this flood of connections overwhelmed the database, causing timeouts.

We solved this by implementing Amazon RDS Proxy. Instead of connecting directly to the database, our applications connect to the Proxy.

  • Connection Pooling: The Proxy shares a pool of active connections, allowing our applications to scale to thousands of concurrent requests without overloading the database.
  • Faster Failover: If the database updates or fails over, RDS Proxy maintains the application connections, reducing failover times by up to 66%.
  • Enhanced Security: It enforces IAM authentication, removing the need to hardcode database credentials in the application.

5. The Database: Aurora on Graviton

The backend connects to an Amazon Aurora MySQL database (via the Proxy). We migrated this to AWS Graviton instances (ARM-based processors).

  • Performance: Graviton offers better price-performance than standard x86 instances.
  • Stability: Aurora is fully managed. No manual backups, no patching, no downtime.

The Price of Excellence

You might expect an enterprise architecture hosting 7 apps, a production database, a database proxy, multiple load balancers, and a global CDN to cost thousands per month.

Because of our heavy use of Spot Instances, Graviton processors, and Savings Plans, the total infrastructure bill for this client sits around $750 USD per month.

That is roughly $107 per application for a self-healing, auto-scaling, secure environment that handles thousands of devices.

Architecture Diagram

Here is how the traffic flows through our secure, scalable fortress.

The IoT Fortress Diagram Figure 1: The IoT Fortress Architecture. Traffic flows through dual load balancers (ALB/NLB), while RDS Proxy protects the database from connection floods during auto-scaling events.

Conclusion: Peace of Mind as a Service

This architecture represents the sweet spot of modern cloud engineering. It is Serverless (no OS management), Scalable (1 to 20+ instances), and Cost-Optimized.

Our client sleeps well knowing that if 5,000 devices suddenly connect at 3 AM, the infrastructure will handle it, and they won’t go broke paying for it.


Ready to scale your business?

Whether you have a simple static site or a complex IoT ecosystem, we build infrastructure that grows with you. Contact us at support@sevenseven.tech or fill out our contact form.