Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Slick 3.0 reactive/asynchronous at the database driver level? For which databases?

Slick has historically relied on JDBC drivers, which internally block waiting for socket I/O in response to queries. Every outstanding database call requires a thread to block on a socket; hence, it's not really reactive in the same sense as ReactiveMongo, postgresql-async and mysql-async, which are asynchronous all the way down.

Has anything changed in this regard in Slick 3.0? Or am I confused about any of this?

like image 413
Ed Staub Avatar asked Apr 13 '15 03:04

Ed Staub


People also ask

Is Slick asynchronous?

Slick is easy to use in asynchronous, non-blocking application designs, and supports building applications according to the Reactive Manifesto.

What is slick in Scala?

Slick is a Functional Relational Mapping library for Scala that allows us to query and access a database like other Scala collections. We can write database queries in Scala instead of SQL, thus providing typesafe queries.


1 Answers

It is not async down to the driver level, but that is not a problem. The number of blocking threads waiting for database connections is supposed to be small in a good setup. Thus they don't consume a lot of resources. Slick manages them and schedules blocking threads into their own thread pool, so they aren't in the way of computations. A "native" async driver would probably add a minor speedup, but not a major one. Slick may support that at some point in the future. The major benefit of "reactive" comes from what Slick already implements in 3.0. A more extensive explanation can be found here: https://www.parleys.com/tutorial/reactive-slick-database-programming

like image 88
cvogt Avatar answered Sep 18 '22 07:09

cvogt