-
Notifications
You must be signed in to change notification settings - Fork 112
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
Use non-blocking IO http-client library to send faster and reducce CPU usage #101
Comments
I'd be happy to integrate such improvements in this project (no need for a separate driver). How exactly is your setup (VertX + callback) different from the asynchronous HTTP client that is currently being used by the library? Can you share some code? |
Nonblocking IO is different from Nonblocking code. |
You can see benchmark here: |
yep. +1 as for now just use PushService.preparePost. it is public and create apache http async client on |
@martijndwars you can read more about non-blocking-io (as how nodejs work in one thread) |
My two cents, I believe the current implementation is non-blocking strictly speaking, if you use PushService#sendAsync, as it uses Apache HttpAsyncClient behind the scene (see their HttpCore tutorial). The main issue though in my opinion, is that callers can't wait and react on it without blocking, as it returns a good ol' Java5 Ideally, migrating the implementation to a more recent HTTP client that would return a AHC is a good candidate, here is a migration example: pusher/pusher-http-java#38. What do you think? Are you happy with me giving this a try if I find some free time? |
Thanks for the explanation @sp00m. A PR that makes these changes is much appreciated. |
Now #139 has been merged and released under https://github.com/web-push-libs/webpush-java/releases/tag/5.1.1, I believe this ticket can be closed. Example with Project Reactor: PushAsyncService pushService = new PushAsyncService(...);
Notification notification = new Notification(...);
Mono<Response> mono = Mono.fromFuture(() -> pushService.send(notification)); |
We have a project with a lot of notification must be delivered per hour.
So we're using VertX to send http request asynchronously and pass callback into sendAsync method. Now, we can X2 speed and reducce 1/2 CPU usage by using this library.
If you want to create another driver with asynchronous http request, let contact me to discuss more details
My email: tathuan96@gmail.com
The text was updated successfully, but these errors were encountered: