John Doe
John Doe

Reputation: 111

What is the "proper" way to use DynamoDB for an iOS app?

I've just started messing around with AWS DynamoDB in my iOS app and I have a few questions.

Currently, I have my app communicating directly to my DynamoDB database. I've been reading around lately and people are saying this isn't the proper way to go about getting data from my database.

By this I mean is I just have a function in my code querying my Dynamo database and returning the result.

How I do it works but is there a better way I should be going about this?

Upvotes: 3

Views: 1077

Answers (2)

Vasily Sochinsky
Vasily Sochinsky

Reputation: 4011

From what you say, I can guess that you are talking about a way you can distribute data to many clients (ios apps).

There are few integration patterns (a very good book on this: Enterprise Integration Patterns), one of which is called shared database. It is essentially about using a common database for multiple clients to share the data. Main drawback for that pattern (in your case) is that you are doing assumption about how the database schema looks like. It can potentially bring you some headache supporting the schema in the future, if your business logic changes.

The more advanced approach would be sending events on every change in your data instead of directly writing changes to the database from client apps. This way you can add additional processing to the events before the data they carry is written to the database. For example, you may want to change the event format in the new version of your app, but still want to support legacy users, so you add translation procedure which transforms both types of events to the format which fits the database schema. It's basically a question of whether to work with diffs vs snapshots.

You should be aware of added complexity of working with events, and it can be an overkill if your app is simple and changes in schema are unlikely.

Also consider that you can do data preprocessing using DynamoDB Streams, which gives you some advantages of using events still keeping it simple to implement.

Upvotes: 0

Vikdor
Vikdor

Reputation: 24124

Amazon DynamoDB itself is a highly-scalable service and standing up another server in front of it requires scaling the service also in line with the RCU/WCU configured for your tables, which we can and should avoid.

If your mobile application doesn't need a backend server and you can perform all the business functions from the mobile device, then you should probably think about

  1. Using the AWS DynamoDB SDK for iOS devices to write your client application that runs on the mobile device
  2. Use AWS Token Vending Machine to authenticate your mobile users to grant them credentials to be used to run operations on DynamoDB tables.
  3. Control access (i.e what operations should be allowed on tables etc.,) using IAM policies.

HTH.

Upvotes: 2

Related Questions