r/Clojure • u/nathanmarz • Oct 12 '23
Announcing Clojure API for Rama: build end-to-end scalable backends in 100x less code
We've just released a first-class Clojure API for Rama. Rama is a new programming platform we released in August that enables end-to-end scalable backends to be built in their entirety in 100x less code than otherwise. It's a "programmable datastore on steroids" where you mold your datastore to fit your application rather than the other way around. The introductory blog post to the Clojure API culminates in building a highly scalable auction application with timed listings, bids, and notifications in only 100 LOC.
3
u/ewouldblock Oct 13 '23
I personally found the main documentation and the tutorial to be much more comprehensible than the blog post,
https://redplanetlabs.com/docs/~/index.html
While I'm not sure that I'm sold on it, I can acknowledge that it's interesting. I haven't fully completed the tutorial yet, but the types of things that come to mind are, is the data store ("Pstates") fully custom code or is it backed by some already proven tech similar to what Datomic did? Same question with regard to the ingest process which sounds like a message queuing technology?
Is this meant for building REST APIs or APIs generally, and if so is a PUT/POST endpoint simply going to use the ETL language/APIs? Does this solve for the fairly common search use case (e.g. query by fuzzy/match semantics like what Lucene does?
Based on what I've read so far it feels like a mash up of Clojure DSLs, document datastores like MongoDB (store the data in the shape you want to query), and the promise of automatic resiliency and distributed programming similar to what Erlang provides (promises?). I have no idea if that's a correct observation by the way, and I'm going to continue pressing through the documentation and tutorial.
3
u/nathanmarz Oct 13 '23
Map-oriented PStates use RocksDB under the hood, and value PStates (e.g. with a schema
Long) are in-memory values backed by a file. Depots use Kafka'sLogclass under the hood – this is just the log implementation without any of the networking, producer, consumer, or other stuff that's in Kafka.Your observation that with Rama you store data in the shape you want to query is correct, and this is key to Rama's expressiveness. PStates are considerably more expressive than MongoDB or any other database in this regard. Besides being able to be any combination of data structure of any size (nested structures can be bigger than memory, and top-level data structures are frequently not maps), you can also store your domain types directly in PStates. So just store your Clojure records directly, and you can query those records or parts of those records directly.
2
u/ewouldblock Oct 13 '23
oh damn, look who I'm talking to haha. Back in the day when I was first learning Clojure I was a huge fan of Cascalog. I also enjoyed your book "Big Data" which described the lambda architecture.
I'm not actively using Clojure but Im still a huge fan of the stuff that comes out of the community. I'm now very motivated to learn more about your work here. Thanks for the reply!
2
u/First-Agency4827 Oct 14 '23
Looking at Rama it seems it's purpose is decomplecting complex backends with many types of data storage and communication infrastructure ( event buses ). But to come to this conclusion, it is quite hard. So I remembered a guy explaining how to simplify a complex backend when your scalable needs aren't high or well defined by simply using postgres: https://youtu.be/hInTeB07xdc?si=d7m4IRqumtuC7AKs Maybe a similar video is needed, showing how you can reduce all the MySQL s, Redis-es, Postgreses, Mongos, Kafkas, ElasticSearches , Datadog s etc into a much simpler backend using Rama only ... Just an idea 🙂
3
u/nathanmarz Oct 14 '23
This is why we didn't just release Rama in the abstract, but also released a production-ready Twitter-scale Mastodon instance to demonstrate its power. That product contains a ton of features that work completely differently (e.g. timelines, social graph personalized follow suggestions, search, and many others) that traditionally require a many databases and specialized infrastructure to build at scale. With Rama we were able to do it all on the same platform.
3
u/First-Agency4827 Oct 14 '23
I think a picture before and after showing the massive reduction in complexity by using Rama from the twitter demo would be great. A small presentation or a 2 min video even better. Thinking that it'll open some discussions with decision makers easier
1
u/YabMas Oct 13 '23 edited Oct 13 '23
I've only scanned the available info so sorry if this is covered somewhere, but: It's not completely clear to me what applications this is most suitable/interesting for.
Mainly; does it make sense to look into this if you're writing applications that have moderate scaling needs? Would Rama still provide real benefit for these types of applications, with the added benefit of having a clear path/answer to whatever stage of scaling you are with your app?
4
u/nathanmarz Oct 13 '23
Since Rama reduces complexity so much, it improves development speed substantially even when scale isn't an issue. The more complex your infrastructure setup, the more of a cost difference there will be compared to the Rama implementation. It's extremely common for non-scalable apps to use multiple databases (e.g. Postgres + search database) and queues + workers for background work.
For example, our Twitter-scale Mastodon instance is more than 40% less code than Mastodon's official backend implementation. The official implementation is not scalable, and it's also written in Ruby (which is usually less code than Java).
2
u/YabMas Oct 13 '23
I just started looking into the documentation and saw my question is actually more or less addressed in the second paragraph of the introduction.. So sorry about that, but thanks for the reply.
Still wondering how/how much it would benefit us, but I guess that answers my question if it's worth looking into more :)
1
u/alexis_vincent Oct 14 '23
What is the general strategy for data migration? Does this involve reprocessing depot’s or is there a more lightweight variant?
1
u/nathanmarz Oct 14 '23
The current options are:
Recompute new PState from scratch from depot
Use Thrift or Protocol Buffers for values, which trivially supports migrations involving adding or removing fields
We also have a project in-progress to add first-class migration support to PStates on module update. The first version will be a lazy migration that migrates values on read, and we may also supplement that with a background task that slowly migrates the full PState in the background.
1
18
u/pwab Oct 12 '23
I’m just an ignorant internet person so what I’m about to say doesn’t matter and you shouldn’t care. I’ve worked in situations that i understand puts me in Rama’s target audience, so i thought i will give it a look…
To be honest, none of it makes any sense to me. I can’t see myself using it or even reading about it more because I don’t understand even the simple examples. It doesn’t grab me because I can’t relate to it. The code looks like clojure, but aside from that it is completely alien. I don’t understand the concepts and therefore can’t tell why or if this example is clever or not. The explanatory text of the blog post confuses me more.
It looks like I need a PhD in this technology before i will be able to write hello-world with it.
It might be great but I can’t tell.