Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Design doc] For deciding the final indexes on the table. #31

Open
vikhyat187 opened this issue May 12, 2023 · 5 comments
Open

[Design doc] For deciding the final indexes on the table. #31

vikhyat187 opened this issue May 12, 2023 · 5 comments
Assignees

Comments

@vikhyat187
Copy link
Contributor

vikhyat187 commented May 12, 2023

[Note] This document is to decide the final Indexes on the feature flag and Feature flag User mapping table.

Feature Flag table.

  • Id --- string -> generated in system by UUID package
  • Name --- string
  • Description --- string
  • Status --- string
  • CreatedAt --- number
  • CreatedBy. --- string
  • UpdatedAt --- number
  • UpdatedBy --- string
    The number is dynamodb datatype for Go we are using int64

I'm thinking to have Id as the Partition key., as its auto generated and it will avoid Hot Partition problem

The sort key can be CreatedAt, we can order the rows using created time. (Optional as Partition key will be unique)

We can have an GSI on the Name attribute.

Initially I thought to get the Id generated by the user, in that case we need to have checks on its uniqueness and it can lead to Hot Partition problem.

FeatureFlag-User mapping table

  • FlagId --- string-> system generated
  • UserId --- string
  • UpdatedAt --- number
  • UpdatedBy --- string
  • CreatedAt --- number
  • CreatedBy --- string
  • Status --- string

Here the flag Id and User Id combination can form the partition key, as User can have multiple feature flags.

We can have GSI on User Id, to fetch all the feature flags for the User.

Links:
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-partition-key-design.html
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html

@prakashchoudhary07
Copy link
Contributor

Where are we going to use status from feature flag table?

And in featureflag-user mapping
FlagId is foreign key reference from feature flag table right?

@RitikJaiswal75
Copy link

The sort key can be created, we can order the rows using created time. (Optional as Partition key will be unique)

How sure are we that it will always be unique since it will be running over the web I think there might be chances when 2 users create a feature flag at the same time.

@vikhyat187
Copy link
Contributor Author

vikhyat187 commented May 13, 2023

Where are we going to use status from feature flag table?

And in featureflag-user mapping
FlagId is foreign key reference from feature flag table right?

We can use feature flag status to switch off a flag in case of features breaking on production, we can check this before checking feature for user, if the feature is enabled or not
Yes it's the same flagid in mapping table @prakashchoudhary07

@vikhyat187
Copy link
Contributor Author

vikhyat187 commented May 13, 2023

The sort key can be created, we can order the rows using created time. (Optional as Partition key will be unique)

How sure are we that it will always be unique since it will be running over the web I think there might be chances when 2 users create a feature flag at the same time.

The sort key need not be unique, the partition key which is flagId (generated by uuid package) is going to be unique in Feature Flag table, we can have the sort key (optional) to get the data in ordered fashion. @RitikJaiswal75

@gauravv-dev
Copy link

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants