Showing posts with label Read a Thin Book. Show all posts
Showing posts with label Read a Thin Book. Show all posts

Tuesday, January 13, 2015

Read a Thin Book - Cloud Architecture Patterns - 3 - Database Sharding

Database Sharding


It is a technique to scale data horizontally.

Impress on this is to start with single database and then divvy up its data across multiple ones (shards). Each one has same schema as original one. most data is distributed so that each row appears in exactly one shard. The combined data from all shards form single logical database.

When to use


-- when query volume, update volume and storage requirements etc exceed capacity of single database
--when you can no longer scale up or scaling up involves unacceptable cost comparing to scaling out.

Implementation


In database integrated sharding support, such as federation in MySQL and SQL Server.
This pushes complexity out of application code and into the database service.

Application layer support. expensive and complex, but more flexible. If you want to shard Oracle database, likely you will have to go through this approach.

Usually specific database column is designed as shard key that determines which shard node data should goes to. the shard key is also needed in order to access data.

Even sharding usually means horizontal split and stores different set of same structured data into different nodes, functional split or vertical split is very often the first step to go before data can be further sharded (horizontal split). Each function area has a shard group, in each shard group, data is horizontally split. For example, for a function area dedicated for customers, a shard group is created for it, with the group, customer data is split and distributed according to last name.

Well designed sharding may only shard certain tables, commonly used reference tables can simply be replicated entirely.

In order to be efficient, single shard should be able to satisfy most of common database operations without having to resort to another shard. (share nothing)

As a common practice, all the shard nodes should have UTC as their time,

Related Concept or Areas


Scalability, eventual consistency, shared nothing/autonomous

Challenges


Aggregation usually for report usually is a challenge and has to resort to application, NoSQL database such as CouchBase support MapResuce that span shards, but not common to most of databases.

Adding nodes and design shard key is also a challenge. poorly designed sharding plan may introduce huge volume of data movement.

Materials

http://www.google.com/url?q=http%3A%2F%2Fintermediatesql.com%2Fsharding%2Fioug-collaborate-2012-the-art-of-database-sharding%2F&sa=D&sntz=1&usg=AFQjCNFxJ6PTrdYTsV1Q-TRieXl4K6z-7Q



Tuesday, January 06, 2015

Read a Thin Book - Cloud Architecture Patterns - 2

CDN

Content Delivery Network

Definition

A service that provide global caching.

Benefits


Reduce latency by routing client to nearest data node.
Distribute load to multiple nodes
Redundancy by replication
Availability
scalability

Drawbacks


First access to the file is slower(subsequent access is faster by accessing local region cache)

Mechanics

Edge caching. providing content to user from closest location. CDN's role is to provide edge caching.

Cache content (files) on many nodes globally around the world.

Only master copy matters.

It differs from multisite deployment in term of content vs application, reading vs reading and writing.

Using URL provided by CDN provider so that CDS can determine when to use cache

Whenever user want to access content controlled by CDN service, CDN will determine closest CDN node to serve client. anycast protocal)

Cached content has expiration period, and changes will be propagated by CDN service.

Challenges

Cache can be out of dated. Sync needs time to happen. (example of eventual consistency. immediate consistency is traded off to availability ad scalability)

Usage

Good for repeatedly used files,  big multimedia files such as video and voice content

Misc

Usually this can be enabled in cloud storage service. E.g. Windows Azure Blob Storage.

Monday, January 05, 2015

Read a Thin Book - Cloud Architecture Patterns - 1

Multisite Deployment


Definition


Deploying your application to multiple data centers. For both reading and writing.

Benefits


Reduce latency by routing client to nearest data center.
failover across data centers improves availability.

Constraints


Costly.
There will have data loss during failover.

Mechanics


Cloud platform provides service for geographic load balancing. Traffic Manager in Azure and Elastic Load Balancing in AWS.

Data replication between data storage in different data centers. (eventual consistency)


Challenges

Determine service failure

Misc

Geographic load balancing and data replication are all configurable in cloud platforms.