Вопрос

I'm familiar with developing desktop apps in Clojure (written a multithreaded interactive visualization system). However, I'm fairly new to Web development using Clojure.

I plan to use Clojure on the server for handling logic; and ClojureScript for handing client side work. However, I don't know what to use for my database server. Should I use something like Monogodb? or Hadoop? Or .... ?

The app is something very simple; a basic forum. Total number of concurrent users will be < 100 at a given time. One thing that is important to me is the ability to easily backup / data consistency -- it's very very important to me that I can easily make daily backups (and not lose all the data.)

Thanks!

Это было полезно?

Решение

You can use many databases; if the database has an API for Java, you should be good to go. MySQL, MongoDB, Postgres, Hadoop… and more.

For a nice overview of the webstack in Clojure, check out brehaut's article on the matter.

For getting up and running quickly with Clojure and ClojureScript, try ClojureScriptOne.

There are many ways to write what you want to write; if you're already familiar with Clojure, it shouldn't be too hard to get going.

Другие советы

Haven't used it myself, but Datomic ( http://datomic.com/ ) looks great for anyone coming from Clojure.

Datomic is an amazing database, and I'd highly recommend it. It has many features which set it apart from other database systems:

  • Like Clojure's data structures, it's persistent, meaning that by default, adding new facts to the database doesn't delete old facts, allowing you to query the state of the database at a previous point in time, enhancing audit-ability and assistance in debugging.
  • The underlying Entity Attribute Value (EAV/triple) data model (at least partly inspired by RDF & the Semantic Web), is extremely flexible, allowing you to express arbitrary graph structures and effortlessly deal with polymorphism.
  • The query language is flavor of Datalog, a sort of pattern matching based query language strictly more expressive than SQL and the like in that it can do recursive queries, making it particularly well suited for dealing with graph data/queries.
  • In addition to Datalog queries, there's a pull api, which let's you pull data out of the database more simply using a GraphQL like expression which specifies the shape of a document-like structure you'd like to pull out of the database. These queries can even be used from within the :find clause of a Datalog query.
  • You can use Clojure functions from within your queries.
  • The indexing system is very smart and more or less automatic, in stark contrast with the work that typically goes into tuning SQL databases for performance.
  • Transactions go through a different API/function call than queries, meaning that the number one security risk identified by OWASP (SQL injection) is literally impossible in Datomic.
  • The transactor/read-replica design makes it super easy to scale reads/queries, while keeping pressure off the transactor.
  • It's fun as hell.

One of the things worth pointing out here is that by embracing the EAV data model and datalog/pull queries, Datomic ends up having structural flexibility closer to that of a NoSQL database, while still being fundamentally relational, and even more expressive in it's relational queries than SQL.

It's amazing and you should absolutely give it a shot. It will melt your brain a little. In the good way.

It's also worth noting that it's popularity has inspired a number of successful open source projects, so the underlying approach is not going anywhere any time soon:

  • DataScript: In memory clj/cljs partial implementation
  • Datahike: Fork of DataScript which queries over on disk indices, meaning you don't have to keep everything in memory to query
  • Mentat: Mozilla project trying to make a Datomic-alike for a Mozilla project
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top