266 points · by ifcologne · 6y ago · 154 comments
While it's missing some popularity from MongoDB and having wide adoption of things like mongoose in lots of open source CMS-type projects, it wins for the (i believe) unique take on map / reduce and writing custom javascript view functions that run on every document, letting you really customize the way you can query slice and access parts of your data...
Example: I'm building a document analysis app that does topic + keyword frequency vectorization of a corpus of documents, only a few thousand for now.
I end up with a bunch of documents that have "text": "here is my document text..." and "vector": [ array of floating point values ...].
What I can do with couchdb is store that 20d vector and emit integers of it as a query key:
var intVectors = doc.vector.map(function(val){
return Math.floor(val)
})
emit(intVectors, 1);
Then I can match an input document's vector (calculated the same as corpus documents), calculate a 'range' of those vectors, pass it as start and end keys, and super quickly get a result from the database of 'here are documents that have vectors similar to your input'...Super fun, quick and flexible to work with!
I really like CouchDB. It is wonderful if you want that kind of DB. However, if you want a relational DB (and there are many, many, many reasons to want one), do not pick CouchDB. It works very poorly as a relational DB.
I have a legacy project that didn't quite understand this point and we have ended up paying the price for a document oriented DB in which it is hard to migrate and where we are constantly having to worry about the bandwidth to the view server. And then all the amazing, wonderful features of couch? We don't use a single one :-P Fail all the way around. However, I still like it and instead of retiring it, I've been slowly trying to start using the features that make it awesome, while mitigating some of the problems that have piled up over the years.
The problem I had with CouchDB is integrating it into a framework like Rails. CouchDB on its own does so much cool stuff. The "free" HTTP API and client replication via PouchDB are the two huge ones. But it just wasn't smooth enough to get the data out, use it where I wanted, and then save it back.
But after that, it was very nice.
Firebase is the gold-standard for offline apps (as a service). CouchDB replaces Cloud Firestore, and Keycloak replaces Authentication. I haven't seen OSS equivalents of Cloud Functions, ML Kit, and the other things (e.g. In-App messaging, and Cloud Messaging). It'd be nice to have the entire stack of Firebase bundled as a group of OSS projects, including CouchDB.
Sad to see that per doc access control didn't make it in 3.0. Hopefully it'll be in 3.1.
(1) https://www.ibm.com/cloud/blog/announcements/announcing-supp... (2)https://github.com/apache/openwhisk/blob/master/tools/db/REA...
We have dedicated clusters on Cloudant and they’ve run quite smoothly for many years. Someday we might switch to the on-demand IBM Cloud pricing, but haven’t done it yet.
So shameless plug if you're interested in signing up for the alpha: https://www.aspen.cloud
Every now and again I wonder if I could implement the CouchDB Replication Protocol on top of Cosmos DB with a presumably hairy ball of Azure Functions and hoping someone beats me to needing that to exist and scratches that itch for me. (Cosmos DB's changes feed is so almost right for the job it hurts because it sounds like it should be easy, and yet I assume it won't be.)
All databases are represented by a host and a port. I think you mean CouchDB offers a HTTP-based API that allows queries to be run without requiring a database-specific library and that because it's HTTP, it can be accessed via a browser.
[1] In this case, a JSON document but either with a JSON-schema or marshaled/unmarshaled into a strict type.
Thanks!
PL/SQL also allowed (and allows) you to create entire apps within a database.
I used it years ago when I was experimenting with Ionic[0]. What appealed to me was that I could use CouchDB (cloud) and PouchDB[1] (device) to and have a replicated copy of the data locally. The application was used in areas where network connection was very limited. Using this strategy I was able to ensure the mobile devices data was as recent as the last time it had a network connection.
[0] - https://ionicframework.com/
[1] - https://pouchdb.com/
For user authentication I've forked the nowadays unmaintained superlogin package [1], which still does a great job when keeping the dependencies up to date.
For those interested, looks like the guts of CouchDB are going to be swapped out for FoundationDB.
https://blog.couchdb.org/2020/02/26/the-road-to-couchdb-3-0-...
Updates on huge docs would be painful!
The IBM Cloudant free tier only allows Doxs up to 1 MB.
So this doesn't really come as a surprise or feel hyper restrive to me.
Yes ^^ !
Congrats to the team. These people are some of the nicest and most supportive devs I know of in the OSS community (or whatev').
They show a great deal of patience in their slack channel and are always welcoming and answering stupid questions from idiots like me.
Seriously asking...
Over the past 5 years MongoDB has gotten a great storage engine, transactions, distributed transactions, multi master replication, first class change streams and is very very solid as a foundational piece of infrastructure you can rely on while CouchDB has languished. I can’t imagine reaching for it in my tool belt when I need a document store over MongoDB but I’m obviously biased so I’m wondering if there is a lot I’m missing.
Obviously it’s cool from a more open source databases standpoint — I love learning about how things are built and evolve over time.
2. MongoDB's design has historically been terrible; and, from my current experience with clients, is still a source of 'WTF's.
I just verified every single post of you on hackers news in last 12 months, and every one, in different DB discussions are doing the some shamefull plug about Realm.
E v e r y o n e.
And not a single disclaimer from you, not to mention some of your posts (like here, what janl pointed) are simply not true.
Disgracefull. I'm leaving this comment for anybody in the future doing check on you to notice this.
As silly as that sounds as a reason to choose CouchDB it demonstrates where the respective company's priorities lie.
CouchDB is a community-run Apache Software Foundation project (that has corporate contributors as well as individual contributors) at a much lower scale than MongoDB.
Of course MongoDB’s marketing is better, they are spending a lot of money on it. If you’d like to help out with CouchDB’s marketing, we can always use another helping hand :)
It's definitely impressive marketing but when I'm deciding on which tool to use that arguably works against them as opposed to for them.
"It's incredibly fast!" "It's web scale!" "It'll be able to drive itself cross country in a couple of months!"
And I think the unfounded/exaggerated hype bothered a lot of us, but like Tesla, the actual product seems to have improved quite a lot as they've had time and resources to throw at it. So sure, some of us remember Teslas and MongoDB from 2013 and scoff, but the current reality is much different.
> The Couch Replication Protocol lets your data flow seamlessly between server clusters to mobile phones and web browsers, enabling a compelling offline-first user-experience
CouchDB has another pattern, each master is really a master and you can have live replication but also offline replication. You can connect two clusters every new moon and they will synchronize. For sure the clients may have to deal with potential conflicts but in practice it's very neat and that's what makes couchdb worth it if you need this feature.
CA databases: SQL databases that are hard to scale ("partition") but are always consistent and available.
CP databases: MongoDB style databases that are consistent and partition tolerant, but trade availability (sometimes your queries will fail during high load).
AP databases: CouchDB style databases. They are always available and are partition tolerant, but you may be querying stale data.
They are very different databases. But since they have come up are around the same time and because they look very similar on the surface, you might think you chose between them.
But when you look more closely at detail decisions on the technical details, at almost every point, where CouchDB goes one way, Mongo went the other way.
I’m not saying either decisions are better or worse, it’s just that they are very different database that you should evaluate on their merits, not just superficially.
Looking forward to CouchDB 4.0/FoundationDB goodies. Do we have any roadmap details on this.
> Default installations are now secure and locked down.
More good news!
Anyone have recent experience with couchdb?
I see the (quickstart) docs use plain http - should one terminate ssl in front, eg with a recent version of haproxy?
CouchDB does SSL natively, but we do recommend HAProxy.
I joined a company where it's being used backing a mobile app with couch/pouch in production. We can't wait to get off of it. Writes are slow. Reads are worse. Having a DB per user is a scaling and backup nightmare. If you run into any issues, it's a ghost town.
I'm glad the CouchDB Team is forging ahead, but who is really using this database?
OTOH, publicly known big companies using CouchDB include Apple and IBM.
And I worked on a team that used CouchDB’s offline capability in the 2015 Ebola crisis in West Africa. That work also lead to the first Ebola vaccine ever.
That’s why we do CouchDB :)
One you implement validation functions [1] on user databases to control what kind of data can be inserted into couch. These functions can only be changed by database admins, not users, so can act as a security mechanism controlling what goes in.
As mentioned by others you can also implement a proxy. This doesn't have to interfere with sync functionality, you just have to make sure you proxy all the endpoints in the replication protocol [2]. Envoy [3] is one such proxy that essentially applies document level permissions to a CouchDB database without interfering with sync.
If the goal is just to limit document size, or throttle clients trying to hammer the API, this doesn't even have to be a custom proxy, and reverse proxy with the needed control knobs (such as NGINX) will do. You can of course combine this with validation functions, using validations to ensure the everything that comes in is the right "shape" and using NGINX and it's ilk to apply throttling and sane request limits.
At scale there's a decent chance you want a proxy in front of your Couch instance anyway, since Couch is truly multi-master, meaning you probably want to balance your clients across all your nodes anyway.
[1] https://docs.couchdb.org/en/stable/ddocs/ddocs.html#validate... [2] https://docs.couchdb.org/en/stable/replication/protocol.html... [3] https://github.com/cloudant-labs/envoy
I'm not sure about current time but previously it was a problem that couchdb file grow until some limit on filesystem and couchdb just crashed.
Start of the envoy readme: it's not battle tested or supported in any way. Also it doesn't do any validation apart from limiting permissions for different users.
It's easier to reimplement couchdb than to create smart proxy that will estimate is this query expensive or not.
I'm not saying about rate-limiting proxy or load-balancing to different backends which could be implemented on nginx or something else.
1) The client you wrote is bugged and generated bad data. This scenarios can occur just as easily using Postgres and an application server. What does your app server do if a client tries to send bad data? (Answer: Whatever you told it to do. Most likely throwing a 500 when your databases refuses the incoming data.)
As for what will happen when pouch syncs to couch the server will let everything else sync, but not the bad document. The return value from the API call will tell you what documents didn't sync.
2) Someone is intentionally trying to shove bad data into your database. In this case it's worked as advertised and rejected the bad data. What do you care if a malicious client breaks?
What kind of "expensive" query are you envisioning? Mango queries don't support joins, and only simple equality filters, so in general the worst thing someone could do is send a query that doesn't use an index, but why are you letting the client query the server in the first place? Just have the client sync and query client side. Or don't allow access the the _find endpoint and restrict them to the map/reduce view you handwrote.
If you must let them send arbitrary queries (which to me implies a relatively trusted user, but let's pretend their not), then run the query with a limit of 1 or 0, and examine the execution stats to see if they are using an index, and check their query to see if their limit is reasonable. But at this point you've now entered into a scenario that's going to be very difficult with a custom API too.
For your example specifically I'd use a proxy.
Do you propose to create proxy that parses query and estimates complexity? I think this task at least as hard as implementing couchdb myself (actually harder)
Is there any secure open source code with pouchdb/couchdb integrations?
CouchDB was a simple but very powerful idea (that still needed improvements), but it was coopted into something not very nice nor good nor useful.
See my old rant about it and why it failed: http://web.archive.org/web/20170530122143/http://entulho.fia...
I'm wondering how people solve the common search after create pattern when using external indexes
I have never done this with CouchDB, but the technique is described in Martin Kleppman's __Designing Data Intensive Applications__.
We are working on per-document-access-control at the moment, to support this use-case out of the box
This is a great release too!
Some are no longer maintained. Some still work.
To clarify: seems their main site is on apache.org. But, their www.couchdb.org site (hosted on uberspace.de) doesn't have a correct cert.
Maybe you encountered a bug where it served the wrong cert for a different batch of custom domains.