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

feat: move experiment calculator to batch service #1160

Merged
merged 7 commits into from
Aug 6, 2024

Conversation

Ubisoft-potato
Copy link
Collaborator

@Ubisoft-potato Ubisoft-potato commented Jul 25, 2024

This PR will move experiment calculator to batch service.

Key Changes

  • Add distributed lock which backend by Redis. [1] [2]
  • Update experiment calculate job to run calculator directly rather than call calculator service. [1]
  • Remove experiment calculator service and manifests.
  • Add http stan container to batch service. [1]

This pull request includes several changes that focus on removing the experiment-calculator component and adding a new httpstan service. The most important changes include the removal of the main experimentcalculator.go file, updates to the Helm charts, and modifications to the dependencies in the go.mod file.

Removal of experiment-calculator component:

Addition of httpstan service:

Dependency updates:

  • go.mod: Added github.com/google/uuid v1.6.0 to the dependencies and removed it from the indirect dependencies. [1] [2]

@Ubisoft-potato Ubisoft-potato marked this pull request as ready for review July 25, 2024 05:35
@Ubisoft-potato Ubisoft-potato force-pushed the feat-move-experiment-calculator branch from 94f091f to 246bab6 Compare August 5, 2024 10:58

const (
experimentLockPrefix = "experiment-calculate:"
experimentLockTTL = time.Minute
Copy link
Member

@cre8ivejp cre8ivejp Aug 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on the number of events, it could take more than 1 minute to finish analyzing the data.
It will be safer if we set the default value to 10 minutes.
Also, can you make this configurable? It will be nice to pass the config via values.yaml.

)

const (
experimentLockPrefix = "experiment-calculate:"
Copy link
Member

@cre8ivejp cre8ivejp Aug 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
experimentLockPrefix = "experiment-calculate:"
experimentLockKind = "experiment_lock"

}

// getLockKey generates the lock key for a specific experiment
func (el *ExperimentLock) getLockKey(environmentID, experimentID string) string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func (el *ExperimentLock) getLockKey(environmentID, experimentID string) string {
func (el *ExperimentLock) newLockKey(environmentID, experimentID string) string {


// getLockKey generates the lock key for a specific experiment
func (el *ExperimentLock) getLockKey(environmentID, experimentID string) string {
return fmt.Sprintf("%s%s:%s", experimentLockPrefix, environmentID, experimentID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Sprintf("%s%s:%s", experimentLockPrefix, environmentID, experimentID)
return fmt.Sprintf("%s:%s:%s", environmentID, experimentLockKind, experimentID)

return el.lock.Unlock(ctx, lockKey, value)
}

// getLockKey generates the lock key for a specific experiment
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// getLockKey generates the lock key for a specific experiment
// newLockKey generates the lock key for a specific experiment

@cre8ivejp cre8ivejp force-pushed the feat-move-experiment-calculator branch from 454c510 to 741f24e Compare August 6, 2024 04:51
Copy link
Member

@cre8ivejp cre8ivejp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@cre8ivejp cre8ivejp merged commit 238b390 into main Aug 6, 2024
22 checks passed
@cre8ivejp cre8ivejp deleted the feat-move-experiment-calculator branch August 6, 2024 05:24
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

Successfully merging this pull request may close these issues.

2 participants