Overview

Chapter 5. Designing and architecting for cloud scale

This chapter explains how cloud applications must be designed differently when they are expected to serve internet-scale audiences or experience rapid growth. It introduces the main cloud-scaling patterns: moving an existing application unchanged for cost reasons, building new applications for huge user growth, handling occasional compute bursts, and using storage that can expand as needed. The core message is that cloud value comes not just from infrastructure, but from designing systems that can absorb sudden demand, scale economically, and avoid the limits that often constrain traditional data centers.

A major focus is sharding, or partitioning a database across multiple machines so the load can be spread out in parallel instead of concentrated on one server. The text shows that large working sets and excessive writes are common scaling barriers, and that breaking data into smaller, independent shards can improve throughput, availability, caching, and write performance. At the same time, sharding introduces complexity: data may need to be rebalanced, queries may require pulling from multiple shards, referential integrity becomes harder to enforce, and operational support is often limited. The chapter uses real-world examples such as Facebook and Flickr to show why large web services eventually have to abandon centralized database designs.

The chapter also covers cloudbursting and elastic storage as practical ways to extend enterprise systems. Cloudbursting lets an application keep its core in the data center while pushing overflow work to the cloud during spikes, which can be far cheaper than overprovisioning local hardware, though it requires careful handling of queues, load balancing, data movement, and vendor dependence. For storage, the chapter describes cloud storage services such as S3 and block storage options such as EBS, emphasizing their scalability but also warning about latency, transfer costs, and the need to place data close to where it will be used. Overall, the chapter argues that successful cloud architecture depends on matching the application pattern to the right scaling strategy and planning for data, performance, and operational complexity from the start.

Statistics that show why sites such as eBay can’t survive with a centralized database. That database must be partitioned into multiple databases. Partitioning (or sharding) is a critical strategy for scaling.
Basic database sharding partitions the database based on who will access that part of the service. In this example, the criteria are that odd-numbered users go in one partition and even-numbered go in the other.
The traditional approach to scaling a database. Bigger servers drive bigger databases. But the system is throttled by how fast the server and the disk subsystem can handle writes, and it quickly reaches its limits when dealing with internet scale.
The sharding approach to database scaling uses more modest servers (usually based on cheap commodity hardware) with modest databases, where each server and its associated database takes on a portion of the database load. A good partitioning scheme balances the load and allows continued expansion as the application continues to scale.
A hypothetical social networking site that employed vertical (feature-based) partitioning when it implemented sharding to help it scale its application to ever-larger numbers of users
Rebalancing data. Initially, the GetDatabaseFor() function pushed requests for partition A to the center server. But that server’s database shard has gotten too large and needs to be rebalanced. All or a portion of database A is moved to the server on the left. After that data is successfully moved, the function GetDatabaseFor() is modified so that future requests for shard A are directed to the leftmost server.
The profile of the Flickr photo-sharing site, showcasing its large number of users and data
Flickr’s architecture includes many levels. First is load balancing as incoming connection requests arrive. Squid caches are open-source web-delivery systems that operate as reverse proxies for HTML pages and images. The PHP App Servers connect to the shards and keep the data consistent. The storage managers do the actual mapping from an index to the correct shard. NetApps are for mass storage of photos. Their fundamental database architecture uses dual masters for each shard. This gives them resilience in the case of failure. The dual-tree structure is a custom set of changes to MySQL that allows scaling by incrementally adding masters without a ring architecture. The central database includes data, such as the users table, which includes primary user keys (a few different IDs) and a pointer to which shard a user’s data can be found on. The Big Search Engine is a replication of the database Flickr wants to search.
A highly simplified cloudbursting architecture showing that most users are directed by the load-balancer to the data center. After capacity is reached, additional users are directed to the cloud-resident portion of this application.
Eventseer’s cloudbursting architecture. Eventseer’s data center operates the production servers that serve all pages to site visitors, the master database, and the master queue of pages that need updating. The database is synced regularly over to Amazon’s S3 so a replica of the current database is resident in the cloud when needed. Twice a day, an array of AMIs are spun up in EC2, and each is provided a copy of the database replica. Work to perform comes from the queue, which is updated periodically. Final static pages are sent back to the production data center at Eventseer.

FAQ

What are the main application patterns that fit cloud computing best in this chapter?The chapter highlights four common high-scale patterns that often motivate cloud adoption: transference, internet scale, burst compute, and elastic storage. Each pattern addresses a different need, such as moving an existing application as-is, handling huge user growth, managing temporary compute spikes, or storing rapidly expanding data.
What is transference in cloud computing?Transference is the pattern of moving an existing on-premises application to the cloud without major redesign. It is usually driven by cost savings, especially for commodity services like email or CRM. The main caution is that local customizations or unsupported components may prevent a clean move.
What does “internet scale” mean in the context of cloud architecture?Internet scale refers to designing applications that can handle very large and unpredictable numbers of users without requiring huge upfront infrastructure investments. These systems should be able to start small and expand as demand grows. A major challenge is ensuring the database does not become the bottleneck.
Why does database design become a problem for internet-scale applications?At large scale, the database can throttle growth because of too much memory demand for the working set or too many writes for a single server to handle. As usage increases, read and write load can overwhelm traditional database architectures. Sharding is presented as the primary solution to this problem.
What is sharding, and why is it important?Sharding is the partitioning of a database into multiple smaller units, called shards, that can be handled independently and in parallel. It improves scalability, write throughput, availability, and query performance. It is especially valuable for internet-scale services with massive amounts of data and traffic.
How does sharding change an application’s code?Instead of connecting to one database directly, the application must first determine which shard contains the needed data. This is often done with a method such as GetDatabaseFor(), which maps an entity like a customer ID or user ID to the correct database. The rest of the application can often remain largely unchanged.
What are the common sharding strategies described in the chapter?The chapter describes vertical partitioning, range-based partitioning, key- or hash-based partitioning, and directory-based partitioning. Vertical partitioning separates features into different databases, range-based partitioning splits by values like year or zip code, hash-based partitioning uses a function such as modulo, and directory-based partitioning relies on a lookup service for flexibility.
What are the main challenges or drawbacks of sharding?Sharding is powerful but complicated. Challenges include rebalancing data when shards grow unevenly, joining data across multiple shards, enforcing referential integrity, and dealing with limited tooling and support. It can also introduce new single points of failure if a lookup service is used.
What is cloudbursting?Cloudbursting is a hybrid model where an application runs partly in a local data center and partly in the cloud. The local environment handles normal operations, and the cloud provides extra capacity during spikes or overflow periods. It is especially useful when demand is irregular or when some tasks are better handled outside the enterprise.
What is cloud storage, and what role do services like Amazon S3 and EBS play?Cloud storage is storage accessed over a network through web service APIs, usually in a RESTful style. Amazon S3 provides scalable object storage for buckets and objects, while EBS offers block storage that can be attached to EC2 instances like a mounted disk. These services help applications scale storage capacity and preserve data across instance shutdowns.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • The Cloud at Your Service The Cloud at Your Service ebook for free
Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • The Cloud at Your Service The Cloud at Your Service ebook for free