Best practise on doing Cassandra Connection?

173 views
Skip to first unread message

Muhammad Sumyandityo Noor

unread,
Jan 13, 2014, 1:22:12 AM1/13/14
to clojure-...@googlegroups.com
Hello Folks,

I'm new in Clojure and Cassandra. I'm creating a very simple service discovery service to replace the old one written and utilizing REST using compojure, liberator, and cassaforte. This is my first project utilising Clojure.

My concern is in the connection within the app. What's the best practise for REST based service for connecting to Cassandra. I'd searching in google and still cannot get the definitive answer. Is it batter to have a default persistent connection used by all endpoints or use different connection each time request arrives in endpoint. My application traffic only comes for clusters within the datacenter.

Thanks,

Didiet.


Michael Klishin

unread,
Jan 13, 2014, 2:10:54 AM1/13/14
to clojure-...@googlegroups.com
2014/1/13 Muhammad Sumyandityo Noor <lynx...@gmail.com>

My concern is in the connection within the app. What's the best practise for REST based service for connecting to Cassandra. I'd searching in google and still cannot get the definitive answer. Is it batter to have a default persistent connection used by all endpoints or use different connection each time request arrives in endpoint

Anna Pawlicka

unread,
Feb 6, 2014, 5:52:25 AM2/6/14
to clojure-...@googlegroups.com
I'm wondering how client/connect works - I'd like to use it to create a session on application startup, and then have all mini services use that session to write/read. Does it use a connection pool that is later used by execute commands? Or would it create a new connection each time?

Thanks,
Anna

Alex P

unread,
Feb 6, 2014, 5:59:51 AM2/6/14
to clojure-...@googlegroups.com
A session holds connections to a Cassandra cluster, allowing it to be queried.

Each session maintains multiple connections to the cluster nodes,
provides policies to choose which node to use for each query (round-robin on
all nodes of the cluster by default), and handles retries for failed query (when
it makes sense), etc...

Session instances are thread-safe and usually a single instance is enough
per application. However, a given session can only be set to one keyspace
at a time, so one instance per keyspace is necessary.


There's also a connection pool per host. All queries are executed asynchronously
(underneath). There are also means in the driver itself to execute them in an
async manner. 

Anna Pawlicka

unread,
Feb 6, 2014, 6:10:12 AM2/6/14
to clojure-...@googlegroups.com
Super quick reply! Thanks, think clears things up.

Anna

Alex Petrov

unread,
Feb 6, 2014, 3:38:07 PM2/6/14
to clojure-...@googlegroups.com, Anna Pawlicka
np,
Thanks for using Cassaforte!
 
--
You received this message because you are subscribed to the Google Groups "Cassaforte, a Clojure client for Apache Cassandra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-cassan...@googlegroups.com.
To post to this group, send email to clojure-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clojure-cassandra/bd19de28-a180-4318-b9b3-96a6a63e3248%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages