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.
The Cloud at Your Service ebook for free