Amazon DynamoDB比Amazon RDS(php)慢吗? [关闭]

We use a bunch of AWS services hosted in the Singapore region. We have a few EC2 instances and an RDS instance. We were planning to migrate some of our data to Amazon DynamoDB, which will help in our application data design.

Unfortunately, DynamoDB is always slower than RDS. I have written a single row in a table created in the same region as our EC2 instances. Reading this row takes more than 1 second using the AmazonAWS SDK for php, and fetching a row from RDS using mysql takes more than 10 times lesser than that.

Is there something we can do to optimize this? I have disabled SSL, but I don't think it made much of a difference.

Possibly. DynamoDB has considerable latency and runs on top of a thicker application stack than does a RDS hosted database (MySQL, SQL Server, Oracle).

However, IMO the key advantage of DynamoDB (and most NoSQL dbs) is that the latency is dependable. If you are seeing a 400 ms latency on record retrieval, you can count on that 400 ms latency with 1 session or with 100,000 sessions.

[Note: 1 second does seem like a long time - we able to get multiple records < second in most instances, but I've not really used the DynamoDB method for the PHP specific SDK (just .Net). I wonder if something else could be bottle-necking.]

Looking at your previous comment I'd say that scan is your problem. You really only want to be using that when absolutely essential, i.e. to feed data into map reduce for analytics or something along those lines. As far as I'm aware, scan actually goes through every single record and looks for items matching your criteria (sloooowwwww), where as get/query works off the nicely indexed hash/range keys.

If possible you should be structuring your data so that you can query off of the hash/range key, If that's not feasible you could look at putting your meta data / query fields into cloudsearch, using that to return the id then directly getting the item from Dynamo. You could also set up some denomalized tables (restructuring the same data in different tables so you have different range keys)

You shouldn't see those large latency times with get and query commands using the PHP SDK.

If you are using DynamoDB with the AWS SDK for PHP, you should make sure stay up-to-date with which version of the SDK you are using. Specifically, you need to be using version 1.5.9+ in order to get the best performance for DynamoDB operations. There were some issues resolved recently that were adding extra latency to some requests, so this may help you out a lot.

Also, DynamoDB recently add support for AWS SignatureV4 for signing requests, which removes the need for STS credentials which the SDK previously retrieved and cached for you. This should also contribute to better performance as well.