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: evaluate the user in the go sdk to improve response latency #921

Open
6 of 7 tasks
cre8ivejp opened this issue Apr 15, 2024 · 0 comments
Open
6 of 7 tasks

feat: evaluate the user in the go sdk to improve response latency #921

cre8ivejp opened this issue Apr 15, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request sdk server

Comments

@cre8ivejp
Copy link
Member

cre8ivejp commented Apr 15, 2024

Summary

The current architecture when the get variation interface is called. It requests the evaluation directly from the server.
This approach is more straightforward but may introduce latency. Also, this could lead to infra-cost issues because it could evaluate the same user many times in a short time, even if the flag didn't change.

We should consider implementing the evaluation logic in the SDK to implement a cache similar to the client SDK.
This would improve the latency issues and drastically reduce the requests to the server, reducing the infra-cost.

I was thinking of creating a new common repository for the evaluation and proto files, but it would be better if we kept this as a mono repo for this case. We can move it to another repository in the future if needed.

TODO

  • Create the proto dir as a go module
  • Move the evaluation code to a go module
  • Implement evaluation module in the API Gateway
  • Implement server-side API key type (Backend & Frontend)
  • Implement API to get all flags and segment users per environment using the server-side API key
  • Implement cache in the Go SDK (In-memory)
  • Implement the configuration to select to evaluate locally or remotely

API Gateway

It will evaluate the user from the evaluation module. There are no changes in the evaluation code.

API Key

We will implement a new key type, which will have access to all the flags and segment users per environment.
I will add a new column called key_type in the api_key table to check what the key can retrieve.

  • Server-side: Access to All flags and segment users per environment (Read-only)
  • Client-side: Access to a single user's evaluation (Read-only)

SDK cache

The cacher will cache all the flags and segment users per environment in memory.
It will poll the latest data from the Bucketeer server and override the current in-memory data every 30 seconds.
This implementation will be similar to the other client SDKs.

SDK get variation interface

We won't change the current interfaces. The changes will be made internally to evaluate the user in the SDK, just like the Bucketeer app does on the server side.

@cre8ivejp cre8ivejp added enhancement New feature or request server sdk labels Apr 15, 2024
@cre8ivejp cre8ivejp self-assigned this Apr 15, 2024
@cre8ivejp cre8ivejp changed the title feat: evaluate the user in the sdk instead of the backend feat: evaluate the user in the go sdk to improve response latency Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request sdk server
Projects
Status: In Progress
Development

No branches or pull requests

1 participant