r/Clojure • • 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.

77 Upvotes

25 comments sorted by

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.

7

u/nathanmarz Oct 12 '23

Thanks for the feedback. We're still learning how to best teach Rama. It being a new paradigm with multiple layers of new concepts makes teaching it challenging.

I'd like to better understand what confused you. Was it specifically the <<sources code, whose body is a different programming paradigm than regular Clojure? Were you able to follow the conceptual overview up to that point?

9

u/lgstein Oct 12 '23

While I had some similar impressions and complaints when they launched, I found that it is possible to understand their paradigm and general idea after reading through the docs spending about 4 focus hours. "The paradigm" is compelling as an idea. Whether its a practical idea for real world development remains to be seen, but it surely is an exciting endeavor to find out. As an abstraction, it might be that it goes just one level too far - I'm somewhat skeptical how well migrations and changes of data shape will be maintainable with this model.
The as of now undefined license/pricing is of course a big blocker, so I'm happy to read a few docs and examples but wouldn't want to invest any commitment beyond an afternoon or two.

4

u/nathanmarz Oct 13 '23

We're up front about pricing with our private beta users. Our business model is a per-node license fee priced to capture a small percentage of the cost savings Rama provides.

1

u/aaronbaek Nov 23 '23

Hi, I've been intrigued by the examples and documentation provided by Rama and would like to know more details about the license/pricing.

For example, is the Rama framework open source and solutions created with the Rama framework available for a fee, or is it all Rama?

1

u/nathanmarz Nov 23 '23

The full version of Rama is only available currently by being part of our private beta, which you can apply to here. It's easy to get into the private beta if you've already prototyped something with the publicly available version.

The licensing model is a per-node license fee that captures a small percentage of the cost savings Rama provides. The specifics of this are one of the first things we discuss with private beta applicants.

Rama is not open-source, though we've open-sourced a number of things on top of it.

1

u/aaronbaek Nov 23 '23

I found that on blog and google group. thk

10

u/slifin Oct 12 '23

So far I think this is suitable for you if you want a single solution for your backend - what many people use a combination of databases and message queues for and you want that solution to be "reactive" all the way through

The other things you're getting built in are cluster management and monitoring though I've not really looked at those yet

So far I think the cognitive advantage is that you are using the same fundamental building blocks that Rama provides every time your system is just the same blocks for nearly every problem

The trade-offs I have seen so far are that you need to learn this new reactive language that I think will suffer the same problems as Specter, powerful once you know it, hard to onboard and teach

I think initially I will be learning how the language works by essentially copying examples and learning by rote rather than any deeper understanding

Bizarrely another reactive tech has emerged to perfectly complement Rama, Clojure Electric which can give you reactivity all the way to the browser from the server, people have already started putting these two together

I think the Clojure Electric team did something very clever in that they wrote a compiler that turns a superset of Clojure into a fully reactive Clojure, so you don't have to understand a huge amount of its reactive layer which so far has been easier to learn

To Rama team's credit, their documentation is exceptionally good and Clojure Electric Teams' documentation is notably bad though they are certainly not finished yet

5

u/slifin Oct 12 '23

I went back to Electric's docs after writing this comment to see if I was being unfair - it has improved since I last saw it: https://electric.hyperfiddle.net/

8

u/aaroniba Oct 12 '23

That's how I felt when Datomic was released. Eventually there were enough learning resources (blog posts, beginner guides, friends smarter than me) and enough motivating anecdotes from companies using it to great success, and I got up to speed. Now I use Datomic every day and would be really sad if I had to go back to a SQL database.

I'm still studying Rama in my spare time, working toward my PhD as you say. I have a hunch it's the real deal. It's more conceptually novel than Datomic was, but has correspondingly higher claimed payoff.

One thing I love about the clojure community is it's full of genius visionary early adopters who are much smarter than me. I am excited for those brave trailbrlazers to play with this new alien technology and report back to us humans their experiences!

3

u/[deleted] Oct 14 '23

Try it for an hour, build something very simple. You will see that although Rama is different, it's not that hard once you get the underlying concepts:

PStates are partitioned key-value stores with user-definable indexes, basically a value, key-value store, or a key-key-value store, or a key-key-key-value store, etc

The Path API takes some getting used to, think of it as jq on steroids.

Depots are event logs, basically the same thing as a Kafka topic.

A topology defines how to proces updates to a Depot, you can use the Path API to update or retrieve data in PStates.

1

u/mumbo1134 Oct 13 '23

this exact situation is one of the classic reasons that people historically avoided lisps. my impression is that rich hickey tried as hard as he could to design clojure to discourage people from creating unreadable DSLs, but if you go out of your way to make one, you will.

-1

u/Admirable-Ebb3655 Oct 12 '23

You’re probably not the target audience, with all due respect.

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's Log class 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.