-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Local schema cache weighted invalidation based on schema size #2598
Open
mattsewall-stripe
wants to merge
2
commits into
confluentinc:master
Choose a base branch
from
mattsewall-stripe:mattsewall/local-cache-optimizations
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+119
−8
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,6 +165,18 @@ public class SchemaRegistryConfig extends RestConfig { | |
public static final String COMPATIBILITY_CONFIG = "avro.compatibility.level"; | ||
public static final String SCHEMA_COMPATIBILITY_CONFIG = "schema.compatibility.level"; | ||
|
||
/** | ||
* <code>schema.cache.maximum.weight</code> | ||
*/ | ||
public static final String SCHEMA_CACHE_MAXIMUM_WEIGHT_CONFIG = "schema.cache.maximum.weight"; | ||
public static final int SCHEMA_CACHE_MAXIMUM_WEIGHT_DEFAULT = 1000000; | ||
|
||
/** | ||
* <code>schema.cache.use.weight</code> | ||
*/ | ||
public static final String SCHEMA_CACHE_USE_WEIGHT_CONFIG = "schema.cache.use.weight"; | ||
public static final boolean SCHEMA_CACHE_USE_WEIGHT_DEFAULT = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turned off by default but in my opinion likely could be turned on by default. |
||
|
||
/** | ||
* <code>schema.cache.size</code> | ||
*/ | ||
|
@@ -322,6 +334,10 @@ public class SchemaRegistryConfig extends RestConfig { | |
"The expiration in seconds for entries accessed in the cache."; | ||
protected static final String SCHEMA_CANONICALIZE_ON_CONSUME_DOC = | ||
"A list of schema types to canonicalize on consume, to be used if canonicalization changes."; | ||
protected static final String SCHEMA_CACHE_MAXIMUM_WEIGHT_DOC = | ||
"The maximum weight of the schema cache."; | ||
protected static final String SCHEMA_CACHE_USE_WEIGHT_DOC = | ||
"Whether to use weight or size based local schema cache."; | ||
protected static final String METADATA_ENCODER_SECRET_DOC = | ||
"The secret used to encrypt and decrypt encoder keysets. " | ||
+ "Use a random string with high entropy."; | ||
|
@@ -513,6 +529,14 @@ DEFAULT_KAFKASTORE_WRITE_MAX_RETRIES, atLeast(0), | |
.define(SCHEMA_CANONICALIZE_ON_CONSUME_CONFIG, ConfigDef.Type.LIST, "", | ||
ConfigDef.Importance.LOW, SCHEMA_CANONICALIZE_ON_CONSUME_DOC | ||
) | ||
.define(SCHEMA_CACHE_MAXIMUM_WEIGHT_CONFIG, | ||
ConfigDef.Type.INT, SCHEMA_CACHE_MAXIMUM_WEIGHT_DEFAULT, | ||
ConfigDef.Importance.LOW, SCHEMA_CACHE_MAXIMUM_WEIGHT_DOC | ||
) | ||
.define(SCHEMA_CACHE_USE_WEIGHT_CONFIG, | ||
ConfigDef.Type.BOOLEAN, SCHEMA_CACHE_USE_WEIGHT_DEFAULT, | ||
ConfigDef.Importance.LOW, SCHEMA_CACHE_USE_WEIGHT_DOC | ||
) | ||
.define(METADATA_ENCODER_SECRET_CONFIG, ConfigDef.Type.PASSWORD, null, | ||
ConfigDef.Importance.HIGH, METADATA_ENCODER_SECRET_DOC | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sum of canonical schema length must be under 1,000,000 characters is what this variable means. From the guava cache docs there's a lot of fuzziness as to how things get invalidated within the cache itself (based on usage and % of contribution to weight total?) but we've set this limit such that large schemas should be getting invalidated over time. What this essentially means is that more smaller schemas will be cached (and that's good!) as we should be able to cache quite a few of them. No significant performance degradation has materialized from making this change.