https://kotlinlang.org logo
#exposed
Title
# exposed
a

Amejonah 1200

07/11/2023, 7:58 PM
Is there support for r2dbc-postgresql or jasync-sq in exposed? is it planned?
d

Damien O'Hara

07/16/2023, 10:03 AM
To my knowledge there is a notion of doing this but no concrete roadmap. It's worth noting that asynchronous IO is not associated with better performance for database workloads the same way it is for HTTP workloads, which is why there is less urgency in the ecosystem for moving to async drivers
a

Amejonah 1200

07/16/2023, 1:01 PM
is not associated with better performance for database workloads the same way it is for HTTP workloads
But it is IO as HTTP, no? The client spends time on waiting for a response, not really the mapping of the resultset.
d

Damien O'Hara

07/16/2023, 1:08 PM
You'll spend that time waiting either way. The main advantage to async is concurrency, but DB workloads optimize throughput and latency at lower concurrency due to the expense of concurrent transaction handling. this is why connection pools advocate lower max connection counts
a

Amejonah 1200

07/16/2023, 1:09 PM
You'll spend that time waiting either way.
No, you can accept in the meantime new incoming HTTP requests, if you are building a web server.
d

Damien O'Hara

07/16/2023, 1:11 PM
You can already do that. You don't need async DB driver in order to use an async webserver
a

Amejonah 1200

07/16/2023, 1:12 PM
But then, you create a platform thread for each new connection to the db
d

Damien O'Hara

07/16/2023, 1:12 PM
BTW, it's worth noting that client side waits for DB connections to become available from the pool can be made async without using an async DB driver. You just need to dispatch to a limited thread pool
That's fine. You'll only need double digit threads for your DB connections
a

Amejonah 1200

07/16/2023, 1:12 PM
you could technically lower them using a async db driver
d

Damien O'Hara

07/16/2023, 1:13 PM
But why would you? The overhead is minuscule
By comparison, HTTP servers need to handle thousands or tens of thousands of concurrent connections. That's why async is so important and standard for HTTP
a

Amejonah 1200

07/16/2023, 1:15 PM
But why would you?
spending time to do web server stuff instead of waiting for a response of the DB ¯\_(ツ)_/¯
d

Damien O'Hara

07/16/2023, 1:16 PM
Your web server isn't blocked by waiting on the DB. If you are using dispatchers correctly, your JDBC operations are not blocking the web server threads
a

Amejonah 1200

07/16/2023, 1:21 PM
So, because the connection to the DB is limited anyway(and Loom availability soon™️), there is no real gain by having async?
d

Damien O'Hara

07/16/2023, 1:22 PM
That's right. You don't have anything to worry about, as long as you are dispatching to Dispatchers.IO or a dedicated DB thread pool Dispatcher
a

Amejonah 1200

07/16/2023, 1:23 PM
Ok, good. Thank you.
74 Views