1562 points · by philliphaydon · 7y ago · 417 comments
Great read. Well done.
> Digital Blog
> A blog by the Guardian's internal Digital team. We build the Guardian website, mobile apps, Editorial tools, revenue products, support our infrastructure and manage all things tech around the Guardian
Guess it makes sense to reuse the platform that already has the templates than use another platform and reimplement the design.
Well done and congratulations to everyone on the team.
In most early stage startups, that would be an unacceptable loss of time.
So I don't judge them for doing a one-shot migration even if it causes an hour of downtime.
It all depends on the business.
Another team at the guardian did a similar migration but went for a 'bit by bit' approach - so migrating a few bits of the API at a time - which worked out faster, in part because stuff was tested in production more quickly, rather than our approach with the proxy which, whilst imitating production traffic, didn't actually serve Postgres data to the users until 'the big switch' - so not really a continuous delivery migration!
Part of my duties at work require me to deal with "large" issues. While a solution to them is usually necessary and quick and high quality, I've seen the analyses that come after them vary in quality.
Good writeups tend to stick around in people's memories and become company culture, and drive everyone to do better. Bad writeups are forgotten, and thus the lessons learned from them are forgotten as well.
This particular article stands out for me. English is not my first language, and I've spent most of my life dealing with very fundamental technical details, so most of my writeups aren't the best. I'm going to bookmark this one and come back to it to learn how to write accessible technical narratives.
I like the article but it was a bit hard for me to consume with multiple voices in different parts.
We accured lots of downtime due to mongo.
But later versions were rock solid and I've matainer mongo installations at many startup and SMEs once you setup alertd for disk/memory usage, off you go. Works like charm 99% of the times.
Not that that's really a surprise or was unknown, it's just fairly new to see in the open source ecosystem instead of the enterprise one.
SQL has decades of production maturation, and has wider domain knowledge.
Unfortunately the number of my customers who would sign off on just "two nines" is approximately zero...
https://www.mongodb.com/customers/guardian
https://www.mongodb.com/presentations/mongodb-guardian
https://www.slideshare.net/tackers/why-we-chose-mongodb-for-...
And reupping my previous, three-part series on MongoDB:
On MongoDB
NoSQL databases were the future. MongoDB was the database for "modern" web engineers and used by countless startups. What happened?
IMO, the reason is that newer developers faced the choice of learning SQL or learning to use something with a Javascript API. MongoDB was the natural choice because they excelled at being accessible to devs who were already familiar with Javascript and JSON.
Not only that, their marketing/outreach efforts were also aimed at younger developers. When was the last time you saw a Postgres rep at a college tech event?
> 10gen's key contributions to databases — and to our industry — was their laser focus on four critical things: onboarding, usability, libraries and support. For startup teams, these were important factors in choosing MongoDB — and a key reason for its powerful word of mouth.
Startup Engineers and Our Mistakes with MongoDB
https://www.nemil.com/mongo/2.html
The Marketing Behind MongoDB
Marketing, marketing, and more marketing. Mongo was written by a couple of adtech guys.
> Not only that, their marketing/outreach efforts were also aimed at younger developers. When was the last time you saw a Postgres rep at a college tech event?
I remember being underwhelmed by two things at the one MongoConf I went to earlier this decade:
1.) My immediate boss was an unfathomable creep who was there mostly to pick up women
2.) Mongo was focused on how to work around the problems (e.g. aggregate framework) rather than how to solve them.
I can't recall ever seeing a Postgres rep, but I can recall having worked out a PostGIS bug with a fantastically tight feedback loop. The Postgres documentation and community are nothing short of amazing.
Meanwhile with Mongo I watched as jawdropping bugs languished. IDGAF what the reps say, anyone with even a few years experience should've been able to see through the bullshit that Mongo/10gen was/is selling.
The thing I dislike about this type of comment – although I now notice yours doesn't explicitly say this – is the implication that devs don't like SQL because they're lazy or stupid. Well, sometimes that is probably true! But there are some tasks where you need to build the query dynamically at run time, and for those tasks MongoDB's usual query API, or especially its aggregation pipeline API, are genuinely better than stitching together fragments of SQL in the form of text strings. Injection attacks and inserting commas (but not trailing commas) come to mind as obvious difficulties. For anyone not familiar, just look at how close to being a native Python API pymongo is:
pipeline = [
{"$unwind": "$tags"},
{"$group": {"_id": "$tags", "count": {"$sum": 1}}},
{"$sort": SON([("count", -1), ("_id", -1)])}
]
result_cursor = db.things.aggregate(pipeline)
Of course you could write an SQL query that does this particular job and is probably clearer. But if you need to compose a bunch of operations arbitrarily at runtime then using dicts and lists like this is clearly better.Of course pipelines like this will typically be slow as hell because arbitrary queries, by their nature, cannot take advantage of indices. But sometimes that's OK. We do this in one of our products and it works great.
With JSONB and replication enhancements, Postgres is close to wiping out all of MongoDB's advantages. I would love to see a more native-like API like Mongo's aggregation pipeline, even if it's just a wrapper for composing SQL strings. I think that would finish off the job.
# Query all rows in the "users" table, filtering for users whose age is > 18, and selecting their name
"users"
|> where([u], u.age > 18)
|> select([u], u.name)
# Build a dynamic query fragment based on some parameters
dynamic = false
dynamic =
if params["is_public"] do
dynamic([p], p.is_public or ^dynamic)
else
dynamic
end
dynamic =
if params["allow_reviewers"] do
dynamic([p, a], a.reviewer == true or ^dynamic)
else
dynamic
end
from "posts", where: ^dynamic
Across all the different means of interacting with a database I have experience with (from full-fledged ORMs like ActiveRecord, to sprocs in ASP.NET), I've found that it offers the best compromise between providing an ergonomic abstraction over the database, and not hiding all of the nitty-gritty details you need to worry about in order to write performant queries or use database-specific features like triggers or window functions.My main point, though, is that you don't need to reach for NoSQL if all you need is a way to compose queries without string interpolation.
You're using the Pymongo library as an example. Someone can just as easily use SQLAlchemy and not have to worry about those things.
Every language I know of has great ORMs which do this for whatever SQL flavors people tend to use on that platform. I write things like this all the time, and it gets turned into SQL for Postgres:
```` Article.where(author_id: 37).order(:modified_date, :desc).where.not(published: false) ````
When using an ORM correctly (and indeed, the less I'm using any of my own bits of SQL the more this is true) I am also protected against injection attacks.
I'm not saying NoSQL has no value, but I believe it to be the wrong tool for data that lends itself to an RDBMS. If you have a bunch of documents who have deeply nested or inconsistent structures and where it makes no sense that you'd want to query by something other than the primary key, sure, it's a no-brainer to use a NoSQL system. For a CMS, which has been implemented thousands of times in RDBMSs, it is madness though. I cringe at realizing that apaprently there are developers out there who have avoided learning SQL entirely in their career out of fear, and as a result have to use Mongo for every application because that's the only thing they know how to do. I'm sure they're out there, but I wouldn't hire one.
At my company we built a UI on top of Slick that lets users of our web app define complex triggers based on dynamic fields and conditions which are translated to type-safe SQL queries.
- Misunderstanding by most developers of the relational model (I heard a lot of blathering about 'tabular data', which is missing the point entirely).
- The awkwardness and mismatchiness of object-relational mappers -- and the insistence of most web frameworks on object-oriented modeling.
- The fact that Amazon & Google etc. make/made heavy use of distributed key-value stores with relatively unstructured data in order to scale -- and everyone seemed to think they needed to scale at that level. (Worth pointing out that since then Google & Amazon have been able to roll out data stores that scale but use something closer to the relational model). This despite the fact that many of the hip NoSQL solutions didn't even have a reasonable distribution story.
- Simple trending. NoSQL was cool. Mongo had a 'cool' sheen by nature of the demographic that was working there, the marketing of the company itself.
I remember going to a Mongo meet-up in NYC back in 2010 or so, because some people in the company I was at at the time (ad-tech) were interested in it. We walked away skeptical and convinced it was more cargo-cult than solution.
I'm _very_ glad the pendulum is swinging back and that Postgres (which I've pretty much always been an advocate of in my 15-20 year career) is now seeing something of a surge of use.
Is a Postgres rep a thing?
PostgreSQL looks scary because it is a swiss army knife. It has a million different features and data structures. MongoDB does only one thing.
I do remember a lot of MongoDB t-shirts, cups and pens around every office I was in around 2011-2013. When I would ask they would tell me that a MongoDB developer flew halfway across the world to give them all a workshop on it.
Ability to store Algebraic Data Types and values with lists without a hassle of creating a ton of tables and JOINs. Postgres added JSON support since, plus there are now things like TimescaleDB, which didn't exist previously.
ORMs have existed for decades so developers can use a SQL database just fine without knowing the language. So it's definitely not this.
It's more likely because Mongo is (a) is extremely fast, (b) the easiest database to manage and (c) has a flexible schema which aligns better with dynamic languages which are more popular amongst younger developers.
Mongo literally has no upside vs postgres.
One of the biggest and most expensive was using Cassandra to store membership details. Something like 4 years of work, by a team of 40, wasted by stupid decisions.
They included: o Using Cassandra to store 6 million rows of highly structured, mostly readonly data
o hosting it on real tin, expensive tin, in multiple continents (looking at >million quid in costs)
o writing the stack in java, getting bored, re-writing it as a micro service, before actually finishing the original system
o getting bored of writing micro services in java, switching to scala, which only 2/15 devs knew.
o writing mission critical services in elixir, of which only 1 dev knew.
o refusing to use other teams tools
o refusing to use the company wiki, opting for thier own confluence instance, which barred access to anyone else, including the teams they supportedStep one was hire everyone the guy had worked with at his previous company. They were all winforms / excel / SQL / sharepoint / office developers from big finance and had no idea where to go really. None of them had even touched asp.net.
Cue "what's popular". Well that was Ruby on Rails back then on top of MySQL and Linux. 4 people with zero experience pulled this stack in and basically wrote winforms on top of it. Page hits were 5-8 seconds each. Infrastructure was owned by SSH worms and they hadn't even noticed.
I think I lasted two days there before I said "I'm done".
“The computer industry is the only industry that is more fashion-driven than women’s fashion.” — Larry Ellison
I suspect that in a year I’ll be using what is effectively an Elisp machine with an Apple logo paired with an iPhone.
The real driver of the NoSQL movement, I believe, was that everybody wanted to be the next big social network or content aggregation site. Everybody wanted to be the next Facebook, Instagram, Twitter, etc. and that's what people were trying to build. Ginormous sites like these are are one of the applications that strongly favors availability/eventual consistency over guaranteed consistency, whereas most other applications are quite the opposite.
Nobody really cares if your Instagram post shows up 10 minutes later in New York than it does in LA, and certainly not if the comments appear in similarly inconsistent order. It's one step above best-effort delivery. However, your bank, hospital, etc. often care quite a bit that their systems always represent reality as of right now and not as of half an hour ago because there's a network problem in Wichita.
The question is, "If my data store isn't sure about the answer it has, what should it do?" RDBMS says, "Error." NoSQL says, "Meh, just return what you have."
Speed to market/first version using JSON stores is attractive, especially when you're still prototyping your product and won't have an idea of exact data structures until there's been some real world usage.
Which is why MongoDB is awesome for teaching and building new stuff but horrible for reports, metrics, and scaling.
Also, I think MongoDB tried to be everything and failed to be good at anything. It offers neither stellar performance nor scalability and I guess for most projects there is not much advantage over regular SQL database. Certainly nothing to fight over when there is much more technology choices to make.
Another example is "Agile". Everybody is doing it yet I still wait to see a single company that understands what the term means. My current boss is big promoter of "Agile" which in his language is synonym to "Scrum". Yet when asked he has never heard of Pheonix Project, The Goal, theory of constrains or basically any theory at all. So what the people are doing is fighting fires almost 100% of the time with not much project work done for the effort and absolutely no improvements. Yet, because everybody complies to do daily standups and Jira updates we are 100% agile.
Don't even get me started on devops...
Text and still imagery based media companies aren't big data providers. NoSql was a bad choice from the start.
On the server front that means ever increasing complexity with decoupled microservices and latency issues that play nicely with the classic approaches to those domains (static typing, functional programming).
On the data front sites like HN, Reddit, or Facebook need scability more than consistency, and have oodles of 'uninteresting' data that jives nicely with a schemaless document store.
It's interesting because I feel like the NoSQL world spent a lot of time reinventing the RDBMS from the "opposite direction". For all its faults, SQL is a fascinating language because it mostly ignores low level details of how the database scales, how it operates under the hood. It's not that SQL is intrinsically hard to scale (certainly at the relational algebra roots it shouldn't be hard, in theory), but it certainly leaves a lot of work to anyone building a database engine to figure out what/when/why/how to scale. I feel like a lot of RDBMS' query analyzers/planners resemble things like HBase a lot more than folks realize.
It's great that NoSQL realized that sometimes those "low level details" in an SQL engine are useful in their own ways, and have increased the spectrum of performance versus power/flexibility trade-off options. But it shouldn't be that big of a surprise that SQL databases remain competitive in that trade-off space, given under the hood they've had to think about a lot of that stuff over many decades.
They used the version of OpsManager that doesn't manage the deployment - is specifically not a deployment manager. Mongo does offer a managed version of this software, which the author mentions - with a justification for why they couldn't use that offering. However, I think this was the main mistake that The Guardian made. As the author notes: "Database management is important and hard – and we’d rather not be doing it ourselves." They underestimated the complexity of managing database infrastructure. If they had been attempting to set up and manage a large scale redundant PostgreSQL system, they would have spent an enormous engineering effort to do so as well. Using a fully managed solution - like PostgreSQL on RDS from the beginning would have saved them time. Comparing such a fully managed solution to an unmanaged one is an inappropriate comparison.
Full disclosure - I used to work at MongoDB. I have my biases and feelings w.r.t the product & company. In this case I felt that this article didn't actually represent the problem or it's source very accurately.
Re criticism of OpsManager - I think this is fair, given the sheer number of hoops we had to jump through to get a functioning OpsManager system running in AWS - no provided cloudformation, AMIs etc. £40,000 a year felt like a lot for a system that took 2 or more weeks of dev time to install/upgrade. The authentication schema thing was a bit of a pain as well, though we were going from a very nearly EOL version of Mongo (2.4 I think).
That sounds awful. Reading these stories I'm happy I work with small companies without such a huge infrastructure.
Training is exceptionally hard. Databases are hard to manage, and it takes years to learn to diagnose their function on unknown hardware / software.
This all being said, "no provided cloudformation, AMIs etc." is no bueno - not a good experience for the user.
If you haven't used Mongo with WiredTiger, you really haven't used it at it's best.
> Clocks are important – don’t lock down your VPC so much that NTP stops working.
> Automatically generating database indexes on application startup is probably a bad idea.
> Database management is important and hard – and we’d rather not be doing it ourselves.
This is true of any database infrastructure with redundancy/scalability requirements.
What they did was take a technical problem and solve it by buying an off the shelf solution. Which is fine, of course, but I’m a bit surprised by the reaction here on HN.
I work for MongoDB so if you have any questions about storage, feel free to reach out.
One major change is that in 2010 you couldn't always run your whole DB in RAM, so there were some real performance benefits with MongoDB.
Another difference is that MongoDB was early with great JSON-support. Something that Postgres has since gained.
I think there are pros and cons with both. If I'd chose one today, for most tasks I'd probably chose Postgres.
That said, to understand why people made those choices, you need to 'teleport back' to that time and compare them in that year (given the tradeoffs at that time).
I worked with databases that only had table level locks(not row level) and there were more than enough occasions I cursed the creators.
Instance level(& indeed DB level) is insanity unless your DB is a read only DB.
They have very few write actions; in the Guardian's case hundreds of authors publishing a few articles a day, versus millions of users reading data. Writes would be sporadic and batched.
News products also changes more rapidly than you might expect. A modern news team may be writing and shipping code to better cover a breaking news event. I can imagine why a document store would be appealing to them.
For another, it may be everyone is susceptible to the influence of trends. Even engineers. And the more complex the details of a subdomain of software engineering are, the bigger the tradeoff between becoming someone who can make a true engineering assessment in that niche and developing expertise elsewhere...
Further, most of the use cases are fairly shallow, so it doesn't actually matter that much, and you'll be paid more to paper over the cracks.
We need to change the market, but it doesn't like the strong and stable engineers are getting lead roles to pay more strong and stable engineers to build boring tech, despite that actually being better for most businesses.
the whole promise of mongo is/was distributed (HA+LB), which was all the rage back then, when AWS AZs dropped like flies every few weeks and scaling was seen as the problem. go fast, break things was the mantra.
and it's still not trivial to do pgsql maintenance without downtime, whereas in a clustered/distributed "solution", you can enjoy certain additional freedoms. this includes the freedom to shoot yourself in the foot (data inconsistency, but you had to fight a bit for that state by promoting a non latest slave to master).
Review driven design is likely a large contributer. If you know you will be looking for a new job in 2 years, you better get some experience in $latestTrend instead of $provenTechnology.
I now use json supported functions in SQL Server and do not have the need for a different type of database. SQL Server handles my small 'documents db' implementation with the infrastructure of a RDMS. Win win for me.
To me Mongo just got popular by mistake way too early. It's like having a celebrity retweet your post because they liked what they saw at the time, exposing you to the world where everyone now thinks you have something important to say. Not surprisingly, you don't!
I don't see how Mongo was built based on Postgres, either?
As an aside, I did consider using SQL Server until I looked at the licensing fees. Why would someone choose SQL Server when options like Postgres or MySQL/MariaDB exist? Is there a specific SQL feature (MSSQL or Oracle SQL) provides which is not available elsewhere and would be a core feature which the companies data storage is built upon? I.e. that feature is so important that the companies product architecture would be fundamentally different without using the proprietary database.
Outside of my professional career, with my personal projects I use SQLite, but if I were to build out something that intended to be larger scale business venture, I'd probably go with Azure SQL Database for multiple reasons. A large one being MS's overall integration, including their full control of the stack and CI/CD with .Net->Azure DevOps->github->Azure Pipelines->Azure PaaS/SQL Database. I admire what they're building, but a lot of people work outside of the MS realm. Companies don't tend to have a tech stack bone to pick as we do on HN, and many are already using part of the MS stack.
In sum, there's just a lot of business realities at play. I wouldn't personally run out and buy a SQL Server license myself, for what I do at home or with my (very) small side business, either.
Dealing with one vendor, M$, is better than dealing with 20. You pay for one support package and get all the benefits that come with one platform.
As much as I love open source, I do see the benefit of working with one vendor on all of your stack needs.
M$ reporting systems of SSRS SSIS and other is probably their bread and butter when it comes to DB space. Very few want to spend 60-70 hours a week building complex command line reports where with SSRS and SSIS most of these tools come with a nice GUI that helps you build these reports. Sure there are others that do the same but most required a third party vendor to add to the functionality. For example Apache. With Java and Apache I've had to deal with literally 15 to 20 different vendors just to do the same thing I can do with one vendor. Jenkins, Zookeeper, Camel, Cassandra, Tomcat all under the banner of Apache, but in reality governed by their own set of standards. I mean take a look for your self: https://www.apache.org/index.html#projects-list
Because they're in an organization where they're already invested in Microsoft technologies, so it's much easier to just use MS's DB instead of something entirely different that doesn't integrate as well.
It's similar to why many people use Apple software products that aren't as good as alternatives: if you already have an Apple platform/device, it's easier and better integrated and likely already installed.
1) MongoDB Atlas would work well here: it’s Mongo hosted on a cloud provider of your choosing managed by the people that make it.
2) a DBA, even a noSQL one*, is worth every penny. (I don’t mean this to put down noSQL DBAs just that it’s good to have someone dedicated to managing them and that a DBA versed in the administration and upkeep of a relational system could retain pretty quickly to help get the most out of a noSQL one)
A few things stood out at me. In no particular order:
- Going with Mongo in the first place cost them dearly. CMS are a weird application for schemaless. Not necessarily wrong, but definitely weird. I wonder if they would benefit from moving to more structured schema and I'm willing to bet a lot of the migration complexity comes from that in the first place.
- God damn that is a long migration. Holy shit. I know tech isn't their core competency but they do seem to have very competent staff. I've worked in places this glacially slow and I get how it can get this bad but it really strikes me as having no right to be. 10 months to migrate .... from the point where they were ready, until they were done. And somehow integration tests got overlooked during all that.
- Close call with dynamodb. Bit of a wtf on waiting for the feature to be implemented for nine months though. I'm sure they have an account manager with aws... I definitely think blocking an internal process on such a fragile externality as a closed process upstream publishing a feature is the wrong move and a red flag. Their migration path would have probably been harder with dynamodb too.
- I feel the pain of their troubleshooting issues on the load testing step. I can completely see how this can happen. That said it also raises a few red flags to me. Letting something as simple as the load testing step get complex enough to require weeks of engineering is ... Eh.
Have more thoughts but I hate typing on mobile. This is a fantastic write up, I love when non-tech companies publish this sort of stuff. And hurrah for postgres.
That depends. If the CMS is managing documents that have flexible structures that are tree-like, it might not be such a horrible idea to model that structure in a document instead of relationally.
C = Actual content to be published
MS = User accounts, user permissions, user authentication options, user authentication logging, meta change logs (user X removed tag Y at time Z), behaviour logs (user X viewed revision Y of article Z at time A)... and that's just scratching the surface of a very, very basic CMS.
I'm being generous and assuming articles, tags, bylines, and attached media (with full change history) is all "C".
I am saddened by many of the comments here though which equate to: "never try anything until you know everything" - sorry but that's just not realistic and it's unfair to the people who - commendably - contribute to these write ups and hold their hands up to mistakes-made, decisions that went badly with hindsight, etc.
Bigger picture: the Guardian appears to be thriving, and is succeeding based on the efforts of the tech team here. So if you read this and come away with a sense of "failure" you're probably missing something important.
It's OK to try new things and fail - just get back up and keep on trying, and use the new wisdom you build!
Plenty of people here like to dish on Mongo and the product seems to have been re-architected a few times since I used it seven years ago. By what metrics can we say the product is one worthy of passing a HN smell test? Passing Jepsen was seemingly not enough. https://www.mongodb.com/jepsen
Common sense and formal education? I'm sorry, I'm aware of how incredibly snarky and arrogant that sounds, but in this case I always struggled to comprehend how MongoDB, or most of "NoSQL" in general, was considered viable to begin with.
"Schemaless" just immediately means that instead of the database keeping consistency, you now essentially have to do all your type and constraint checking in the application; I never understood how that's favorable, and how that remains maintainable in any way. On top of that, NoSQL (and maybe Mongo in particular?) also decided to throw away all guarantees that classical SQL databases have been offering for multiple decades for very good reason.
I think everyone who's had a somewhat theoretical class on databases and learned about, for example, what ACID really means, will have smelled that something doesn't quite add up here.
This is so true. Some component has to maintain integrity of the data. Should it be the application developer? Or the database software team?
I know which one I'd choose, and which one is focused on data integrity and not business logic.
if you're using partitioned (inherited) tables in Postgres, then it's the application developer, as foreign keys on inherited tables don't really work.
the workaround is triggers.
But eventual consistency may be a viable trade off to help you scale, but the thing is you probably need to be at a massive scale before it is worth moving away from traditional SQL, which can have read replication and the app can have caching too. But there is probably some point at which eventually consistent nodes make sense.
In a sense that is what a CDN is, and we like to use those.
The summary of the latest MongoDB report [1] follows,
"In this Jepsen report, we will verify that MongoDB 3.6.4’s sharded clusters offer comparable safety to non-sharded deployments. We’ll also discuss MongoDB’s new support for causal consistency (CC) in version 3.6.4 and 4.0.0-rc1, and show that sessions prevent anomalies so long as user stick to majority reads and writes. However, with MongoDB’s default consistency levels, CC sessions fail to provide the claimed invariants."
That's really not what I want to hear about a place I'd be storing data.
Was it just a prototype back then? (When did it stop being a prototype?) Would the creators be comfortable using version 1 still?
Actually, I think that could be a good test of database stability: would you be willing to run a 5 year old version of your own software?
> This interpretation hinges on interpreting successful sub-majority writes as not necessarily successful: rather, a successful response is merely a suggestion that the write has probably occurred, or might later occur, or perhaps will occur, be visible to some clients, then un-occur, or perhaps nothing will happen whatsoever.
> We note that this remains MongoDB's default level of write safety.
- http://jepsen.io/analyses/mongodb-3-6-4 2018-10-23
Whoa, that was close. I really don't see why anyone would choose DynamoDB as a general purpose data store, unless they enjoy wasting countless hours finding ways around the limitations it imposes about how data should be stored and accessed. At least that was my (admittedly limited) experience. Postgres is a much better choice.
It's an epic shift in thinking to go from a schema of 50-60 tables to 1. Almost every dev I've worked with is very new to this.
The #1 sign a dev has no business using NoSQL: They chat about how flexible NoSQL is. Yeah, you can add attributes on the fly but I've found Dynamo to require much more careful planning then RDBMSes. Most devs I've met can understand when they need to use an index. But, almost all of them have issues predicting if their changes will lead to unbalanced requests against partitions.
Anyhow, since you can even connect the PostgreSQL WAL easily to a log stream like Kafka or Kinesis, I'm not sure why you'd ever start with a NoSQL DB, unless you just had master NoSQL data wonks.
I mean yeah who knew that blocking NTP therefore time drifting would break everything...
For those criticizing MongoDB, Fortnite generates $3B/year and runs on MongoDB, you should tell them it's a mistake and that they should use PG instead.
https://www.epicgames.com/fortnite/en-US/news/postmortem-of-...
https://www.epicgames.com/fortnite/en-US/news/postmortem-of-...
That being said they had a massive outage due to a MongoDB issue.
But I'm also one of the the people that still prefers to run MySQL over PostreSQL just because the tooling is still far superior
https://www.percona.com/doc/percona-monitoring-and-managemen...
https://www.percona.com/software/database-tools/percona-tool...
1. Stop. Trying. To. Build. Your. Own. Cloud. A pizza shop doesn't build their own cars to deliver pizzas.
2. There's no such thing as hassle-free anything, unless you are paying someone else to deal with the hassle. Sales teams lie.
3. Justifying an untested idea with "but it's modern technology" is going to backfire. Follow established patterns with good track records.
4. Writing your own in-house behemoth product, of which there are already many kinds available, results in long-term expensive engineering projects necessary to to get around the high costs you didn't know were coming.
5. Don't write business logic, or your primary software product, in a way that talks directly to a database. Just... No.
6. Magic new technologies that remove the problems of old technology also introduce the problems of new technology.
1. Well, they probably own the car though which is a better parable. You don't need to rent your car, you can simply purchase it just as you can purchase servers. People build their own garages.
4. So you should only used already written software? Sometimes it is just faster and better to write it yourself. You get less dependencies, you know how the whole thing works etc.
5. Why not? That is exactly what one should do.
Sure, use an ORM to abstract away the differences between PostgreSQL and MySQL (up until you need to care about them). That's reasonable. But maintaining a magical MaybeSQL layer that's powerful enough to not totally suck is going to totally suck.
Adding an abstraction on top of DB query won't help much if you are moving from one type of DB to another, say SQL to document, or document to graph.
Do people use ElasticSearch as a primary data store? In my limited experience implementations don’t treat it as the source of truth.
We unfortunately inherited a cluster from someone who thought it would be appropriate as a SoT for forensic data, which causes me no end of grief.
https://www.elastic.co/guide/en/elasticsearch/resiliency/cur...
I'm a little skeptical of the idea that you can do custom software development with a custom database schema and realistically expect to outsource DB management. But sure, you can try. And in any case, you'd hope a largely read-only and document oriented dataset like a newspaper's has a relatively simple schema; without too many crazy schema quirks.
I'm sure you can get advice or buy know-how; but they're too coupled to think you're not also going to need to spend some time too. (At least: assuming your workload is large enough and complicated enough that naive brute force isn't an attractive option).
Anecdotes like this are just that, anecdotes, there are no numbers in this article to show a trend away from Mongo, Mongo is actually continuing to gain adoption. See https://db-engines.com/en/ranking
> -8.82%% As of 11:56AM EST. Market open.
1 month chart still looks green so this might just be a correction.
It's under `/info`, which un-suffixed redirects to `/about`, which I _can_ find from the home page (it's linked in the _footer_) but I can't find this engineering blog from `/about`, or anywhere else I can get to from `/`.
I don't think it's so much a positive choice to use the same system as it is just using (a possibly separate instance of) what they already had, and still squirreling it away in a corner.
This requirement made some sense in a world where a rogue employee might yank your database server out of a rack and walk off with it, but I don't understand why this is still considered relevant in an AWS context. First of all your data is never really "at rest", a huge point of Dynamo is that the data is always available (at least 99.999% of "always" anyway). Second "at rest" where? Literally on a physical disk? Even if there was a single physical disk that held it I'm willing to bet that even if you were in the right AWS data center and had support of a willing AWS employee you couldn't find that disk and even if you could there'd be no way to remove it. I'll guess its literally millions of times more likely for you to fail to deprecate some AWS API key that's sitting in clear text on a laptop you sold as surplus than anybody gets their hands on your at rest Dynamo data.
The regulations and the attack risk aren't always in alignment unfortunately.
Interesting. I didn't know you could make indexes for things /within/ the JSON.
The only limit that I've run into in comparison with NoSQL databases is that you cannot index fields inside arrays within the column (json -> arrayIndex -> field), you need to normalize the array to a different table.
https://dev.mysql.com/doc/refman/5.7/en/create-table-seconda... contains some JSON-specific examples.
The proper solution is to onboard the proper talent and tools or outsource it all. MongoDB does have fully-managed offerings that will automatically migrate and run your database, across cloud-providers if you need, and would've cost less than all the time and effort spent on this. This is just another example of poor technical competency at media publishers.
I'm guessing their original choice for MongoDB was more for the schemaless development flexibility rather than horizontal scaling capabilities. This seems to have worked well enough for them. DynamoDB seems like a natural fit coming from a document store and they did very well not to choose it.
I think AWS is due for a managed NewSQL store comparable to Google Cloud Spanner or MS Cosmos DB.
Great blogpost, though; well written, which is always a surprise.
It's not just media companies rewriting something significant every few years; everyone in the tech industry does it. There's a very good reason for it: it provides interesting and high-paying work for tech employees.
Who wants to go to a company, set up a great system that doesn't need any more work except maintenance, and then just settle down into maintenance mode? No one who wants a rising career. "Maintained system using $oldTech" doesn't look good on a developer's resume, whereas "migrated critical system to $newTech" does.
And it's not just the developers: managers who oversee big teams of developers working on a big new project have more prestige and are paid more than managers who just oversee some boring already-done project that's in maintenance mode.
Now, in this case, there were probably very good genuine reasons for making a big change (I'm no fan of MongoDB), but many times if you look closely with a critical eye, you'll probably find that people padding their resume and making up a reason for their job to exist is the real reason something is being done.
Busy-work is never interesting, and if it's "high-paying" someone is getting fleeced (and will do what they can so as not to get fleeced in the future). At some point, the constant rewriting will have to stop. In contrast, maintenance work on a well-engineered critical system can be quite interesting in its own right (and it's not like the "maintenance" doesn't involve writing some new stuff on occasion. Nothing is ever truly "done").
Just to expand on this: if I were to take part in a project to move a critical service from Postgres to MongoDB (which I believe to be a worse solution), this would still be a better learning experience for me than just maintaining an existing installation. I'd have to learn about both DBs, and write a lot of new code to work with the new DB. That wouldn't happen with a Postgres system that's already set up and working fine. And my resume wouldn't look like someone that can come in and get to work on a big project and see it through by working on a maintenance project.
>At some point, the constant rewriting will have to stop.
At that point, the developers and managers who pushed for the big new project will have moved on to another company. Remember, moving companies every few years will generally yield a much higher salary than staying at the same company for your entire career.
>In contrast, maintenance work on a well-engineered critical system can be quite interesting in its own right
Sure, but you're not going to get a great salary doing that.
MongoDB, on the other hand, recently changed their license to an abomination that many people think is no longer Free: https://news.ycombinator.com/item?id=18301116
If you care about using FOSS - as many companies do - MongoDB is no longer open for consideration.
> approximately 2.3m content items.
I had a previous project where we did a similar thing (except with HSTORE instead of JSONB) and it exploded rather dramatically (very simple queries took multiple minutes or timed out entirely) after around 30m rows. I hope the Grauniad doesn't run into a similar issue, or at least anticipates it better than we did.
Having issues accessing Xmillion rows seems like something that would be caught by someone focused on performance of the database full-time.
At my previous startup I was ingesting Hearthstone games at a rate of 1-2M / day. Before being handed off to permanent storage (s3, redshift etc) a bunch of data would get stored in a JSONB, with 14-day retention. This all ran on a 200GB t2.large instance on RDS, was our smallest instance and never really caused an issue.
1) Why use Scala to write (a relatively simple) internal CMS?
2) Why use a clustered database for 2 million records?
3) Why write your own proxy? (in Akka, none the less)
4) Why would you migrate articles from Mongo to Postgres using a script that runs overnight in screen?
The Guardian is, prima facie, a Wordpress blog. A simpler architecture would be:
1) Any CRUD web framework to build the CMS for reporters to draft their articles (Django, Rails, etc). Any basic RDBMS with read replication will do. Or, ditch the webapp entirely and just make a simple Markdown editor that commits to a git repo, a la Prose or Netlify.
2) When a reporter "publishes" an article, generate HTML for it and push to the CDN network. (I can't easily tell by looking at their HTTP headers, but I assume they're doing this already)
Okay, I'm being a little tongue-in-cheek. It's probably not that simple. But, one has to wonder, when you're serving up 100 million static HTML pages a day, if it really has to be this complicated.
A bloated web framework makes your code simpler because there are many things that you don't need to reimplement by yourself.
The problem is when developers use a framework without understanding it well and:
1) Reimplement in the code features that are already present in the framework. 2) Fight against the framework because their business needs conflict with the conventions choosen by the framework. 3) Fight against the framework because they don't agree in the way the framework solved a particular problem and want to solve it their way.
In both cases, the origin of the issues is not the framework itself.
> The most trivial way to implement a website for high traffic is simple static content generator
Agree. But in any case, those kinds of sites are not hard to catch neither.
Django itself was literally developed to suit the use cases of a newspaper.
I spent 4 years at a large financial news company, where we benefited from many ex graunaids who decided to migrate over the river.
They helped us create the new front end to the website, to much acclaim. However, it was hard for a number of reasons(this is from the financial news company, not the gruan.):
1) The journalists hated change, especially as they couldn't see any benefit. They just want to keep their same interface exactly as it is, bugs and all. They also had an active union.
2) There is 20 years of "micro services" moving data from the CMS, through various things to allow stuff like translations, syndications (very important source of money) data extraction, meta data processing, physical page layout, and many many more. Most of which is done by a legacy ETL framework pushing to and from a solaris FTP server that is old enough to join the army.
3) there is more than one way to enter data into the CMS.
4) The type of article, and the data in said article changed depending on where it came from, and what services nobbled it.
5) looking after the journalist's interface, curating the data, sorting the articles and adding meta data, looking after paying subscribers, and finally the front end, were all different departments that refused to talk to each other.
This meant that unlike a rational place, there was no source of truth for the CMS. It wasn't like you could call up article 342923 and display it. There was no guarantee that it would have all of the metadata (like were we allows to publish it) required. Add to that the inter department rivalry, which meant that for some reason the membership department were allowed to spend 4 years re-writing the same bit of functionality over and over again. (user management and payment gateways is a solved issue, but alas it took the best part of 25 million quid to find that out.)
To answer your questions:
1) because it scales maaaaan, looks good on my CV, I don't want to spend time doing boring work, I want to learn a new tool
2) see 1
3) see 1
4) Because I suspect that they've never seen a working ETL system
To answer your bonus questions:
1) Journalists have unions, changing the editor requires a _boat_ load of training, and is almost never worth it. Buy over build every time. But yes, its just text. However its the metadata that makes it. Whos in the article, whats the subject. Is it a lifestyle piece, does it have photos, who owns the copyright for the photos, is the article syndicatable, can we syndicate this article, who edited it. Etc, etc, etc. The text entry is the easy bit, its the parts that make it a real news paper that are hard.
2) Nope, almost certainly never done like that. The article will be given a UUID, and dumped into the CMS DB. The front page generator system will then dynamically pull out the articles based on parameters given first by the editors, (front page image, leading headline etc) then the related articles might be curated by hand, or by keyword/metadata or user's preference.
Then the advertising and tracking bits have to be injected, which account for 50-70% of the effort.
CDNs now allow a lot of logic to be pushed to the edge. (see https://labs.ft.com/2014/10/caching-user-agent-specific-resp...) which means that its not overly taxing to host a very large website.
Their proxy is one example where Rust will give the same capabilities as Scala and will be more robust, in the future, if it's not already the case today.
I haven't tried it yet, and there are some limitations at the moment, but I find it extremely promising.
Most of the times a boring database is a better fit.
Not everybody can be an early adopter, especially on the software which stores what is arguably your most precious asset.
Elaborating on my comment though, it would make sense to consider a drop-in replacement for a technology for which you've already invested yourself, but got bitten enough time to think about moving away to a different model (operational burden, data loss, etc).
I'm not sure if "baroque" is a good qualifier for FDB.
It's recent in the open source community, but has been running in production for many companies (including Apple) for some years. It's based on sound architecture, compare to many others.
This is one of the reasons why building on top of the old API wasn’t an option. There was very little separation of concern in the original API and MongoDB specifics could be found even at the controller level. As a result the task of adding another database type in the existing API was too risky.
This seems like the problem was more related to the API layer code quality rather than where the data was stored.
We moved that specific collection to MySQL, no problem and there was virtually no change in the data structure. Both were of course indexed.
SQL is not RDBMS is not ACID is not NoSQL.
When comparing NoSQL to something you should really compare it to RDBMS which is what most people conflate with "SQL". This conceptual understanding gap is IMO what led to the huge growth and misuse of "NoSQL" for a decade.
This bit sounds like a cautionary tale about the importance of a layer and well structured API. There’s no reason why details about your data store should leak into an API Controller.
This happened to us numerous times before and after we migrated to their Atlas platform. We are a major streaming company with more than 120M registered user. Disclosure, we are moving away from MongoDB as well.
- They'd been running the two systems in parallel and comparing their outputs for months. By the time the pulled the plug, they were confident that PostgreSQL was working fine.
- They had written systems to copy data from the MonogoDB-backed service to the one running on PostgreSQL. Once they started treating PostgreSQL as the official store of record, they'd be faced with either writing another system to mirror PostgreSQL back to MongoDB or committing to lots of double entry. Either of those sound painful.
postgres all the way.
THe FT use(d) cassandra to store their membership details (6 million rows of largely static, read-only well structured data) The cluster was massive (12+nodes in at least two regions, from memory) slow and was impossible to upgrade reliably.
The support from datastax is shite. Backups are not reliable. imports even less so, and you are beta testing the whole system every time you do a point release.
CMSs have highly structured data. swallow your pride, map the data and build a proper schema. Its really not that hard.
Yes, cassandra has a graph layer, no its really not worth it. Yes it has gremlin, no you shouldn't need it if you've modelled your data correctly.
Datastax builds a graph layer on top, or you can use something like JanusGraph, but it's never as good as using a real graph database with natively designed storage system.
I've seen cassandra shine when it comes for write optimised loads. Pipe a bucket load of data into gremlin and magic happens.
But thats a specific workload, which is pretty rare, and certainly not suited 999:1 read to write ratio. Thats not cassandra's fault, thats the fault of the idiot that chose it, and the boatload of idiots who carried on and added loads of systems that makes it much harder to migrate away.
Then we come to support. Datastax is the defacto support provider. They make a lifecycle manager, backup/restore tool, and push a load of patches into the main codebase. But it is shit
o Backups fail silently
o The only way to make alerts work (ie do an action, rather than create a popup when you log into the ops center) requires work to navigate the API
o Its full of CVEs, which are script kiddy-able
o migrating data from backups to new clusters was impossible to do without a boat load of manual work, failed 50% of the time
o restoring from automated backups was impossible until august.
o it couldn't use instance profiles on AWS until august
o upgrading to a point release silently breaks backups, _always_
Basically I spent the first half of this year QA very expensive software. There are some very very good support people, but there were some terrible ones as well.They definitely want more than a key value store. They at least want date and content indexing, editor, author, etc. I imagine they probably have a few internal requirements as well wrt analytics, tooling and more. S3 doesn't work for all this and another user's suggestion that this is all treatable like static content sounds way off to me. The best you can do is pregenerate some of the HTML.
In Amazon it's harder to compare directly as the support contract is paid across all of our accounts, but we're spending around $13,000 for a highly available db.r4.xlarge postgres instance.
Performance wise, querying without an index is SLOW, basically not worth it - as we end up doing a scan of the entire database. Fortunately we don't need to do this as we can usually rely on the guardian content API for proper searching stuff. The average API (a Scalatra app) response time reaches 150ms at 'peak time'. This isn't a high-performance use case - around 1000 requests/minute at 'peak' time.
My company does bespoke software development for large enterprises. If they're on AWS having all your services within a VPC you control is something of table stakes for a lot of large company engineering and security teams.
My SAs seem cautiously willing to try it, but I won't put them through the work of learning how to manage it unless I can find a clear advantage over Postgres+JSONB.
"Goodbye {Postgres|Mongo|MySQL}, Hello {MySQL|Mongo|Postgres}"
Would you say the same thing about programming languages?
I was actually listening to the Full Stack Radio podcast, and the latest episode talked about the power of moving more into the database. What struck me as a strong idea was that we can't treat databases as equivalent - different database servers have different strengths (for example, some have better JSON support or time evaluation functions).
I think it's particularly telling that you seem to be thinking of the database as a "tool", but if you're like most, you fight religious battles over your language of choice. In my experience, the database IS the application (and in many cases, the business) and is a far more important choice than the implementation language, the cloud provider, etc.
But lemme ask this question, what are the things in which mongo is better than postgres?
You are talking about replica sets, which is different concept.
OpsManager is great for team that don't have dedicated devops I think and have great dashboard/visualization.
However, run your own MongoDB is very easy. Not like Postgres(unless you used RDS). However, when using RDS, you still have downtime when upgrading db, it still have a small amount of time the standby in MultiAZ is promoted to master, DNS is updated, and during that yourcurrent primary is not writeable or even not available. MongoDB is way easier to operator. You add/delete/node on fly and client auto discover network topology. Plus https://docs.mongodb.com/manual/administration/production-no... this links give great info to tune it: thing like run on XFS, mount with notatime options...puts opslog on high iops volume etc...
Peformance isn't a factor to pick your database much nowsaday. They looks great on the benchmark. However, try for yourself before pick one on your workload. Postgres does has its own ward.
Pick a database based on how well your team confident with it, how does the database help you move fast enough or deliver business value. Don't follow the hype or silly benchmark.