According to Datomic’s Connection documentation:
Datomic connections do not adhere to an acquire/use/release pattern. They are thread-safe, cached, and long lived. Many processes (e.g. application servers) will never call release.
I’m interested to know how this is achieved in practice, specifically for sql connections. From the client/user perspective this is great as you don’t need to worry about the thread pool at all which simplifies client code, and what you need to reason about signficantly. It’s something I’d love to replicate in other applications with SQL connections.
Breaking down the question into smaller parts:
- What challenges needed to be considered when treating Datomic connections as long lived?
- Is the approach suitable in general when dealing with JDBC connections, or is it only suitable for a sub class of problems (including Datomic’s)?
- I can see that Tomcat’s JDBC connection pool is used under the hood, how is this pooling used to achieve long lived connections from the Datomic connection perspective?
- In practice when do you use separate JDBC connections behind the scenes e.g. do you use separate connections for reads vs writes?