Sarah Mei, a software developer and Ruby community figure, writes about databases, programming culture, Rails, and diversity in tech.
HN links her post "Why You Should Never Use MongoDB", which one commenter says started much of the criticism of Mongo, and her essay on programming not being math.
At some point I'll write up my notes about how I've been using MongoDB. I've basically given up on SQL databases. Every architecture, for every scale, from small to Enterprise, is really better handled by MongoDB, sometimes in conjunction with Kafka (since any sufficiently large operation is automatically heterogeneous and polyglot, with different database technologies).
When you're a small startup and you're just starting up, you can create a single MongoDB instance (ignore everything about you've heard about Web Scale) and stuff data into it as needed, without thinking much about the structure. You can add in contracts on your database functions, which slowly specify the contract, as you learn more about what your project is really about. To get a sense of that style of development, please see what I wrote in "How ignorant am I, and how do I formally specify that in my code?"
http://www.smashcompany.com/technology/how-ignorant-am-i-and-how-do-i-specify-that
MongoDB is great for ETL. You can pull JSON from 3rd party APIs and store it in its original form, then later transform it into the different forms you need.
In large Enterprises, you will inevitably be trying to get multiple services and databases to work together. The old style for dealing with this was the ESB (Enterprise Service Bus) or SOA (Service Oriented Architecture) but in recent years most of the big companies I've worked with have moved toward something like a unified log, as Jay Kreps wrote about in…
"Learn X in Y minutes" is an awesome concept! Let me know if you ever decide to run with it. I guess I don't fit the CoffeeScript is a hipster language profile very well but I still enjoy writing code in it ;)
I basically agree with everything you've said (in both posts) ... you can be successful while wasting cycles. And if you're working on a low-volume and/or internal only application, you'll probably never face the limits of a modern server.
If you need to operate "at web scale" [1], or run into an uncommon (or common) bug, you'll need to know more about the frameworks and systems you're code relies on (e.g. MongoDB configuration for systems over 2GB [2]). Blog posts like the one referenced are completely unfair to those that developed MongoDB - read the manual and understand how MongoDB works OR use it at your own risk.
So I'll switch arguments and help you make your point. We have an application written in Oracle's Application Express - while we have extensive expertise in Oracle's database software, we have this one system which was completed for expediency's sake. It's kind of horrific but (mostly) works at the scale required. It would be financially foolish to dig into more deeply into ApEx for this one dead-end application. Everyone is happy.
[1] https://www.youtube.com/watch?v=b2F-DItXtZs (audio NSFW)
[2] http://www.sarahmei.com/blog/2013/11/11/why-you-should-never-use-mongodb/
Reminds me of http://www.sarahmei.com/blog/2013/11/11/why-you-should-never-use-mongodb/
> Remember that TV show application? It was the perfect use case for MongoDB. Each show was one document, perfectly self-contained. No references to anything, no duplication, and no way for the data to become inconsistent.
> One Monday, at the weekly planning meeting, the client told us about a new feature that one of their investors wanted: when they were looking at the actors in an episode of a show, they wanted to be able to click on an actor’s name and see that person’s entire television career.
> The client expected this feature to be trivial. If the data had been in a relational store, it would have been.
> I learned something from that experience: MongoDB’s ideal use case is even narrower than our television data. The only thing it’s good at is storing arbitrary pieces of JSON. “Arbitrary,” in this context, means that you don’t care at all what’s inside that JSON. You don’t even look.
> When you’re picking a data store, the most important thing to understand is where in your data — and where in its connections — the business value lies. If you don’t know yet, which is perfectly reasonable, then choose something that won’t paint you into a corner. Pushing arbitrary JSON into your database sounds flexible, but true flexibility is easily adding the features your business needs.
My concern would be whether Mongo will cause me to lose data.... "To recap: MongoDB is neither AP nor CP. The defaults can cause significant loss of acknowledged writes. The strongest consistency offered has bugs which cause false acknowledgements, and even if they're fixed, doesn't prevent false failures." https://aphyr.com/posts/284-call-me-maybe-mongodb
...or get my data corrupted: "When MongoDB is all you have, it’s a cache with no backing store behind it. It will become inconsistent. Not eventually consistent — just plain, flat-out inconsistent, for all time. At that point, you have no options. Not even a nuclear one. You have no way to regenerate the data in a consistent state." http://www.sarahmei.com/blog/2013/11/11/why-you-should-never-use-mongodb/
When you refactor or rewrite your code, you have the old code in version control, can write tests to confirm that it still works as expected, and there's no inherent time pressure.
If you pick an unreliable database and your data has been or is being lost and/or corrupted, it's more like a "try to stop the bleeding before the patient dies" situation.
That's not the time I want to be considering changing databases.
> JavaScript Object Notation which looks exactly the same as JavaScript.
Whether it looks the same is irrelevant. It doesn't even have the same syntax rules. For example, this is valid JavaScript:
{
one: "two",
three: undefined
}
... but would be completely invalid in JSON, in more than one way. No, they are not the same.
> don't see how it's the same as converting for example PHP to MySQL where I'm bound by a schema which looks nothing like my data structure in PHP
And in 99% of cases, this is a feature, because you can't represent most data as a flat list of nested objects. See also this article: http://www.sarahmei.com/blog/2013/11/11/why-you-should-never-use-mongodb/
Aside from that, if you want a native nested representation of data in your database, so including relations, you use an ORM. For example, in PHP with MySQL, you might use Eloquent.
How data is represented in your application and how it's represented in the database, are two entirely different things. There's no advantage to be gained from trying to make them the same thing - that's the concern of the database abstraction that you choose to use.
Aphyr has thoroughly explained what is wrong with MongoDB[1]. I'm quite sure that things aren't probably as swell with your tech stack you might imagine. A commenter here has in the past demonstrated how to cause someone using MongoDB data problems by sending too much information too quickly for MongoDB to handle in a targeted way although I can't find the link to it now. I have been wanting to try it myself to see if I could do it too. Firebase uses MongoDB[2]:
"Firebase stores all its data in MongoDB which offers the built-in capability for apps to scale automatically and gives each piece of data its own unique URL stored in JSON documents."
I was going to see if I can get achieve data consistency problems there for my own firebase app.
Also posts that malign MongoDB frequently make it to the home page [3][4].
[1] http://aphyr.com/posts/284-call-me-maybe-mongodb
[2] http://www.mongodb.org/about/production-deployments/
[3] http://www.sarahmei.com/blog/2013/11/11/why-you-should-never-use-mongodb/
[4] http://www.aaronstannard.com/post/2013/12/19/The-Taxonomy-of-Terrible-Programmers.aspx