Skip to content

[improve] Prefetch role tokens in the background in the Athenz auth plugin - #1355

Merged
nodece merged 1 commit into
apache:masterfrom
massakam:prefetch-role-token
Apr 23, 2025
Merged

nodece merged 1 commit into
apache:masterfrom
massakam:prefetch-role-token

Conversation

@massakam

@massakam massakam commented Apr 16, 2025 •

Copy link
Copy Markdown
Contributor

Motivation

We use Athenz for authentication between clients and brokers.

When a broker is restarted or a topic is unloaded, connected Pulsar Go clients can send a large number of requests to the Athenz ZTS server at the same time, causing the ZTS server to become overloaded.

The Athenz library used by the authentication plugin caches obtained role tokens for at least two hours to reduce requests to ZTS. However, this cache is only updated when a reconnection occurs between the client and the brokerand is never updated in the background. Therefore, if a broker that has a large number of clients connected for a long time is shut down, all of those clients will simultaneously send requests to ZTS to refresh their role token caches, which have already expired.

Modifications

Newer versions of the Athenz library support the feature to periodically fetch role tokens in the background, so I will upgrade the Athenz library and enable this feature.
AthenZ/athenz#2892

This way, each client's cache is constantly refreshed and does not expire, avoiding a flood of requests to ZTS in response to broker restarting or topic unloading.

Verifying this change

  • Make sure that the change passes the CI checks.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): yes
  • The public API: no
  • The schema: no
  • The default values of configurations: no
  • The wire protocol: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

@nodece
nodece merged commit 6080a62 into apache:master Apr 23, 2025
@massakam
massakam deleted the prefetch-role-token branch April 24, 2025 02:01
@massakam massakam added this to the v0.16.0 milestone Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants