keepcalculator

06 Numbers and Powers

Cloud Design Choices That Hurt Performance

Card No. 06·61675 · Updated · Standard formula, shown below

This guide helps you spot common cloud architecture decisions that quietly degrade performance, such as chatty APIs, oversized instances, or ignoring caching. You’ll learn what to look for in your own setup and how to fix the most frequent culprits before users notice.

What You’ll Need

  • Access to your cloud provider’s console or CLI (AWS, Azure, GCP, etc.)
  • Basic familiarity with your application’s architecture (services, databases, storage)
  • Monitoring or logging tools (CloudWatch, Azure Monitor, or similar) to check metrics
  • Permission to view instance types, database settings, and network configurations

Step-by-Step

  1. Map your request flow. Draw or list every step a user request takes: load balancer → app server → database → cache → third-party API. This gives you a baseline to spot where delays could creep in.
  2. Check for chatty APIs. Look at your application code and API endpoints. If a single user action triggers 10+ separate HTTP calls, that’s a red flag. Each round trip adds network latency, even in the same region. Consolidate related data into fewer, larger responses (e.g., GraphQL or a custom aggregate endpoint).
  3. Review database queries. Enable slow query logging and look for queries that scan large tables or lack proper indexes. Use EXPLAIN (or your DB’s equivalent) to see execution plans. Add indexes on columns used in WHERE, JOIN, and ORDER BY clauses. Avoid SELECT *; fetch only needed columns.
  4. Evaluate instance sizing. Look at your CPU, memory, and network utilization over a week. If your instances are consistently under 20% CPU, they’re oversized and you’re paying for idle capacity—but that’s a cost issue. For performance, the bigger problem is undersized instances: if CPU is pegged at 90%+ during peak, you need to scale up or out. Check if your workload is burstable (t3/t4g on AWS, B-series on Azure) and whether you’re exhausting CPU credits.
  5. Inspect auto-scaling settings. If you use auto-scaling, check the threshold and cooldown periods. A common mistake is setting the scale-up threshold too high (e.g., 80% CPU) so new instances launch only after performance already suffers. Lower the threshold to 50-60% and shorten cooldowns to react faster. Also ensure you scale on the right metric—CPU may not be the bottleneck; memory or request count might be.
  6. Look for missing caching. Check if you’re caching database results, API responses, or static assets. If not, that’s a huge miss. Implement caching at multiple levels: CDN for static content, in-memory cache (Redis/Memcached) for frequently read data, and HTTP caching headers for API responses. Even a simple cache can cut response times by 80%.
  7. Examine network topology. Are your app servers in a different region than your database? Cross-region traffic adds 50-100ms per request. Move resources to the same region or use read replicas in the app’s region. Also check if you’re using a VPN or NAT gateway that adds overhead—sometimes a direct VPC endpoint is faster.
  8. Check for synchronous dependencies. If a user request waits for a slow email service or a third-party API call, that’s a synchronous bottleneck. Move such tasks to a queue (SQS, RabbitMQ, etc.) and process them asynchronously. The user gets a response immediately, and the background worker can take its time.
  9. Review database connection pooling. If your app opens a new database connection per request, that’s expensive. Use a connection pool (e.g., HikariCP for Java, SQLAlchemy pool for Python) and set reasonable max connections. Too many connections can overwhelm the database; too few cause waiting.
  10. Monitor cold starts (serverless). If you use Lambda or Azure Functions, check for cold start latency. Keep functions warm with scheduled invocations, or provisioned concurrency for critical paths. Also reduce package size and avoid heavy initialization code.

Common Mistakes

  • Ignoring network latency between services. Microservices that call each other synchronously in a chain can multiply latency. A single request might hit 5 services, each adding 20ms—that’s 100ms before even processing.
  • Over-fetching data. Returning entire objects when only a few fields are needed. This increases payload size and serialization time.
  • Using a single database for everything. Mixing OLTP and OLAP workloads on one instance can cause contention. Separate read replicas or use a data warehouse for analytics.
  • Forgetting to set timeouts. If a downstream service hangs, your request hangs too. Always set timeouts and circuit breakers.
  • Scaling vertically instead of horizontally. Upgrading to a bigger instance is easy but hits a ceiling and creates a single point of failure. Horizontal scaling with load balancing is more resilient.

Tips

  • Use a CDN for static assets. It offloads traffic from your origin and reduces latency for global users.
  • Enable HTTP/2. It multiplexes requests over a single connection, reducing overhead.
  • Compress responses. Gzip or Brotli can shrink payloads by 70%, speeding up transfer.
  • Prefer read replicas for reporting. Keep heavy analytical queries off your primary database.
  • Set up alerting on performance metrics. Don’t wait for users to complain. Monitor p95 latency, error rates, and saturation.

Troubleshooting

What if the steps don’t reveal the issue? Start by measuring, not guessing. Use an APM tool (like New Relic or Datadog) to trace a single request end-to-end. Look for the slowest segment—it might be a database query, an external API, or even a serialization bottleneck in your code.

If you find a bottleneck but can’t fix it immediately, implement a temporary mitigation: add a cache, increase instance size, or offload work to a queue. Then plan a proper fix.

What if performance is fine in dev but poor in production? Check for differences: production data volume is larger, so indexes may not be used. Run ANALYZE to update statistics. Also, production may have more concurrent users, exposing connection pool limits.

If everything looks correct but performance is still bad, check for noisy neighbors in shared infrastructure (e.g., burstable instances that exhaust credits). Move to a dedicated instance or a different instance family.

Frequently Asked Questions

How do I know if my database is the bottleneck?

Monitor database CPU, connection count, and query latency. If CPU is high and queries are slow, it’s likely the bottleneck. Use slow query logs to find the culprits.

Is it better to scale up or scale out?

Scale out (add more instances) is generally better for performance and resilience, as long as your application is stateless. Scale up is simpler but has limits and creates a single point of failure.

What’s the biggest performance mistake in cloud design?

Ignoring network latency. Every round trip between services adds delay. Minimize the number of calls and keep data close to where it’s processed.

Can too much caching hurt performance?

Yes. Stale data can cause incorrect behavior, and cache invalidation logic can add complexity. Always set appropriate TTLs and invalidate on data changes.

Should I use a monolithic or microservices architecture for performance?

Monoliths often perform better due to fewer network hops. Microservices offer scalability but add latency. If you’re microservices, use asynchronous communication and caching to mitigate.

How can I reduce cold starts in serverless?

Use provisioned concurrency, keep functions warm with scheduled pings, minimize deployment package size, and avoid loading heavy libraries at startup.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →