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

[ENHANCEMENT] Make the Apisix plugin reactive #1412

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

chibenwa
Copy link
Member

@chibenwa chibenwa commented Dec 16, 2024

Please:

  • Test this first on a real Apisix
  • Regular JMAP performance tests before / after
  • Conduct performance tests without Redis

CF #1247

@vttranlina @hungphan227 please cary over this work from now on

@@ -29,25 +31,32 @@ public String name() {
@Override
public void filter(HttpRequest request, HttpResponse response, PluginFilterChain chain) {
logger.debug("Received a new request");
sidFilter(request, response);
chain.filter(request, response);
sidFilter(request, response)
Copy link
Member

Choose a reason for hiding this comment

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

It's possible that chain.filter(request, response) will be called AFTER (bad case) or BEFORE (perfect case) the "PluginFilterChain" had completed

+1 🍺 if it works

Copy link
Member Author

Choose a reason for hiding this comment

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

It's callback based, it is fine!
That's Netty under the hood it feels like home.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's callback based, it is fine! That's Netty under the hood it feels like home.

Could you refer to any document that prove this "callback"? I agree with Tung. Code we put in reactor could be executed after response is sent to client.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are tiring me, so deeply, some days.

Copy link
Member Author

@chibenwa chibenwa Dec 17, 2024

Choose a reason for hiding this comment

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

Because implementing a callback interface:

-> it's clear that though asynchronous the callbacks are still executed in order
-> And sending the response to the client would trivially be implemented in the very last filter.

Copy link
Member Author

Choose a reason for hiding this comment

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

apache/apisix-java-plugin-runner#313

Please qualify the new plugin with the new plugin runner ;-)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah with the updated plugin runner, the reactive code works well.

I have tested case token revoked --> pass
I have conducted performance test like this #1247 (comment) --> The result is good. The latency is always around 5s (I set timeout to 5s).

Regarding updating the plugin runner, I wonder if there is anyone reviewing and approving the PR. In case the repository is no longer maintained, I suggest we fork, create our own repository for the plugin runner (as well as CI/CD)

Copy link
Member Author

@chibenwa chibenwa Dec 20, 2024

Choose a reason for hiding this comment

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

Regarding updating the plugin runner, I wonder if there is anyone reviewing and approving the PR.

It is Christmass time.

Be patient.

We can package, build and deploy the PR for the time being.

Can we do a JMAP perf test on top of this change?
Can we publish the updated Apisix docker image with both changes to the runner and to the plugin?

I have conducted performance test like this #1247 (comment) --> The result is good. The latency is always around 5s (I set timeout to 5s).

(I told you: let's patch the causes and not the consequences)

Copy link
Contributor

Choose a reason for hiding this comment

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

Apisix docker image: hungphan227/apisix:3.9.1-debian-javaplugin

Copy link
Contributor

Choose a reason for hiding this comment

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

It is complicated to update staging env to run jmap perf test with apisix. Therefore, I will update james-gatling and run it locally with tmail-backend memory version.

@@ -39,7 +39,7 @@ public class AppConfiguration {
@Value("${redis.password}")
private String redisPassword;

@Value("${redis.timeout:5000}")
@Value("${redis.timeout:500}")
Copy link
Member

Choose a reason for hiding this comment

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

+1 for this

@hungphan227
Copy link
Contributor

Performance test result with 2 min inject, 8 min scenario, 1000 users, tmail memory (due to an unknown issue, I have to remove some JMAP requests in the test):

  • Regular JMAP performance tests before new plugin:
    Screenshot from 2025-01-02 18-08-53

  • JMAP performance tests without redis before new plugin:
    Screenshot from 2025-01-02 22-36-07

  • Regular JMAP performance tests with new plugin:
    Screenshot from 2025-01-02 20-24-27

  • JMAP performance tests without redis with new plugin:
    Screenshot from 2025-01-02 21-28-54

@chibenwa
Copy link
Member Author

chibenwa commented Jan 2, 2025

Ok thanks a lot @hungphan227 !

This proves:

  • 1/ Small gains on regular operations (5% mean time AND 7.6 % P99)
  • 2/ Massive gains in term of ourage (x15 mean time AND x50 P99)

Which image did you use to run those tests?

Copy link
Member

@Arsnael Arsnael left a comment

Choose a reason for hiding this comment

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

LGTM. is this still a draft? or can we switch it to ready for review?

@hungphan227
Copy link
Contributor

hungphan227 commented Jan 3, 2025

Which image did you use to run those tests?

Apisix docker image with new plugin: hungphan227/apisix:3.9.1-debian-javaplugin

@chibenwa
Copy link
Member Author

chibenwa commented Jan 3, 2025

LGTM. is this still a draft? or can we switch it to ready for review?

Build is not necessarily straight forward as it requires building the java plugin yourself.

Maybe keep this as a draft until upstream is released?

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.

5 participants