Using DynamoDB for logging user activity

I am developing a freelancing platform for certain professionals. I was thinking of utilizing the AWS DynamoDB for logging user activity (like posting a job, editing a job etc).

Fields would be

user_id | ip_address | timestamp | data

I would be querying DynamoDB for the following information:

  1. Log of certain user's activity.
  2. Log of all the user activity performed on a certain day.

And the information will have to be saved and accessible for a long time (forever?).

How good would DynamoDB be, for this kind of use case?


Solution 1:

DynamoDB is meant for high-performance retrieval. It internally uses SSD drive so that the storage price of DynamoDB might be a bit expensive for a "forever" data storage when coming to high volumes.

This said, your use case appears to fit perfectly DynamoDB. If you only need what you said, I would recommend this schema:

  • hash_key = <user_id>:YYYY-MM-DD
  • range_key = full_ISO_8601_timestamp
  • ip_address
  • data

ISO_8601 is always a good idea if you need to sort the dates.

I suggest to append the date to the user_id to make queries easier and keep things logically grouped but it will complexify more advanced queries. This may be avoided by using BETWEEN filter of ```Query`