r/programming • u/speckz • Jul 20 '15
Why you should never, ever, ever use MongoDB
http://cryto.net/~joepie91/blog/2015/07/19/why-you-should-never-ever-ever-use-mongodb/390
u/SulfurousAsh Jul 20 '15 edited Jul 20 '15
After having to inherit and deal with a multi-terabyte mongo cluster in a production environment, I will never use it again. Especially with Postgres' composite types, jsonb querying and indexing, materialized views, plv8, and numerous intergrated transaction and locking capabilities.... It has everything I've needed in a database.
99
u/SomethingMoreUnique Jul 20 '15
Why's that? What problems did you hit when you took over the mongo cluster?
278
u/SulfurousAsh Jul 20 '15
Simple queries would randomly take exponentially longer to return than normal (even with proper indexes), data migrations were painful, the most popular interface for ruby (mongoid) would randomly get out of sync (erroneously returning data for the previous query - still never got to the root cause), lack of proper transaction support.
But most importantly the lack of an enforced schema is an enabler for poor development practices and inconsistent data. While this isn't necessarily a fault of the database itself, the ad hoc document nature is easily abused and led us to unmaintainable longterm practices.
→ More replies (49)24
u/keithb Jul 20 '15
But most importantly the lack of an enforced schema is an enabler for poor development practices and inconsistent data.
This. RDBMSs are only coincidentally about persistence. They are really consistency engines. The rush to adopt NoSQL solutions in situations where consistency turns out to actually be very important is a really spectacular instance of throwing the baby out with the bathwater.
→ More replies (1)157
u/lachryma Jul 20 '15 edited Jul 20 '15
I helped run about a dozen high-load production MongoDB clusters at a prior employer. The software is just fine as a single instance without any sort of replication, scaling, or anything. Once you add
mongocand begin clustering, it becomes one of the worst experiences of your natural life.Seriously, they removed a shard once -- just removed a shard, you know, typical production operations -- and that was about a day of downtime to unfuck the database.
Developers love MongoDB. The only shop where this works is one in which developers can throw things over the wall at operations, because in any sane shop, operations will steer you hard toward PostgreSQL. MongoDB is a good way to give your operations team ulcers, because it has behavior that makes absolutely no sense.
Edit: Typo
96
u/glemnar Jul 20 '15
Good developers love postgres too. A lot of them are just stuck with bad past decisions.
66
u/Kalium Jul 20 '15
A lot of bad developers love Mongo and similar because schemas are "hard". So they use something schemaless, getting the downsides of both having schemas and not having schemas!
→ More replies (26)→ More replies (9)36
25
u/OHotDawnThisIsMyJawn Jul 20 '15
My big complaint is that getting low on disk space is basically a death knell. You can't even clean up space for deleted objects. And God help you if you want to add another shard.
105
u/btchombre Jul 20 '15
I'm going to go out on a limb and assume he encountered problems relating to the fact that MongoDb is terrible for storing relational data, and yet everybody uses it to store relational data.
Turns out Data-Integrity is usually more important than rarely needed massive scalability. Who knew.
97
u/fforw Jul 20 '15
Who knew.
Everyone who watched MySQL lose to PostgreSQL..
→ More replies (13)49
u/Halmonster Jul 20 '15
I've been a fan of PostgreSQL over any other DB for ages now (I had a friend at Cal who worked on some early versions). However, I don't think MySQL lost...
→ More replies (17)62
u/kenfar Jul 20 '15
assume he encountered problems relating to the fact that MongoDb is terrible for storing relational data, and yet everybody uses it to store relational data.
Concepts like "relational data", "hierarchical data", "network data" are myths. For the most part there's really just data that we organize into relational, hierarchical and network data stores.
So, when MongoDB's response to most criticisms is "duh, you shouldn't have used MongoDB for relational data" - this should in turn be countered with:
our data was a perfect example of a textbook MongoDB dataset
but then, like everyone else, we discovered that we needed to join other sets of data to it. We wanted to join rather than add it to the collection because a) it was low cardinality & huge, so adding would be insanely expensive and b) we often want to see old data joined to new values.
and we needed to stop repeating some data, and move it into a separate collection and join to it - in order to stop repeating info everywhere (like last name).
128
u/mcrbids Jul 20 '15
Understood it clearly!
Some data is non-relational. Typically, it remains non-relational right up to the point where it becomes valuable. As soon as it's valuable, people start wanting to compare and contrast it with other data, which means creating relationships.
The only use case for MongoDB is when your data has little or no actual value.
→ More replies (11)→ More replies (4)4
u/chrisrazor Jul 20 '15
everybody uses it to store relational data.
Isn't that because nearly all data is relational?
→ More replies (4)16
u/andrefsp Jul 20 '15 edited Jul 20 '15
We handle a relatively high load system.
Among with other problems we have with this database at any random times we get quite lot of write traffic but not enough to justify sharding the database.
As mongo operates in "greedy writes" lock (http://docs.mongodb.org/manual/faq/concurrency/#what-type-of-locking-does-mongodb-use) when this happens we have massive spikes on our read queues making all the queries to go very slow.
The worst thing about this its that even if you have replicas and you try to read from then you will suffer from the same problem caused by the replicated writes.
Basically, there is nothing you can do about this.
We have been trying to get rid of Mongo for a while now and the reason why this it was introduced in first place was because someone read somewhere that "MongoDB scales and postgres doesn't scale because it does joins". I think the guy might have been a victim of MongoDB hype and propaganda.
I've been working with mongo for a while now and I can say there is absolutely no use case I can think of where this database its good at.
For those "Web scale Mongo" fanboys -> MongoDB is WebScale
→ More replies (2)8
u/PM_ME_UR_SRC_CODES Jul 21 '15
We have been trying to get rid of Mongo for a while now and the reason why this it was introduced in first place was because someone read somewhere that "MongoDB scales and postgres doesn't scale because it does joins". I think the guy might have been a victim of MongoDB hype and propaganda.
I honestly don't understand where all the hate for JOINs comes from. I've seen stored procedures in production, under heavy load, do ~30 table joins like it were nothing.
All you really need to be careful with is to take the time to setup indexes properly and check the query planner to see where unexpected bottlenecks may be.
→ More replies (1)32
u/k-bx Jul 20 '15 edited Jul 20 '15
How do you handle multi-terabyte Postgres? Do you shard it? Do you replicate it? If yes – how do you do that? Do you have some failover systems? Can you describe them please?
(updated my question for clarity, because of silent downvotes)
update2: I created a separate poll-topic to discuss all common solutions: please do participate! https://www.reddit.com/r/programming/comments/3dx5j3/poll_people_who_prefer_postgresql_to_mongodb_how/
→ More replies (9)27
u/dready Jul 20 '15 edited Jul 24 '15
There are a ton of options. Many times a multi-terabyte Postgres instance is fine the way it is. You may want to use table partitions or table inheritance to break tables into logical segments before moving to a sharded model. I always think of sharding as a success story. If I can't cost-effectively vertically scale anymore, that's a great business success. Also, it is useful to make a distinction between HA architectures and scalability architectures because when you combine them things can look a little different.
43
u/mynameipaul Jul 20 '15
Many times a multi-terabyte Postgres instance is fine the way it is
Pragmatic problem solving, step 1:
Is there a problem? No? Cool. See you at lunch.
→ More replies (8)→ More replies (1)10
u/k-bx Jul 20 '15
I've added a topic-poll to ask for the most common setups for Postgres for problems which MongoDB tries to address https://www.reddit.com/r/programming/comments/3dx5j3/poll_people_who_prefer_postgresql_to_mongodb_how/
Please, do share yours there!
→ More replies (2)5
u/istinspring Jul 20 '15
jsonb querying and indexing
do you ever use it?
→ More replies (3)2
u/Momer Jul 20 '15
I've used JSONb, and it's great. Just like anything else, though, storing terabytes of data as JSONb is going to require lots of space for indexes.
→ More replies (2)→ More replies (7)3
u/thatgibbyguy Jul 20 '15
All of this comes down to how you experienced whatever system. As a meteor developer, this post is obviously laughable to me, but let's go further.
I am a meteor developer because I inherited a rails app that was built using postgres. That application was so full of errors, hidden gotchas, etc. that it basically pushed me away from rails/postgres for life.
It had very similar symptoms to what you're complaining about too. So what's the common link here?
Shitty developers. That's why your app sucked, that's why mine sucked. The developers before sucked. Shitty developers are platform independent, they just make bad things.
→ More replies (1)
158
u/ramigb Jul 20 '15
I never used MongoDB or NoSQL databases in a serious project not because i tried to evade them but i seriously couldn't find a benefit that convinced me that it's better for my projects than a relational database, this article doesn't make me "happy" but it made me feel more assured that choosing Postgres or MySQL was the right decision.
79
u/unstoppable-force Jul 20 '15
companies started realizing that when it comes to extracting value from data, those relations are incredibly important. that's where the bulk of the value comes from.
→ More replies (2)28
u/iamadogforreal Jul 20 '15
This is what happens when webdevs get the spotlight. "Hey we don't need all these fancy features!" Yeah well, everyone else does.
24
u/longshot Jul 20 '15
I always found this attitude insane. I'm a webdev and a database without the relational portion would be so minimally useful to me.
→ More replies (4)58
u/armpit_puppet Jul 20 '15
Take comfort in that you are probably right. The projects that benefit from non-relational stores do so because they have different access patterns than projects that use relational stores. Most development projects will never achieve the scale that require data to be de-normalized or sharded across multiple instances. When they do, it requires work in the application layer and in the storage layer.
First, you'd change your application to query on keys only. This might mean adding compound keys, or adding unique ids to tables without them. When you get that sorted out, you will be able to take advantage of technologies like Redis and Memcache, in memory, non-relational stores more focused on speed than data durability. You'll query by key, put the result into the cache and return it to the client. On subsequent requests you return from cache. This probably buys you scale into the top 100 U.S. web companies.
By the time you reach that scale, you'd probably be using your relational DB much more like a key-value store as much as possible. This means eliminating joins, splitting off tables that are queried together, and clustering them together. Slaves are added to clusters for read-heavy applications. Anything that can be cached will be cached.
For some tasks where you cannot use keys, you'll be querying over indices, but you'll take great care to examine query plans and ensure everything is optimized. Even then, you'd probably cache the results and ensure a reasonable limit on the number of requested records. You might use Redis's sorted sets if the use case supports it. If you need even more scale, you'd put Memcache in front of Redis, in front of your DB. Or maybe you'd write your own thing because at the point where you're doing things like that, you have Reddit's level of scale (and funding for an engineering team).
Anyway, not all NoSql sucks like Mongo does. Redis and Memcache have great reputations and known limitations (and there are others that also don't suck). Mongo's particular brand of suckage seems to be it's hype and marketing combined with it being an immature product masquerading as the Second Coming.
19
u/frymaster Jul 20 '15
I think the main thing is that, at smaller scales, relational databases work okay at things nosql is good at, whereas nosql is terrible if misused for things that a relational database should be used for. And also that mongo sucks.
7
u/GiantNinja Jul 20 '15
This. I couldn't agree more. I used Mongodb on one project, and it seemed awesome at first, but it didn't take long for it to become apparent that my CTO had made the wrong choice. Was fighting with it way more than it was helping. The Geospatial searching (one of the main selling points for our use) just plain didn't work right and had a limit (like hard-coded into the source code) of 100 results. Totally useless. Could have knocked that site out so much faster and correctly (instead of hacking shit together because of fighting with mongo) doing it the way we knew how (mysql/postgres db, memcached and sphinx search for our search/geo spatial searching/sorting).
The project ended up as a failure for many reasons, but I think mongodb was certainly a contributing factor. Glad I didn't have to work on that project long enough to run into scaling /performance issues that were basically looking us right in the face.
→ More replies (3)6
Jul 20 '15
Why would you put memcache in front of redis when both are key value caches in front of your DB?
18
u/armpit_puppet Jul 20 '15
Let's say you work on a hypothetical application that has a per-user timeline of events. The timeline is paginated with 20 events per page, 99.992% of users never go past page 20. The timeline is the home page for the app, and it alone can see 100k QPS. Querying the database for timeline events is too resource intensive to perform with every request.
You've got this data that models nicely into a Redis sorted set, so when an event is created, it's inserted into the DB, and then inserted into Redis. When a user lands on the home page, bam, events ids come out of Redis, they are multi-getted from Memcache and you serve up the timeline. Awesome. Except this is too slow. The Redis machines are CPU saturated and lock up. You've got to find a better way.
You know Memcache will do 250k QPS easily, while Redis will only do about 80k QPS, and Redis only does that number as straight key-value. Sorted set operations are much slower, maybe 10-15k QPS. You could shard Redis and use Twemproxy or Redis cluster for the data, but you'll need 15-20x the machines you would for Memcache. But an all-Memcache cluster would suck for this application. Whenever an event comes in, you'd have to re-write 20 cache keys per timeline where the event appears.
You examine your data again, it turns out 98.3% of users never make it past page 6. If you can find a way to store that data in Memcache, you can reduce the hardware footprint vs a pure Redis cluster.
Now, when an event comes in, you store it in the DB, push it to Redis, then generate 6 pages and push that into Memcache. Timelines are served straight out of Memcache to page 6, then out of Redis to page 20. The application can just use a loop over the Memcache data to get to the correct offset, and you've saved a lot of money in hardware.
The trees thank you, the dead dinosaurs in oil thank you, your manager thanks you because, let's face it, you've saved the internet. Go home you hero, and puff out your chest. You've earned it.
→ More replies (3)6
u/robotfarts Jul 20 '15
Dynamo can handle far more IOPS and has no table size limits, I believe.
→ More replies (2)→ More replies (9)3
Jul 20 '15
Single Table Inheritance is much more natural in Mongo (or any schemaless db I guess). Not sure if that's a good or bad thing yet.
3
84
u/TomNomNom Jul 20 '15
My place of work uses MongoDB to store what are effectively materialised views onto a relational database - i.e. documents stored in a document store. There's a few reasons that it's an OK fit for what we're doing:
The data isn't mastered in MongoDB. It's a view - the data can be regenerated pretty easily from source.
It allows partial document updates. Some of our documents are a few MB in size so writing the whole document each time would be a bad idea.
It handles > 500 updates per second just fine, which is good enough for us. Our data changes a lot and needs to be very fresh, so throwing a big cache in front of a relational DB makes cache invalidation hard.
We don't write to it from customer-facing code. I.e. we don't have to scale write-locks with growth in customer traffic.
The reads are fast enough. We're doing _id lookups and have seen >3.5gbit/s in reads per node. We're running a 3 node replica set and it's easy to bump that up to 5 or 7 to add more read capacity.
We've found the self-managed failover within a replica set to work pretty well - and trivial to set up.
We're running on 64 bit machines - because it's 2015.
Our MongoDB nodes aren't in our DMZ and the data isn't sensitive anyway (i.e. it's all accessible through our website). Security issues like the one mentioned in the article aren't great - but not really a deal-breaker for us.
10gen/MongoDB inc have been very fast to respond to the few issues we've encountered. The consultancy and training we've had from them in the past has been top-notch too - they've always been very honest about the software's weak-points and how to make best use of it.
Are there better solutions? Probably; but MongoDB has proved itself good enough for our use case.
26
u/brainphat Jul 20 '15
No expert, but sounds like exactly the way MongoDB and NoSQL in general were meant to be used. Thanks for the example.
4
u/TomBombadildozer Jul 20 '15
The data isn't mastered in MongoDB. It's a view - the data can be regenerated pretty easily from source.
Why add a layer of persistence and indirection? Why not scale out with read slaves and just compose information from the source?
It allows partial document updates. Some of our documents are a few MB in size so writing the whole document each time would be a bad idea.
Does your relational data consistently denormalize to a specific size? If not, performance is going to be terrible. But I digress....
Is it a view or not? Do you write updates back to the relational database and then do a corresponding document update in MongoDB? If so, I'll refer back to my first question.
→ More replies (1)13
u/TomNomNom Jul 20 '15
Why add a layer of persistence and indirection? Why not scale out with read slaves and just compose information from the source?
It's largely about latency from the customers' point of view. The data is quite highly normalised in the relational DB, and the queries can get a bit scary. We could cache the query responses (with a very short TTL), but someone is still going to have the latency hit of running the query - and that's just not acceptable for us. Doing our data-transforms out-of-band keeps our customer-facing code fast and simple.
FWIW, we did do it that way first, so we're not just making assumptions about how the approaches compare - we have data to back it up. Tail latency in particular is much improved.
Does your relational data consistently denormalize to a specific size? If not, performance is going to be terrible
There's a pretty big spread of sizes between documents, and the documents change size quite a lot. I don't see why that would make performance terrible - in fact: it doesn't; our performance is fine.
Is it a view or not? Do you write updates back to the relational database and then do a corresponding document update in MongoDB? If so, I'll refer back to my first question.
It is a view. The data doesn't originate with customers though - it comes from other sources, so there's no "customer makes change, doesn't see change reflected in site immediately" type problems. There's no per-customer data in MongoDB, only global data.
→ More replies (1)→ More replies (1)2
Jul 20 '15 edited Jul 21 '15
We've implemented a similar solution. Thanks for reinforcing our concept and use case.
84
u/thistokenusername Jul 20 '15
Why is that every article is about the birth of a new language/framework/system or death thereof ?
92
u/BlueRenner Jul 20 '15
Because, just as in politics, drama gets attention.
Coding is boring, incremental work full of nuance, tedium, and compromise.
New frameworks which will solve the Jesus are interesting, though!
17
u/pihkal Jul 20 '15
Thank Yahweh! Our Pharisee 2.0 project has a serious Jesus problem.
12
u/theonlycosmonaut Jul 20 '15
Pharisee
is a really damn cool-sounding word and would make a great project name.
→ More replies (4)2
u/minshallj Jul 20 '15
Do you have a moment to talk about Jesus, er, I mean, my new javascript framework?
0
Jul 20 '15
[deleted]
16
u/jeandem Jul 20 '15
There are sudoku solvers so that doesn't bode well for your job.
→ More replies (7)8
13
u/joepie91 Jul 20 '15
Far from it. They're just the ones that cause most excitement and/or controversy, and thus more easily rise to the top of a ranking (like on Reddit).
8
u/thistokenusername Jul 20 '15
Fair. By every article, I meant every article from programming subs that pops up on my front page
16
Jul 20 '15
It bears pointing out that the reason databases like Postgres have added this kind of functionality is because projects like Mongo came along and proved the usefulness of the idea (if imperfectly).
Mongo should probably be allowed to just go by the wayside, but kind of like programming languages that are influential but never catch on themselves, Mongo deserves credit for being influential in this space.
That said... seriously, don't use it.
211
u/SanityInAnarchy Jul 20 '15
This has come up before. At this point, Mongo might be too big to fail, though -- it might be a successful application of worse is better.
But really, this article is not helping.
The sources on Mongo losing data seem to indicate that it loses data in the default settings, and when used naively. This is true of many databases. MySQL had the InnoDB engine added much later, and it's only as of version 5.5.5 that it's even the default over MyISAM, which loses data. And people still use MyISAM sometimes, because it has some features InnoDB doesn't.
in fact, for a long time, ignored errors by default and assumed every single write succeeded no matter what
This is really shitty, and is my least favorite thing about both PHP and MySQL. Often, if you try to insert a value that's completely nonsensical for a MySQL column, it'll just turn it into a NULL, and if you're lucky, you'll get a warning about that. You can make it stricter, but this can break legacy applications that rely on this insane behavior.
is slow, even at its advertised usecases, and claims to the contrary are completely lacking evidence
Both of these are comparing to Postgres, which always sounds so interesting, yet you rarely see anyone trying to use it at scale. It's also not obvious what's being compared. If you're outperforming Mongo on a single machine, that's not likely to impress someone who bought into the hype -- the whole point is horizontal scaling.
I'm not claiming Mongo is faster or even better at this, but I don't see much evidence either way.
forces the poor habit of implicit schemas in nearly all usecases
This is like a debate about strict, static typing versus dynamic typing. It's true, nothing will make you stop having to think about types or schemas, but that doesn't mean Python is useless.
has locking issues (sources: 4)
I may be missing something -- I'm just skimming, after all -- but the only mention of locking issues I can find in that article is talking about MySQL versus Postgres, and not about Mongo at all.
has an atrociously poor response time to security issues - it took them two years to patch an insecure default configuration that would expose all of your data to anybody who asked, without authentication...
In other words, if you launched it without configuring authentication, it wouldn't do authentication. This is shitty defaults -- that's arguably a bug, but this is a lot of hyperbole. If you had it properly configured, it was no more vulnerable to this than any other database.
is not ACID-compliant
Kind of the point. See: CAP theorem. Postgres is at best ACID on a single machine -- as soon as you have a cluster, you're going to have to figure out which of those to sacrifice.
is a nightmare to scale and maintain
This is probably true, but without a citation, it's really hard to argue about. Many things are a nightmare to scale and maintain. What makes Mongo especially bad here?
isn't even exclusive in its offering of JSON-based storage; PostgreSQL does it too, and other (better) document stores like CouchDB have been around for a long time
No argument there, it's not exclusive. And Couch is interesting, but neither of the citations mention it -- so why is Couch better?
All of this makes the conclusion believable, but not really well-supported. I'm not especially a fan of Mongo, but this is not especially better argued than the "You should use Mongo because it's web-scale" stuff. I see nothing to counter claims such as:
Faster prototyping is possible with implicit schemas than explicit
Easy schema changes are easier with implicit schemas
More complicated schema changes can be made more safely with implicit schemas
Mongo is better than CouchDB (faster, more reliable, or easier to work with)
Mongo is easier to scale and maintain
Mongo is no less secure than the alternatives
I'm not claiming any of these are true, only that the article doesn't really seem to do anything to disprove them. Its strongest argument is that Mongo has some pretty horrifying default settings.
That's bad enough on its own, as the default settings -- especially of a brand-new database -- says a lot about the mindset of the people who wrote it. If I made a text editor that could run in Unicode or EBCDIC mode, and I set it to EBCDIC by default, it might be a perfectly good text editor, but that choice would probably make you question my sanity and technical competence -- and thus you'd be reluctant to adopt it.
That's all well and good, and maybe enough of a reason to avoid Mongo, but you don't need to exaggerate by then saying Mongo is terrible at everything. Or, if it actually is terrible at everything, you should provide more evidence that it is.
33
u/velcommen Jul 20 '15
is not ACID-compliant
Kind of the point. See: CAP theorem. Postgres is at best ACID on a single machine -- as soon as you have a cluster, you're going to have to figure out which of those to sacrifice.
The CAP theorem does not imply you cannot have ACID compliance in a distributed setting. However, one implication is that when there is a network partition and there is no reachable quorum, you must choose two of the three. So if you prefer consistency and partition tolerance, the database becomes unavailable during a partition. FoundationDB, for example, chose those tradeoff.
MongoDB is just suboptimal engineering and never makes any attempt at ACID compliance in a multinode setting.
→ More replies (1)6
u/eadmund Jul 20 '15
The sources on Mongo losing data seem to indicate that it loses data in the default settings, and when used naively. This is true of many databases. MySQL…
'It's not as broken as MySQL' is faint praise, and 'it's only as broken as MySQL' is fainter still.
→ More replies (1)9
u/Miserable_Fuck Jul 20 '15
It's also not obvious what's being compared.
From source 3:
The initial set of tests compared MongoDB v2.6 to Postgres v9.4 beta, on single machine instances. Both systems were installed on Amazon Web Services M3.2XLARGE instances with 32GB of memory.
EDB found that Postgres outperforms MongoDB in selecting, loading and inserting complex document data in key workloads involving 50 million records. Ingestion of high volumes of data was approximately 2.1 times faster in Postgres. MongoDB consumed 33% more the disk space. Data inserts took almost 3 times longer in MongoDB. Data selection took more than 2.5 times longer in MongoDB than in Postgres.
There are some tables with more data available.
This is like a debate about strict, static typing versus dynamic typing. It's true, nothing will make you stop having to think about types or schemas, but that doesn't mean Python is useless.
It's a lot simpler than static vs dynamic typing. You see, there are tangible tradeoffs to consider when discussing static vs dynamic typing. Python has things to offer in exchange. The schema vs no-schema debate, however, has been obfuscated by NoSQL/Schemaless enthusiasts to the point where a lot of people think that the schema vs no-schema debate applies to their project, when it usually never does. These people then end up ditching their schema for small or nonexistent benefits, and end up having to deal with new problems (Source 4, paragraphs 7, 8, 9, 10, 11).
I may be missing something -- I'm just skimming, after all -- but the only mention of locking issues I can find in that article is talking about MySQL versus Postgres, and not about Mongo at all.
Source 4, 4th paragraph.
No argument there, it's not exclusive. And Couch is interesting, but neither of the citations mention it -- so why is Couch better?
I don't know about Couch, but according to Source 3, Postgres is better.
→ More replies (1)3
u/Shinhan Jul 20 '15
And people still use MyISAM sometimes, because it has some features InnoDB doesn't.
I was really happy once we upgraded to version of InnoDB with FULLTEXT capability (5.6 was it?) because that meant I could get rid of the last few MyISAM tables.
5
u/sbrick89 Jul 20 '15
The sources on Mongo losing data seem to indicate that it loses data in the default settings, and when used naively. This is true of many databases.
MSSQL's defaults are extremely careful about your data... the only "unsafe default" is placing your data + log files on the same drive... but nothing about it ever looses data... and the default FULL recovery model ensures that Trans Logs can help restore the DB to the specific point of failure.
→ More replies (10)9
u/ksion Jul 20 '15
All of this makes the conclusion believable, but not really well-supported.
Mongo has risen to its popularity on the backs of opinionated blog posts and hyperbolic claims. It shouldn't take a peer-reviewed journal to knock it down a peg.
→ More replies (1)12
u/Beaverman Jul 20 '15
You can't fight fire with fire.
Writing hyperbole only works if people want to believe it. None of the people who use mongo wants to hear that it's crap, so they can just skip it.
There's also the problem that you might be unfairly criticising the technology, which would be bad for all of us.
→ More replies (19)2
u/zeekar Jul 20 '15 edited Jul 21 '15
I may be missing something [about locking issues]
At least some of that is historical. MongoDB through version 2.0 had a single global write-lock for the whole process. Any write anywhere would prevent access to anything on that node until the write completed - which is one of the reasons that it originally didn't wait to confirm that the write succeeded; the goal was to release that lock as quickly as possible.
Version 2.2, three years after the original release, narrowed the scope of the lock to per-database, but since the usual model for MongoDB is one database per application environment, that didn't actually help much.
Just 4 months ago with 3.0, they added per-collection locks, and the new engine ("Wired Tiger") even includes individual document-level locks. It was a pretty long 6 years to get there, though.
2
u/SanityInAnarchy Jul 21 '15
I find it disturbing that this lasted till 2.0, but thanks for clarifying that.
284
u/wolflarsen Jul 20 '15
I don't get it computer fan boi world ... 3 years ago we ALL had to be using Mongo or you're just not a programmer even.
Now don't even touch the shit.
Fine be that way.
320
u/joepie91 Jul 20 '15
Two different groups of people, that's why.
Three years ago (a bit longer actually, I think), I was shouting at a MongoDB developer on IRC about how absolutely insane their "ignore write errors" default was. And throughout the years, as the hype died out, more people started realizing (and documenting) the issues with MongoDB.
Which brings us to the current time, where there are enough documented issues to point at and say "hey, you really shouldn't be using this". But realistically, there were plenty of people who saw the red flags three years ago - their arguments just got drowned out by the hype.
128
Jul 20 '15
But realistically, there were plenty of people who saw the red flags three years ago - their arguments just got drowned out by the hype.
Or don't bother to argue at all, sitting at the sidelines watching the world burn.
74
u/Vacation_Flu Jul 20 '15
Or people like me who genuinely couldn't figure out why Mongo was supposed to be so great. I'm gonna pretend it's because I saw through the hype, but really I just didn't see any value in a schemaless database.
→ More replies (7)→ More replies (4)46
u/EmperorNikolai Jul 20 '15
I did this. I watched a project burn on mongo after someone supposedly more senior made the call to use it despite my warnings. Then when the shit hit the fan after merely 4 hours in prod (memory underestimation from hell), I spent a weekend moving it to SQL Server (we already had kit in place or it would have been postgres) and saved the company's management from shareholder wrath.
The same dude is all over devops, CD, AWS, node and cloudy bollocks now. Guess I'll have to pick that pile of shit up and fix it too. Bear in mind we're a Microsoft outfit and I'm the only person with any Linux knowledge at all...
Hype drinkers are dangerous.
→ More replies (4)26
u/biocomputation Jul 20 '15
Hype drinkers are dangerous.
This is the best thing I've read in a long time.
39
u/argv_minus_one Jul 20 '15
Ignore write errors?! Mongo ignores write errors?!?!? That is insane!
17
u/hurenkind5 Jul 20 '15
To be fair, it doesnt do that anymore.
67
u/201109212215 Jul 20 '15
To be fair, it shouldn't have done that in the first place.
Traditional DBs go out of their ways to ensure no data loss on several levels (Ram and disk buffers, redo logs, two-phased commits, CRC checks, etc. on top of user-definable consistency checks). And then you got MongoDB that fails to get the first level right. Failing to just write to disk.
To add on the pile of shit of code that MongoDB is, here is a commit in an official driver where they chose to report an error 10% of the time. Randomly. Yes, with Math.random.
Also, please notice the pokemon catch-them-all Exception on the line right above, and the lack of {proper logging, sound logic regarding Exceptions, dependency injection} on the lines right below.
It truly takes talent to write this.
→ More replies (9)5
u/hu6Bi5To Jul 20 '15
Two different groups of people, that's why.
It's not so clean a distinction. Many of the biggest Mongo haters that I know used to be the biggest Mongo lovers.
For some of them this was because they learned their lesson and improved as developers, but for others they are just habitual bandwagon jumpers!
9
u/ank_the_elder Jul 20 '15
You were shouting at a MongoDB developer on IRC? You must be a great person.
→ More replies (5)2
u/rnicoll Jul 20 '15
I suppose this is the upside to working for an employer (until recently) with a lot of legacy technology, people have adopted, assessed and then dropped new technologies long before you get to them :-D
17
Jul 20 '15
3 years ago we ALL had to be using Mongo or you're just not a programmer even.
This perception is not reality.
It feels a lot of people's memories mistake exuberance for pervasiveness. You remember people being loudly hyped for Mongo, but that warps into "remembering" that "everyone" was hyped about it. (It doesn't help that tech writers who can't code their way out of a paper bag write hype pieces for their shoddy publications/websites).
Hence, we have this repeating perception that "everyone" was hyping X and now "everyone" is abandoning X and it's just not reality. Mongo did not come anywhere close to unseating the top traditional databases in usage. Most people stayed off that train.
→ More replies (2)29
u/cp5184 Jul 20 '15
If you aren't using a container inside a container in the cloud inside a container...
16
12
u/m1ss1ontomars2k4 Jul 20 '15
5 years ago everyone already hated MongoDB. I can't recall a time when it was really all that popular to begin with.
9
u/krum Jul 20 '15
You couldn't even get a job if you didn't have Mongo experience.
→ More replies (3)9
9
u/prof_hobart Jul 20 '15
3 years ago, the cool kids were all shouting about how MongoDB was the way of the future, and the experienced developers largely seemed to be either sniping at it for the fact that it seemed to be lacking most of the features that made RDBMSs a better option than flat files back in the 70s/80s or at most desperately trying to understand what the use cases were for it that made it so great.
All that's happening now is that the cool kids are also starting to discover that it's missing those features that made RDBMSs the right answer back in the day.
→ More replies (1)6
u/wolflarsen Jul 20 '15
No the cool kids have moved on to something else.
(Yes, its probably an freemium Oracle clone)
7
u/dvlsg Jul 20 '15
Hey, better late than never (that people realize MongoDB is usually a bad idea, I mean).
10
u/Caraes_Naur Jul 20 '15
It's because too often non-technical managers (or worse, HR drones) make technical decisions based on the buzzword du jour.
In two years everyone will abandon Node.js as well.
8
Jul 20 '15
could you elaborate on why Node.js is just a passing fad? i was looking into starting to learn it, but don't necessarily want to if it won't go anywhere.
→ More replies (50)2
u/zarus Jul 20 '15
They're trying to fill in the gaping hole in their lives where meaning should be.
2
u/Sebazzz91 Jul 21 '15
Well you still need to do Ruby.. I mean Node.js with NoSQL and Angular, I mean React.js or you aren't a cool programmer.
→ More replies (1)→ More replies (118)7
u/smakusdod Jul 20 '15
Remember Ruby? This happens every 2 years. Get used to it.
7
u/iconoclaus Jul 20 '15
I think you're talking about Rails. Plenty of Ruby happens without Rails, but since those folks are necessarily writing user interfaces, no one notices. Such is the state of webdev.
→ More replies (1)0
13
u/greg90 Jul 20 '15
The article is a bit strong to say there are NO valid reasons, but yeah people were using things similar to document based databases for many years and there's a reason relational databases were invented. They work great. I'm amazed at how many programmers think a relational database won't scale for them given the absurd amount of data the things can store and query.
6
Jul 20 '15
[removed] — view removed comment
→ More replies (1)13
Jul 20 '15
Why would Consumer Reports publish a biased viewpoint?
Short Answer: Because they don’t want you to save gas.
Best Guess: Because they installed Tornado backwards on their dummy vehicle.
Our Conclusion: Because they’re linked to Oil Companies.
HAHAHAHAHA
25
u/db_bureaucracy Jul 20 '15
DB admins are partly to blame for the rise of MongoDB. SQL DBs are better, but in a lot of companies the DB is protected by an army of DB administrators who require forms and procedures signed by managers, layers and layers of bureaucracy, to just make a simple schema change. Even changes that won't hurt the data, they still require days of review and discussion until they will permit it. They expect developers to get the schema perfect and correct on the first try and for it to never ever change again after that. The herculean effort required for even simple changes greatly frustrates developers.
So it's not surprising that something like MongoDB became popular. Finally, no DB admin who will ignore your schema change requests for days and days and then suddenly the day before release, refuse to apply the schema because of some minor reason.
8
u/Arbawk Jul 20 '15
Why did Meteor decide to use MongoDB as their database of choice? If I'm in the midst of creating a web application with the hopes of gaining many users, was Meteor a bad choice because of its Mongo dependency? Or should I not be concerned about switching the backend to an SQL database (and perhaps completely away from Meteor, if necessary), without entirely rewriting everything?
→ More replies (2)2
u/bro-away- Jul 20 '15 edited Jul 20 '15
Because the MongoDB oplog allows for what amounts to a reactive database.
No other database is as easily and cleanly reactive right now (Expect Postgres to catch up, it has some issues right now and needs to throw away the trigger crap in lieu of a real reactive feature).
It has little to do with JS being the core language for queries and their driver is actually a bit of a departure when it comes to querying and doesn't support laziness.
This thread is hilarious btw. As if I'd use MongoDB for financial data or your heart monitor.
19
u/aradil Jul 20 '15 edited Jul 20 '15
I'm using it to replace a file based data repository.
It's better than that simply because of automatic failover.
Maybe there are better alternatives, but it's was also like 10 minutes to set up a replica set cluster, so I don't care all that much.
If I was already using Postgres for something else it would be an easy decision, but I'm not.
MongoDB is the caching layer behind my caching layer that get data pushed to it from my single source of truth relational database.
→ More replies (8)9
u/kenfar Jul 20 '15
it's was also like 10 minutes to set up a replica set cluster, so I don't care all that much.
And now maybe everyone has your data. And reports that ran against a file in 30 seconds can take an hour. And your replica backups don't work. etc, etc.
Maybe you won't hit these issues, but many, many people have. That's why "best practice" now is to avoid MongoDB.
9
u/aradil Jul 20 '15
I would never store sensitive data in a datastore like this. It's only data I already know is available to everyone.
And I'm not using any of the aggregation features of mongodb, not running any sort of reports off of it. It's only being used as a file system replacement with better lookup methods than file names.
I think it has it's place for this sort of use case.
→ More replies (2)
96
u/pirx2691 Jul 20 '15
But it is web scale: http://www.mongodb-is-web-scale.com/
12
u/ifonefox Jul 20 '15
What does web scale mean? Does it literally mean "it scales for the web?" I've only ever seen it used as a joke.
13
Jul 20 '15
It is a joke. It sounds like it means something, but it doesn't. The joke use is the canonical use.
4
u/Vakieh Jul 20 '15
Think about Reddit 10 years ago, serving 100 pageviews a day (a number I made up) compared to now, serving 1,000,000,000 pageviews a day (another number I made up).
'Web scalability' refers to the number of people a web application can serve. Most software serves 1 person per running instance, then you have business intranet software (arguably the replacement for most mainframe applications) which might serve 100ish people. Web applications serve many, many orders of magnitude more, and put stresses on software that originally nobody thought they would have to deal with.
3
→ More replies (2)2
4
u/DPaluche Jul 20 '15
And then at the bottom:
This is not a knock on Mongo DB. I use and really like Mongo DB and would encourage people to check it out as a viable option for production use.
._.
17
u/wolflarsen Jul 20 '15
I remember this!
Came out in the height of the MongoDB hype.
12
u/kazagistar Jul 20 '15
Probably singlehandedly caused the switch from growth to decline.
→ More replies (1)6
→ More replies (1)2
48
u/thoomfish Jul 20 '15
I've got about 100MB of data that exists in a canonical form elsewhere (so I don't really care if the database loses anything, because I can just regenerate it), is only written to once, has a highly polymorphic structure that's difficult to map to relational tables without an ungodly number of layers of indirection, and just needs to be braindead simple to query.
For this narrow use case, I've found Mongo to be satisfactory. I wouldn't use it for anything more serious, of course.
77
u/glemnar Jul 20 '15
To be fair, literally anything is fine in that use case
38
u/thoomfish Jul 20 '15
Anything would be fine, but Mongo is the smallest pain in my ass so it wins.
→ More replies (1)38
Jul 20 '15
cache that shit in memory somewhere. what's the point of a database if it's 100MB of ephemeral data?
→ More replies (5)13
u/argv_minus_one Jul 20 '15
Why not just dump it as BSON or something, and load and index the whole thing on app startup? That doesn't sound like there's any need for a database at all.
8
u/MeLoN_DO Jul 20 '15
I have the same general feeling, but I usually prefer using Elasticsearch (or other search engine) instead of MongoDB. The read throughput, the search capabilities, and the sharding potential is magnificent.
→ More replies (8)6
u/joepie91 Jul 20 '15
PostgreSQL with JSONB can do that just fine, though.
→ More replies (1)10
u/thoomfish Jul 20 '15
Probably so, but this project predates the version of PostgreSQL that introduced that feature.
→ More replies (1)
6
u/joeydee93 Jul 20 '15
As a CS student I took a class on Databases that focused on MySql and other that used sqlite. I was thinking about making a dummy project for fun to use MongoDB just as something different. Sould I use a different NOSQL database?
8
u/THEHIPP0 Jul 20 '15
Haters gonna hate.
MongoDB has some wrong defaults, but if you take some time to read into it you should be fine.
→ More replies (1)3
u/Femaref Jul 20 '15
wrong defaults? Like no write errors and broken design decisions?
Mongo has some specific use cases. The problem is, only a small useful dataset is compatible with mongo, while the rest of the data is relational.
By now, RDBMS can store arbitrary data (e.g. postgres with json/hstore/array field) and so you don't need a separate, not so well understood database.
→ More replies (4)3
u/nutrecht Jul 20 '15
It really depends on what your goal is for that project? I'd recon a project just 'using' any database is too trivial to give you a good grade.
→ More replies (2)
34
u/dccorona Jul 20 '15
I can agree with most of what they're saying there based on the evidence presented to me (never used MongoDB personally), but I don't really appreciate being told that the majority of the time I actually need a relational database. It sounds like they're thinking of a very narrow segment of developers. Literally nothing I do in my day to day would benefit from a relational database over a key-value store, or the other approaches we use to data storage.
25
u/6nf Jul 20 '15
Literally nothing I do in my day to day would benefit from a relational database over a key-value store, or the other approaches we use to data storage.
What do you do day-to-day
35
3
u/dccorona Jul 20 '15
Mostly big data processing and realtime analytics, with a little bit of work for the other end of that (getting that data back out and transformed for display once it's been generated)
→ More replies (2)2
u/holgerschurig Jul 20 '15 edited Jul 21 '15
You don't probably know that many relational databases are ALSO key-value stores. In the case of PostgreSQL even before JSON and JSONB data types you could have used a hstore.
However, they have so much more in their pockets that make them so much more versatily. Especially once your data becomes "valuable" and you want to link (join) it with others.
→ More replies (5)6
u/joepie91 Jul 20 '15
I'm going off "the average developer" here. I'm sure there are specializations where you basically never need a relational database (and that's fine).
→ More replies (14)→ More replies (2)3
u/kamiikoneko Jul 20 '15
well if by very narrow segment you mean an actual pretty huge majority of actual developers building serious, integrity-critical applications, then yeah I agree.
11
u/ArchdukeThe Jul 20 '15
Upvoting because I think MongoDB is a fun toy, but not a great or reliable tool.
But, I hate how developers love writing these extremely black-or-white posts either praising something as your technological savior, or accusing it of giving your career herpes. Any article that starts with "Stop Using", "Considered Harmful", "Never Again", "The Only ___ You'll Need", etc. can fuck off.
7
8
4
u/remimorin Jul 20 '15
I've play with MongoDB a few time. Not my choice, but my mission (do this feature, in this project and ho, the database is mongo). I see a lot a person here saying, I have a case where it went pretty well, and a bunch of reply telling them how they are wrong! Well... I believe them to now more theirs uses case than us. An hammer is a bad saw. A nailer gun cannot do everything an hammer can do. Still, a saw, an hammer and a nailer gun are great tool. But thanks to the OP, I will take a look to other document store before going with mongo!
4
u/rapidsight Jul 20 '15
Is it just me or is this JS fad just repeating history. These problems have been understood since 1970.
2
u/PaXProSe Jul 20 '15
We have an old Oracle guy in our shop, its fun to hear him express his opinion on noSQL DB's. They often lead off with this statement.
4
u/_pennypacker Jul 20 '15
mongodb is great for publishers and large news sites. you can save articles in mongo and that is the ideal because articles are really documents. publishers usually do comments with third parties anyway. if you need to do a user auth system with it just do it in sql separately. you need to keep user auth db separate from news articles anyway. and that is how you serve millions of pageviews per day without spending too much resources.
if you are using mongodb in a bank then u deserve to get robbed. it is not mongodbs fault that you are dumb. you need to know the strengths and weaknesses of every tool you use and make smart choices.
13
16
u/k-bx Jul 20 '15 edited Jul 20 '15
Author lists a bunch of past or present bugs of MongoDB as a reason to not use it. I agree, it might be important for your database to be rock-solid, so if the last thing you want is problems due to bugs in database – don't try new stuff.
Postgres is 19 years old, MongoDB is 6. Just look at the list of bugs PostgreSQL fixed since 2002 and tell me there weren't many or major ones.
And one more thing! I don't understand why author is missing the MAIN points of using MongoDB at all:
it has sharding
it has replication
it has failover
due to schemaless data-storage – it has schema-migrations with zero-downtime (handled by client-side)
I don't understand how can you compare PostgreSQL vs MongoDB, as I don't see PostgreSQL having these three things (in a "usable" form, sorry for this term), which are the main points of using it. So if you are actually choosing which one to use – you ARE doing something wrong (and should use PostgreSQL if it fits your use-case, yes).
Update: I created a separate poll-topic to discuss all common solutions: please do participate! https://www.reddit.com/r/programming/comments/3dx5j3/poll_people_who_prefer_postgresql_to_mongodb_how/
→ More replies (6)5
Jul 20 '15
Holy shit, are we really referencing bugfixes from 13 years ago to make a point? If it was a few years ago it may be relevant, but god damn.
2
u/k-bx Jul 21 '15
My point was that MongoDB is young, and post from this topic mostly lists its issues that were resolved already. There are few unresolved with replication which are pretty bad, but once again, author doesn't even lists what he uses for replication in PostgreSQL (probably nothing?).
17
Jul 20 '15
Should I be worried if I just wrote an entire startup to use Mongo?
26
u/kristopolous Jul 20 '15
Should I be worried that I've had it up and running in production systems with millions of hits a day, running for years, and without a single issue??
→ More replies (5)27
u/orangesunshine Jul 20 '15
I've had fantastic success with MongoDB.
... in large sharded clusters it performed better than our SQL implementation by several orders of magnitude. I'm talking about full benchmarks of the application, where we tested 50+ API calls on both systems.
It was also a fantastic tool when it came to coding and flexibility from a development perspective. Once we put systems/code-standards in place it provided a great platform for our developers to get things done quickly and effectively ... and with a performant result.
One of the most important things is setting up tools for your developers to keep track of the schemas, ensuring consistent implementations across API's, and different documents, etc.
We used a python tool that ensured schema consistency ... allowed us to consistently migrate data ... etc. This is perhaps the biggest benefit with a large application and data-set though. If you have to do a large-scale migration with a traditional SQL database you are required to essentially shut the system down while you migrate all of your data at once.
We setup our MongoDB systems to perform migrations on the fly. So if we had a change in our data structure in a document the changes weren't done to every row/document in one fell-swoop.
Rather we would setup our ORM/driver-thingy to only modify a document when it was accessed by a user. To achieve this with SQL you'd end up with multiple columns and lots of redundant or inconsistent data ... generally with SQL though "best practice" has you doing a data migration which with a large-scale cluster means you have significant down-time.
Rethinking the process for MongoDB allowed us to do massive migrations dynamically or on-the-fly ... restructuring data for efficiency/optimizations that would really not have been possible with a traditional database after launch.
The problem most of these folks on reddit encountered was that they expected it to be magic and just work for what-ever their use-case may have been without any effort, skill, or talent.
It's like any other powerful tool though ... you really need to take the time to understand how to take advantage of it ... make the most out of it ... etc.
If you understand how it performs you can really get some great speed out of it ... and understand how to structure your data/API's and you can create an extraordinarily efficient application backend from a development perspective ..
It's not without effort on the part of the engineer ... though if you're a capable engineer ... it is really one of the best databases out there. The sharding mechanism is phenomenal ... and really something you can't achieve at all with SQL which always has me laughing when "reddit" tries to tell me how MongoDB fails at scale, but postgres is super easy and fantastic.
→ More replies (15)→ More replies (30)32
11
u/oconnor663 Jul 20 '15
This article makes so many claims with so little detail. I liked this one a lot better: http://www.sarahmei.com/blog/2013/11/11/why-you-should-never-use-mongodb/
→ More replies (5)
3
u/DVWLD Jul 20 '15
If you find yourself using Mongoose, you should also be using a relational database. Libraries like Mongoose just try to (poorly) emulate schemaful relational databases using a document store, so you might as well just use a relational database directly!
1000 times yes.
8
Jul 20 '15 edited Jul 20 '15
MongoDB is absolutely fantastic for rapid prototyping and development. I'd never use it in production though.
→ More replies (2)18
u/oxymor0nic Jul 20 '15
I agree. But the problem is that once you use it for prototypes & dev, you have this technical debt that pushes you towards adopting it for production, too.
→ More replies (2)4
u/numinit Jul 20 '15
I think understanding Mongo's place is important.
I can throw stuff at Mongo and it sticks.
If I want to engineer a real solution for storing my data, I'll look at my data first before choosing a DB to store it. That solution may or may not be Mongo. It all depends on the data, the volume of data, and the consistency requirements (e.g. locking, which Mongo is terrible at) for the data.
→ More replies (2)
7
Jul 20 '15
Why do people upvote these "Never ever use (popular technology)" blogs? Its just clickbait. They are never well written or well thought out or even somewhat productive.
→ More replies (1)
6
Jul 20 '15
The best artifacts in programming came from actual scientists who knew the mathematics behind their creations. This sort of mess happens when people start divorcing programming from mathematics. Sure, creativity is the very essence of a field like programming, but one should not forget that the very heart of that essence is solid mathematical rigour.
→ More replies (11)
7
u/kristopolous Jul 20 '15 edited Jul 20 '15
There's quite a few "this didn't work like something it explicitly isn't" kind of posts lately.
He basically complained about partitioning and eventual consistency in 5 different ways.
Mongo and postgres are as interchangeable as imagemagick and opencv or php and matlab ... They are the same superclass of software but they aren't directly comparable and once you start looking for the features of one inside the other you are going to of course conclude that it's not a good mapping.
Might as well compare MySQL to memcache or apc while you're at this or heck, bdb to neo4j ... How silly.
→ More replies (6)
2
u/sup_reddit Jul 20 '15
I swear I read this article 3 years ago. Why is anyone still writing about MongoDB?
2
u/mattyw83 Jul 20 '15
As always don't pick your DB based on a blog post, good or bad. Think about your data, how it will be written/ read and take some time to learn about how your database deals with different failure scenarios. Then make an informed decision.
2
u/chisleu Jul 20 '15
I didn't read the article. I don't have to. I hope you read the article though. MongoDB is like crack. It is really easy to get hooked on, but it ruins your life.
2
u/losingthefight Jul 20 '15
I have been using MySQL since 4.x and have used Mongo for about 5 years now. IMHO, it all boils down to use case and lifecycle. The use case argument has been beaten to death, so I will move past it. One of the benefits of NoSQL servers, at least that I have found, is that they are relatively cheap to get off the ground. For example, if I am starting up a new project and really don't want to have to worry about my database going down, I would look for a hosted solution. As far as I have been able to find, hosted NoSQL solutions are far cheaper than hosted relational systems. There is a similar story behind backup (see: MMS for Mongo).
Sure, ultimately having the data in relational data store may be helpful, depending on use case, but if I don't have the money or expertise to deal with correctly managing a relational store early in a project, I may never get to that point.
Now, if hosted RDBMS's become cheaper / more popular, my opinion could surely change.
2
u/geodebug Jul 20 '15
TL;DR - Mongo DB is bad, if you don't believe me go research it for yourself.
Um, thanks for the opinion I guess
For most cases, what you want is actually a relational database.
That's quite a logic jump. Relational databases are a good choice for many use cases, NoSQL excel at other use cases, many times you use a combination of both.
2
u/joelanman Jul 20 '15
If you're prototyping, you're supposed to throw it away. So the point about not using it to prototype doesn't really stand.
→ More replies (2)
2
u/mage2k Jul 20 '15
If your project involves user accounts, or any kind of relationship between two records, then you should use a relational database, and not a document store - after all, your data is relational.
Ugh, no. The term relational as it applies to relational databases, with the term relational coming from relational calculus, applies to relationships between attributes within a single record. The table/view/result-set is the relation.
Note: I am not saying this in defense of using MongoDB as I completely agree that it's much more trouble than it's worth.
2
u/mdedetrich Jul 21 '15
To be fair, although some of the complaints are legitimate, others are not (due to it being a specific design issue)
As an example, MongoDB not being ACID is not really a negative because MongoDB never claimed to be ACID. Likewise the point about implicit schemas isn't really a negative since MongoDB is designed to be a document, not relational, store. The other complaints are however very legitimate.
Honestly, MongoDB 2.x should have been MongoDB 1.x, they should have never released MongoDB 1.x. MongoDB 1.x was of beta quality (if that)
Personally my biggest issue with MongoDB is its really bad at horizontal scaling, either in terms of performance or how hard it is to deal with MongoDB's sharding/clustering mechanism. I only use MongoDB for one thing, and that is storing web session state (and arguably, Redis/Memcached are just as good for that role).
2
7
u/Maristic Jul 20 '15
As I recall, we knew most of this in 2010.
14
u/TrixieMisa Jul 20 '15
MongoDB sucked in 2010. Now it's pretty good.
If you know what you're doing. If you don't know what you're doing, every database will suck.
→ More replies (1)
4
u/theonlylawislove Jul 20 '15
I'm using it on a low-powered embedded system. Super lightweight, minimal resources, really fast.
I don't know about large scale, shared environments though. But for small embedded systems, its a big win.
9
u/joepie91 Jul 20 '15
There's quite a few other options for that. SQLite is one example.
→ More replies (25)
4
u/jzuijlek Jul 20 '15 edited Jul 20 '15
I did my first project, an online trading game, with MongoDB. We had zero issues during development or production (3 server replica set). It had lots of 24x7 jobs running to (re)calculate the users portfolio value.
As a developer I LOVE not having to deal with SQL and can use MongoDB natively in my code (CFML/Lucee).
If you use it ignorantly, and don't read up on things like write consistency, you are a bad developer. And sharding is a bigger challenge with PostgreSQL.
3
u/skatan Jul 20 '15
Shouldn't a project, that focuses on relationships between records, use a graph database?
3
u/Ace-O-Matic Jul 20 '15
To quote myself from about a week ago: "What the fuck do you mean there's a read lock!?"
Seriously though. The only reason we even use Mongo is cause you pretty much just dump a JSON into it and it's all guuchi. Even then we have to use it concurrently with Reddis or else shudders.
3
u/ellicottvilleny Jul 20 '15
This is typical. I could write an article about how Relational Databases in general, especially ones using SQL, are terrible, from the perspective of a 1970s developer who is unwilling to give up his BTrieve system. There are many fundamental failures to understand the goals and the application domains where MongoDB is applicable. Not every CRUD app you write needs NoSQL, and if you're incapable of imagining the kinds of architectures that NoSQL databases enable, you're right, YOU should never ever use one. The operant word here is YOU. Not the DB in question. Yes MongoDB has bugs. I don't use it myself, but I see a general problem with whiny blog posts like this one that don't even bother to understand the NoSQL domain before rejecting all Implicit Schema systems, and all non-relational systems, as somehow fundamentally FLAWED rather than NOT THE RIGHT FIT FOR YOUR APPLICATION DOMAIN, which is an entirely different matter.
2
u/vivainio Jul 20 '15
I bet it's more common for people to mistakenly assume their data can't be reasonably (or 'easily') represented in relational fashion
2
u/ellicottvilleny Jul 20 '15
I encounter the It's New, Let's Fear It and Villify it much more frequently than I encounter the I Can't Touch That Old And Uncool Technology Anymore, It's Not Cool Enough for My Level 11 Awesomeness attitude. Your experience may be different than mine.
3
u/Cacodaimon Jul 20 '15
Here is a simple form for building your own "Why you should never…" blog posting.
Why you should never, ever use X.
Because Y is faster than X.
X does not support F, Z does.
B has better default settings.
I'm using A for more than 10 years, X is not even 5 years old.
C and D can do the same.
X had security issues. …
End your post by underpinning your opinion with the following sentence: **I read this and this post from guys which says the same. **
4
u/chotch37 Jul 20 '15
Author raises some good points but didn't even cover a major feature of MongoDB - Aggregation. Sure, this year there are few products out there that claim to do agg, but a couple years back, Mongo was pretty much the only game in town that could do it well.
24
u/joepie91 Jul 20 '15
This point was raised to me by somebody else in the past, but they were unable to explain how it was any different from the SQL operations offered by major RDBMSes (incl. stored procedures).
Perhaps you could clarify on that?
EDIT: I'm the author, by the way :)
→ More replies (10)
3
u/tRfalcore Jul 20 '15
I just can't believe anyone fell for using bullshit databases for anything other than read only type stuff.
For some of our read only type shit we were thinking of using mongo for we got MSSQL up to like 98% the same speed so we were like whatever that's fine.
2
u/AdamGartner Jul 20 '15
I know this might be a 'duh' for a No-SQL database, but it's a god damn pain to mess with foreign keys in MongoDB.
2
u/terrible_ramblings Jul 20 '15
I wouldn't say it not being ACID compliant is a reason its evil, sure its not ideal for some use cases, but that doesn't make it a bad database
4
u/Radmonger Jul 20 '15
True: there are 4 to 5 other reasons it is a bad database, as listed in the original article, and all the other similar ones.
To be fair, it can be a mediocre cache.
2
u/Nijikokun Jul 20 '15
Basically people telling other people not to use a database because it doesn't do what they want it to do rather than using it the way they should.
2
2
u/matjam Jul 20 '15
Us crusty old engineers look at this stuff ... think ... "maybe, lets see how it is in 10 years time" ... and stick to using postgresql.
Oh, look, it didn't even reach 10 years.
→ More replies (1)
1
1
u/Torandi Jul 20 '15
We used MongoDb as a prototype backend to a project. It was never the intention to use it in production, and we later replaced it by the real backend. But it was pretty handy as a prototyping tool. I guess the title should be "never use MongoDb in production".
→ More replies (2)
1
u/Wouter10123 Jul 20 '15
Oh... I just started learning about it yesterday, because it seems at play nice with nodejs. Does anyone have any other suggestions to use?
1
u/thebezet Jul 20 '15 edited Jul 20 '15
I've used it for a medium sized project, and it was "okay". Haven't had any issues, other than memory problems at some point due to indexing that wasn't setup efficiently. Had a bunch of replica servers, did not experience any data loss.
Having said that I would be worried about using it for a bigger project.
EDIT: Also, whenever I read an article titled "You should never use X", I roll my eyes… There are situations where you would want to use it.
1
u/santiagobasulto Jul 20 '15
What's the state of CouchDB? I remember looking at them both 3 years ago (when all the hype was starting) and I liked Couch better than Mongo. I really liked the REST interface. But now it seems that the popularity has decreased.
1
1
u/nirataro Jul 20 '15
Can we actually reflect and learn from this MongoDB debacle? MongoDB was everything 3 years ago and now it is a piece of shit. Well let's see what is the hype right now and consider whether they will be in the same predicament in three years time.
1
u/revonrat Jul 20 '15
I use Cassandra a lot. I don't have experience with Mongo. However, my experience has been, if you don't need the NoSQL scaling, don't use NoSQL. Relationals are much nicer to deal with on almost every level except, the oh-crap-I-need-a-multi-petabyte-at-scale database use case.
1
1
u/a_sleeping_lion Jul 20 '15
Im a fan of RethinkDB, which is kind of a mix between a relational database and a json document object store. Though I have yet to deploy it in a true production environment, a core part of its design is easy scaling with clusters and autosharding. Graphing databases are also quite interesting; but of course mysql/postgres are great solutions for almost any application .
1
u/mcgrotts Jul 20 '15
I need to work on a database to store json, I was thinking of using mongodb but not any more. Does anyone have any suggestions on what I should do instead? I think postegre looks good.
1
1
u/jfwam Jul 20 '15
Next week I was going to do a presentation on why should we use MongoDB in our next project. Now I'll have to redo most of my slides ;)
→ More replies (1)
1
1
43
u/grendel-khan Jul 20 '15
I think my favorite MongoDB story was the one where because someone didn't understand some really basic concurrency issues, bank robbers made off with more than a half-million dollars. This wasn't exactly a problem with MongoDB, but it was a problem with someone using a technology they didn't understand and expecting it to do something it was never designed to do, and it led to an actual bank robbery.
The author blames MongoDB for offering a bad API, but he does have his own axe to grind. (He writes his own NoSQL database, which offers features which would have solved the particular problems on display here.)