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

[Question] - RxJava performance verses coroutines #21

Open
ndori opened this issue May 27, 2021 · 2 comments
Open

[Question] - RxJava performance verses coroutines #21

ndori opened this issue May 27, 2021 · 2 comments

Comments

@ndori
Copy link

ndori commented May 27, 2021

I've noticed that the fastest coroutine variant runs in a ~5.6 seconds
however, the RxJava variant runs in ~2 seconds,

If I understand correctly,
RxJava runs every request on a different thread and holds it while the coroutine uses a looper to schedule all of the io on the same thread, saving space.

I've tried achieving better performance on coroutines to be in par with RxJava but failed,

can you better explain that? it seems to me that the RxJava variant is much better because of that (for time optimization).

@xinxiong-tw
Copy link

same question

@xinxiong-tw
Copy link

I found out that it's because the OkHttp client has a default limit on maxRequestsPerHost which is 5, so it only sends 5 requests at the same time. And the RxJava variant seems no limit on this.
If you modify the maxRequestPerHost value to 1000 for example, the coroutine variant is as fast as the rxjava variant. @ndori

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

No branches or pull requests

2 participants