I am looking for the best way of implementing a Multitenant App in AWS. Imagine I am an eCommerce business that has several eCommerce clients and those clients have other clients that are the ones that buy articles.

The easiest multitenant solution would be to have a single database with shared tables such as Articles where there ir a tenantID column to identify the different clients.

However, in case one of my clients remove some articles accidentally and want to restore to an earlier point of time, it would be a hard process because its data is not in a separate database.

I have tried implementing the solution of one Database instance and multiple databases within it in Amazon RDS but it turns out it does not allow me to restore databases withing the DB instance, it only allows to restore the whole db instance.

What would you recommend me to do? Is there another way in AWS or is it better to have an own dedicated server in this case with separated databases?

  • If you agree that restoring to an earlier point in time is something that should remain exceptional, could decline doing it, or doing so in terms of services (delay, possibly price) that make it acceptable for you to extract the data from the whole backup by script ? In my experience working with multi-tenant apps these requests are rare enough you don't need to architecture specifically for that, as long as you have the data somewhere. – Arthur Hv Sep 20 '19 at 20:51
  • 1
    Have you considered application-level solutions to the problem? For example, in the case of a client mistakenly removing articles, implementing a "trash can" where "deleted" records are held for a while before being purged or even a soft delete where no records are actually removed from the database. For accidental updates, an audit log could be useful to understand the original values as well as who changed them and even why. You would shift the burden from maintaining the operational database to application development that would benefit all of the clients. – Thomas Owens Feb 18 '20 at 11:17

Database backups and restores are not designed to be an undo button for users. So its always going to be a hard process if you use them to provide that functionality

For example, say your user accidentally deletes an article, but after that correctly adds some more articles. To restore the deleted article while retaining the new ones is going to be a manual task for you.

Instead, implement undo functionality in your code. Have the delete button simply flag the article as deleted rather than actually deleting it. Then you can add an undelete button which removes the flag.

  • Thanks Ewan! I will use the deleted flag. And would you recommend me to have all the users in the same database or in different db schemas on the same db instance (Amazon RDS)? I am afraid if articles of different clients are in the same table (first approach), the speed when the db becomes large will decrease. – Angel Luis Sep 24 '19 at 7:52
  • there are quite a few questions which address that question, its more of a data jurisdiction issue though – Ewan Sep 24 '19 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.