alaisi / postgres-async-driver

Asynchronous PostgreSQL Java driver
Apache License 2.0
287 stars 38 forks source link

Low Throughput #46

Open libliflin opened 7 years ago

libliflin commented 7 years ago

Hi,

I'm not sure if this is the right spot for this question. I was hoping for some sort of slack channel or gitter or something.

I created a benchmark because I thought this might cause a speed up, but to my surprise I couldn't get much performance boost. To be fair: I'm completely new to observables and undertow and postgres 😄 .

Is there any supporting evidence that this is actually faster than jdbc? or is it a per use case kind of thing?

My code is at async-postgres-benchmark and specifically QueriesAsyncPostgresqlGetHandler.

Thanks!

nilskp commented 6 years ago

There's a common misconception that async (non-blocking really) is "faster", when in reality, you'll often see slightly increased latency. Non-blocking behavior increases the amount of load an application can handle, which means it will perform better under load than the equivalent blocking program.

gmokki commented 6 years ago

I benchmarked this project before and after RxJava1 was introduced. Before it was just simple callback. The RxJava1 overhead slowed down a simple select 1 operation by 30%. Hopefully update to RxJava2 would give some of that lost performance back.

Also the official postgres jdbc driver has lots of optimizations that are not ported to this driver, most notably the support for binary encoding of values.

nilskp commented 6 years ago

IMO, it would be preferable to get rid of the RxJava dependency altogether.

EDIT: which seems to be the plan: https://github.com/alaisi/postgres-async-driver/issues/47#issuecomment-317825123

libliflin commented 6 years ago

Hi @nilskp and @gmokki

I'm not sure how my benchmark is measuring latency. I thought I understood that with async you trade off some latency for increased peak throughput. Please correct if this is false.

My question/comment was on why every measurement I tried is worse compared to the serial option. It's hard to find what exactly is gained with this project.