Database scaling

Most applications use relational databases to store their transactional data. The main problem with relational databases is that they can scale horizontally until you plan for other techniques such as sharding and modifying your application accordingly. This sounds like a lot of work.

When it comes to databases, it is better to take preventive care and reduce their load. Using a mix of storage, such as storing user sessions in separate NoSQL databases and storing static content in an object store, helps to offload the master database. It's better to keep the master database node only for writing and updating data and use an additional read replica for all read requests.

Amazon RDS engine provides up to six read replicas for relational databases, and Oracle plugins can live-sync data between two nodes. Read replicas may have milliseconds of delay while syncing with the master node, and you need to plan for that while designing your application. It is recommended to use a caching engine such as Memcached or Redis to cache frequent queries and thus reduce the load to the master node.

If your database starts growing beyond capacity, then you need to redesign and divide the database in the shard by applying partitions. Here, each shard can grow independently, and the application needs to be determined based on a partition key that the shard request will go to.

So, as you can see, scalability is a significant factor while designing a solution architecture, and it can impact the overall project budget and user experience significantly if it's not planned properly. A solution architect always needs to think in terms of elasticity while designing applications and optimizing workloads for the best performance and cost.

Statistical Analysis System (SAS) need to evaluate different options such as CDNs for static content scaling, load balancing, and autoscaling options for server scaling and various data storage options for caching, object stores, NoSQL stores, read replicas, and sharding.

In this section, you learned about various methods of scaling and how to inject elasticity into the different layers of your architecture. Scalability is an essential factor to ensure you have high application availability and make your application resilient. We'll learn more about high availability and resiliency in the next section.