Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 289 trang
THÔNG TIN TÀI LIỆU
Cấu trúc
Contents
Preface
Acknowledgments
1 Introducing Amazon SimpleDB
What Is SimpleDB?
What SimpleDB Is Not
Schema-Less Data
Stored Securely in the Cloud
Billed Only for Actual Usage
Domains, Items, and Attribute Pairs
Multi-Valued Attributes
Queries
High Availability
Database Consistency
Sizing Up the SimpleDB Feature Set
Benefits of Using SimpleDB
Database Features SimpleDB Doesn’t Have
Higher-Level Framework Functionality
Service Limits
Abandoning the Relational Model?
A Database Without a Schema
Areas Where Relational Databases Struggle
Scalability Isn’t Your Problem
Avoiding the SimpleDB Hype
Putting the DBA Out of Work
Dodging Copies of C.J. Date
Other Pieces of the Puzzle
Adding Compute Power with Amazon EC2
Storing Large Objects with Amazon S3
Queuing Up Tasks with Amazon SQS
Comparing SimpleDB to Other Products and Services
Windows Azure Platform
Google App Engine
Apache CouchDB
Dynamo-Like Products
Compelling Use Cases for SimpleDB
Web Services for Connected Systems
Low-Usage Application
Clustered Databases Without the Time Sink
Dynamic Data Application
Amazon S3 Content Search
Empowering the Power Users
Existing AWS Customers
Summary
2 Getting Started with SimpleDB
Gaining Access to SimpleDB
Creating an AWS Account
Signing Up for SimpleDB
Managing Account Keys
Finding a Client for SimpleDB
Building a SimpleDB Domain Administration Tool
Administration Tool Features
Key Storage
Implementing the Base Application
Displaying a Domain List
Adding Domain Creation
Supporting Domain Deletion
Listing Domain Metadata
Running the Tool
Packaging the Tool as a Jar File
Building a User Authentication Service
Integrating with the Spring Security Framework
Representing User Data
Fetching User Data with SimpleDBUserService
Salting and Encoding Passwords
Creating a User Update Tool
Summary
3 A Code-Snippet Tour of the SimpleDB API
Selecting a SimpleDB Client
Typica Setup in Java
C# Library for Amazon SimpleDB Setup
Tarzan Setup in PHP
Common Concepts
The Language Gap
SimpleDB Endpoints
SimpleDB Service Versions
Common Response Elements
CreateDomain
CreateDomain Parameters
CreateDomain Response Data
CreateDomain Snippet in Java
CreateDomain Snippet in C#
CreateDomain Snippet in PHP
ListDomains
ListDomains Parameters
ListDomains Response Data
ListDomains Snippet in Java
ListDomains Snippet in C#
ListDomains Snippet in PHP
DeleteDomain
DeleteDomain Parameters
DeleteDomain Response Data
DeleteDomain Snippet in Java
DeleteDomain Snippet in C#
DeleteDomain Snippet in PHP
DomainMetadata
DomainMetadata Parameters
DomainMetadata Response Data
DomainMetadata Snippet in Java
DomainMetadata Snippet in C#
DomainMetadata Snippet in PHP
PutAttributes
PutAttributes Parameters
PutAttributes Response Data
PutAttributes Snippet in Java
PutAttributes Snippet in C#
PutAttributes Snippet in PHP
GetAttributes
GetAttributes Parameters
GetAttributes Response Data
GetAttributes Snippet in Java
GetAttributes Snippet in C#
GetAttributes Snippet in PHP
DeleteAttributes
DeleteAttributes Parameters
DeleteAttributes Response Data
DeleteAttributes Snippet in Java
DeleteAttributes Snippet in C#
DeleteAttributes Snippet in PHP
BatchPutAttributes
BatchPutAttributes Parameters
BatchPutAttributes Response Data
BatchPutAttributes Snippet in Java
BatchPutAttributes Snippet in C#
BatchPutAttributes Snippet in PHP
Select
Select Parameters
Select Response Data
Select Snippet in Java
Select Snippet in C#
Select Snippet in PHP
Summary
4 A Closer Look at Select
Select Syntax
Required Clauses
Select Quoting Rule for Names
Output Selection Clause
WHERE Clause
Select Quoting Rules for Values
Sort Clause
LIMIT Clause
Formatting Attribute Data for Select
Integer Formatting
Floating Point Formatting
Date and Time Formatting
Case Sensitivity
Expressions and Predicates
Simple Comparison Operators
Range Operators
IN() Queries
Prefix Queries with LIKE and NOT LIKE
IS NULL and IS NOT NULL
Multi-Valued Attribute Queries
Multiple Predicate Queries with the INTERSECTION Operator
Selection with EVERY()
Query Results with the Same Item Multiple Times
Improving Query Performance
Attribute Indexes
Composite Attributes
Judicious Use of LIKE
Running on EC2
Skipping Pages with count() and LIMIT
Measuring Select Performance
Automating Performance Measurements
Summary
5 Bulk Data Operations
Importing Data with BatchPutAttributes
Calling BatchPutAttributes
Mapping the Import File to SimpleDB Attributes
Supporting Multiple File Formats
Storing the Mapping Data
Reporting Import Progress
Creating Right-Sized Batches
Managing Concurrency
Resuming a Stopped Import
Verifying Progress and Completion
Properly Handling Character Encodings
Backup and Data Export
Using Third-Party Backup Services
Writing Your Own Backup Tool
Restoring from Backup
Summary
6 Working Beyond the Boundaries
Availability: The Final Frontier
Boundaries of Eventual Consistency
Item-Level Atomicity
Looking into the Eventual Consistency Window
Read-Your-Writes
Implementing a Consistent View
Handling Text Larger Than 1K
Storing Text in S3
Storing Overflow in Different Attributes
Storing Overflow as a Multi-Valued Attribute
Entities with More than 256 Attributes
Paging to Arbitrary Query Depth
Exact Counting Without Locks or Transactions
Using One Item Per Count
Storing the Count in a Multi-Valued Attribute
Testing Strategies
Designing for Testability
Alternatives to Live Service Calls
Summary
7 Planning for the Application Lifecycle
Capacity Planning
Estimating Initial Costs
Keeping Tabs on SimpleDB Usage with AWS Usage Reports
Creating More Finely Detailed Usage Reports
Tracking Usage over Time
Storage Requirements
Computing Storage Costs
Understanding the Cost of Slack Space
Evaluating Attribute Concatenation
Scalability: Increasing the Load
Planning Maintenance
Using Read-Repair to Apply Formatting Changes
Using Read-Repair to Update Item Layout
Using a Batch Process to Apply Updates
Summary
8 Security in SimpleDB-Based Applications
Account Security
Managing Access Within the Organization
Limiting Amazon Access from AWS Credentials
Boosting Security with Multi-Factor Authentication
Access Key Security
Key Management
Secret Key Rotation
Data Security
Storing Clean Data
SSL and Data in Transmission
Data Storage and Encryption
Storing Data in Multiple Locations
Summary
9 Increasing Performance
Determining If SimpleDB Is Fast Enough
Targeting Moderate Performance in Small Projects
Exploiting Advanced Features in Small Projects
Speeding Up SimpleDB
Taking Detailed Performance Measurements
Accessing SimpleDB from EC2
Caching
Concurrency
Keeping Requests and Responses Small
Operation-Specific Performance
Optimizing GetAttributes
Optimizing PutAttributes
Optimizing BatchPutAttributes
Optimizing Select
Data Sharding
Partitioning Data
Multiplexing Queries
Accessing SimpleDB Outside the Amazon Cloud
Working Around Latency
Ignoring Latency
Summary
10 Writing a SimpleDB Client: A Language-Independent Guide
Client Design Overview
Public Interface
Attribute Class
Item Class
Client Design Considerations
High-Level Design Issues
Operation-Specific Considerations
Implementing the Client Code
Safe Handling of the Secret Key
Implementing the Constructor
Implementing the Remaining Methods
Making Requests
Computing the Signature
Making the Connections
Parsing the Response
Summary
11 Improving the SimpleDB Client
Convenience Methods
Convenient Count Methods
Select with a Real Limit
Custom Metadata and Building a Smarter Client
Justifying a Schema for Numeric Data
Database Tools
Coordinating Concurrent Clients
Storing Custom Metadata within SimpleDB
Storing Custom Metadata in S3
Automatically Optimizing for Box Usage Cost
The Exponential Cost of Write Operations
QueryTimeout: The Most Expensive Way to Get Nothing
Automated Domain Sharding
Domain Sharding Overview
Put/Get Delete Routing
Query Multiplexing
Summary
12 Building a Web-Based Task List
Application Overview
Requirements
The Data Model
Implementing User Authentication
Implementing a Task Workspace
Implementing a Task Service
Adding the Login Servlet
Adding the Logout Servlet
Displaying the Tasks
Adding New Tasks
Deployment
Summary
Index
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Nội dung
[...]... create and delete domains as needed.There are no configuration options to set on a domain; the only parameter you can set is the name of the domain All the data stored in aSimpleDB domain takes the form of name-value attribute pairs Each attribute pair is associated with an item, which plays the role of a table row The attribute name is similar to a database column name but unlike database rows that must... stored in SimpleDB is treated as plain string data.There are no explicit indexes to maintain; each value is automatically indexed as you add it High Availability High availability is an important benefit of using SimpleDB. There are many types of failures that can occur with a database solution that will affect the availability of your application.When you run your own database servers, there is a spectrum... change, store it differently without changing the database Low latency within the same region— Access toSimpleDB from an EC2 instance in the same region has the latency of a typical LAN Low maintenance— Most of the administrative burden is transferred to Amazon They maintain the hardware and the database software Sizing Up the SimpleDB Feature Set Database Features SimpleDB Doesn’t Have There are a. .. configurations you can employ To help quantify the availability benefits that you get automatically with SimpleDB, let’s consider how you might achieve the same results using replication for your own database servers.At the easier end of the spectrum is a master-slave database replication scheme, where the master database accepts client updates and a second database acts as a slave and pulls all the updates... each month Data transfer costs beyond the free tier have historically been on par with S3 pricing, whereas storage costs have always been somewhat higher Consult the AWS website at https://aws amazon. com /simpledb/ for current pricing information Domains, Items, and Attribute Pairs The top level of data storage in SimpleDB is the domain .A domain is roughly analogous to a database table.You can create... calls to Memcached, email, XMPP, and URL fetching App Engine includes an API for data storage based on Google Big Table and in some ways is comparable to SimpleDB. Although Big Table is not directly accessible to App Engine applications, there is support in the data store API for a number of features not available in SimpleDB. These features include data relations, object mapping, transactions, and a. .. possible that AWS may increase performance of the service over time, based on user feedback But SimpleDB is never going to be as speedy as a standalone database running on fast hardware SimpleDB has a different purpose Robust database clusters replicating data across multiple data centers is not a data storage solution that is typically easy to throw together It is a time consuming and costly undertaking... your data differently In SimpleDB, there is no schema requirement Although you still have to consider the format of your data, this approach has the benefit of freeing you from the time it takes to manage schema modifications The lack of schema means that there are no data types; all data values are treated as variable length character data As a result, there is literally nothing extra to do if you want... database rejects updates during even simple problem scenarios, it defeats the availability In practice, replication is often not done this way A common solution to this problem is to allow only the master database to accept updates and do so without direct contact with any slave databases After the master commits each transaction, slaves are sent the update in near real-time.This amounts to a relaxing... want to add a new field to an existing database.You just add the new field to whichever data items require it.There is no rule that forces every data item to have the same fields The drawbacks of a schema-less database include the lack of automatic integrity checking in the database and an increased burden on the application to handle formatting and type conversions Detailed coverage of the impact of . 56 DomainMetadata Parameters 56 DomainMetadata Response Data 56 DomainMetadata Snippet in Java 57 DomainMetadata Snippet in C# 58 DomainMetadata Snippet in PHP 58 PutAttributes 59 PutAttributes Parameters. database usage simpler. SimpleDB aims to simplify the much harder task of creating and managing a database cluster that is fault-tolerant in the face of multiple failures, replicated across data centers,. software. In addition, the app developers are best served with a guide that uses a matching program- ming language and client. The official Amazon documentation for SimpleDB is targeted squarely at