Live data from Hacker News

Startup Mistakes: Choice of Datastore

stavros.io

101–110 of 119 posts

Re: Startup Mistakes: Choice of Datastore

#101
post #58
post #16

Earlier quoted context omitted.

BIG ERROR. Like, MONUMENTAL. That something (if chose very wrong) will totally derail you progress and will cost a lot of fix it later. Is incredible. Nobody remember that the most cost effective way to fix a problem is in the early stages? And, yes, the best overall primary datastore, like 90% of the cases, is a RDBMS. Very few actually need to use something else.

The point OP is making is that in a startup, you don't do engineering for the sake of engineering. In the end, what matters is generating wealth. Obviously, you want a sane legacy for the future but unless you already have hit that sweet product-market fit spot it is likely that you will spend a non-trivial amount of time optimizing (prematurely) for something that's in fact orthogonal to what you actually need. The…

This, I find, is one of the hardest things about hiring developers for a startup. Because on one hand you want people who knows how to do things right.

On the other hand, you want people who are prepared to accept that decisions that are insane in a stable business can be very much rational in a business where the cost of cash to fund large engineering changes is dropping at a crazy rate if you're successful, and doesn't matter if you're not (because you'll never get to it).

Of course it's good to avoid completely pointless mistakes. But it often matters far more to deliver.

Re: Startup Mistakes: Choice of Datastore

#102

Earlier quoted context omitted.

have you ever had an issue with that? There are only 7 billion people, most of whom don't need your database updated faster than their ping time... seems like a non-issue.

It's an issue when two people try to write something at the same time and one of them gets a crash because acquiring the lock failed.

So that's an actual issue for you? This happened?

Can't you just idle in a loop waiting for the lock, perhaps waiting a random number of milliseconds (200-800)?

(So that rather than crash, the client just "hangs" waiting for the lock, in a busy loop.)

It just seems like this should not be an issue.

Re: Startup Mistakes: Choice of Datastore

#103

Earlier quoted context omitted.

It's an issue when two people try to write something at the same time and one of them gets a crash because acquiring the lock failed.

So that's an actual issue for you? This happened? Can't you just idle in a loop waiting for the lock, perhaps waiting a random number of milliseconds (200-800)? (So that rather than crash, the client just "hangs" waiting for the lock, in a busy loop.) It just seems like this should not be an issue.

Yes, it happened. I could do lots of things, and "apt-get install postgres" is the simplest

Re: Startup Mistakes: Choice of Datastore

#104

Earlier quoted context omitted.

So that's an actual issue for you? This happened? Can't you just idle in a loop waiting for the lock, perhaps waiting a random number of milliseconds (200-800)? (So that rather than crash, the client just "hangs" waiting for the lock, in a busy loop.) It just seems like this should not be an issue.

Yes, it happened. I could do lots of things, and "apt-get install postgres" is the simplest

That's fair. As an aside, while it solved your crash issue and obviously scales, when you switched did you get an immediate measurable (and noticeable) performance hit due to the overhead of a proper concurrent database?

Re: Startup Mistakes: Choice of Datastore

#105
post #95

Earlier quoted context omitted.

>something that can accommodate changing requirements, i.e., a relational database Wouldn't NoSQL be better suited for this scenario? Genuinely curious.

Exist the myth RDBMS are not flexible (because it have schemas). To the contrary, the relational model is very flexible, and allow to model everything you could want. Even model a NoSql :) And the Relational model is fairly simple. You could learn anything you need in minutes and just remember in add a few index here and there. For the small amount of things you need to do, is incredible how many features a RDBMS giv…

> I don't remember the original quote, but is alike: "Novices worry for code, Experts focus on data structures".

The origin is Linus Torvalds on the Git mailing list. Here is a copy from LWN: https://lwn.net/Articles/193245/

The quote is ironic considering that Git uses a bespoke and not particularly well-designed key/value database, which has resulted in notorious usability problems in Git.

Re: Startup Mistakes: Choice of Datastore

#106
Wow. This fell off the front page in the time it took for me to drive to work. Guess the NoSQL crowd ain't got time for that.

While I'm generally sympathetic to your post, there are some things that are red flags.

>If you have ten services accessing the same database and sharing data between themselves

Whoever access the database schema owns it. If you have ten systems accessing your database then ten teams own it. And if ten teams own it then nobody owns it. Nobody can change it. Seen this at a successful start-up that got big, but then couldn't rev order management, because every team had their finger in the pie, we couldn't do a schema update without breaking everyone, and of course one team was "under tremendous pressure to hit a major milestone and we just can't do that now" for over a year.

Now I would turn this around into a win for RDBMS by suggesting the use of functions or stored procedures: with an RDBMS we can construct an API, and then we can version those APIs. And then the team that owns the database can do what they like. That said, we can do the same with NoSQL databases by not allowing other teams to access them. The team that owns the NoSQL database is required to maintain an API for it.

I've only ever had nightmares with other teams coding against my schema. GraphQL worries me in that respect and I'd love to hear how people here have fared with long lasting GraphQL, in the real world.

>Django, for example, makes migrations trivial, as you just change your application-level classes and the database gets migrated automatically.

I've had automated migration systems grind to a halt and leave the DB fucked too.

>Priscilla used a graph database when her data was relational. Her husband, furious, filed for divorce.

There are no schema that are "relational" but not "a graph". However there are plenty of schema where a graph database is a natural fit but that require either one-table-per-node-type or building a graph model on top of your RDBMS (e.g. an Entity-Attribute schema). Oy.

There are also many schema where there is only one entity type, but every join is against itself, and we're looking to join all the way out to the clique. In this case would you suggest an RDBMS, and then put the iteration in the application? You suggested earlier that making up for the inadequacies of the datastore in the application is a bad idea.

I've got a graph application that uses NoSQL and it was the right call. An RDBMS would have allowed us to write something that worked for simple cases, but that would have brought the system to its knees based on some customer usage. The solution for the RDBMS would be the same as what we had to do for NoSQL. But up to that moment, the NoSQL allowed us to iterate far faster than an RDBMS.

>For example, if you later need to compile a list of all the brands of all the products on your store, an RDBMS can easily do that by reading the “brands” table

Only if you built a brands table. You can't argue that we can't predict the future, so use an RDBS because its easy to change, but then make arguments that require that the builder accurately predicted the future and built the schema with that foresight. Sure, we could go and pull a brands table out of the existing tables but thats work, and it might be work on a live database that brings it down.

A graph database would be just as likely to have 10 brand nodes since the overhead of creating the first such node is far lower than creating an entire table and updating the schema.

>Relational databases excel at easily providing answers to questions that weren’t predicted at the time when the data model was designed.

Or a NoSQL database with spark. "But spark is something new to learn"

And this is the biggest flaw in your argument. You're pro RDBMS because you know SQL and how to run RDBMS, create the schema, and write the queries. It is incredibly easy to get started with MongoDB. That right there is why it is popular. Not because its good. But when you say "Just get something started and use an RDBMS", you're actually saying "I know you know javascript, but I need you to learn Modula-2 for this part of the system". Fundamentally different syntax and strict types (or "schema").

>For all its unparallelizability, ACID is pretty damn nice.

Until someone holds transactions open across network calls and kills throughput. I've seen that issue lose a company a multi-million dollar contract because of contention on a single row. Or until someone chooses the wrong isolation level ("But I used a transaction!") and two transactions happily decrement non-atomically. This shit be hard, and part of the "hard" is not knowing you're doing it wrong.

>You’ll have plenty of time figuring out what to use when you know your exact usage patterns, if the business manages to not die until then.

So start with something quick and easy then. You've already managed to describe two scenarios where an RDBMS blew up in practice (multiple teams hitting a DB causing schema lock; its a network, not a flat hierarchy).

If you have an experienced SQL team, by all means go with RDBMS. But lets not pretend they are a panacea. Honestly, I'd use a graph database pretty much all the time - if I could only trust them. But its the quality, reliability and longevity that I have a problem with, not with the nature of how the database organizes data.

Re: Startup Mistakes: Choice of Datastore

#107
post #96
post #82

Earlier quoted context omitted.

If your goal is to build a sustainable business you must address two questions: Will I provide value people are willing to pay for? Will I be able to find those people profitably? Both answers must be yes. You might be able to answer one of the questions without an MVP but very unlikely to answer both without. So you need to ship something. It would be clearly stupid to not consider your technology choices at all in…

>Spending a massive amount of time on getting it “just right” will most likely teach you that you’ve developed the perfect solution to a problem no one cares about. And this is the reason a RDBMS is totally better. You NOT need to "spend a massive amount of time". With this: 1- You get a totally proven and mature tech 2- With massive tolling support and documentation 3- With the capabilities to model even most NoSql…

I was speaking less about the specific debate between NoSQL and RDBMS and more about being cautious to not over-think the technical aspects in general.

Speaking specifically about NoSQL: I’ve been able to launch entire MVPs using DynamoDB, some Lambda functions and HTML / JavaScript in about the same amount of time it would have taken me to plan out, build and refactor a proper schema. And I usually learned through the MVPs that my idea was stupid and no one cared about what I built, much less about my choice of database.

Re: Startup Mistakes: Choice of Datastore

#108

Earlier quoted context omitted.

Yes, it happened. I could do lots of things, and "apt-get install postgres" is the simplest

That's fair. As an aside, while it solved your crash issue and obviously scales, when you switched did you get an immediate measurable (and noticeable) performance hit due to the overhead of a proper concurrent database?

No, no noticeable hit. SQLite is a proper concurrent database as well, so I don't think I would have.

Re: Startup Mistakes: Choice of Datastore

#109

@StavrosK: (aka the author) - what is the TLDR of the article? Ask since there appear to be a number of users including myself that appear to not get the intent of your article. — Meta-comment: Feel like if the poster is self-identifying as the author when posting the link, it’s verified via say email/domain, an HN username has been ID’d in the past as the author, etc. — it should be automatically obvious in post, co…

It's what I explicitly call out as a TLDR in the article itself: "Think before you pick a database. If you insist on not thinking, pick PostgreSQL. Trust me." Basically, "Postgres is a better default".

There is no TLDR, summary, etc. clearly marked as such; by one estimate it takes 140 seconds or 468 words to get to the start of the sentence you quoted above; which is strange given your point is to stick to best practices unless there’s a strong reason not to do so. Strongly recommend moving that info to the top of your post.

Re: Startup Mistakes: Choice of Datastore

#110
post #47

To the people saying "just do Postgres", what would you say to a startup that wants to create offline first apps? CouchDB, for example is way better at that than Postgres. 1) Use CouchDB and Postgres? 2) Somehow implement revisions and Postgres? 3) Use Postgres anyway and scrap the offline first?

If you want to create offline-first apps, I would use Postgres as the main datastore and use Couch to sync data between client and server. You'd have to decide which of your data would live where (or if you wanted to use Couch as a way to transfer data from the server to the client). Couch is a very good datastore for that use case, though, so I would definitely use it in some capacity for your purpose.

Can you expand on this? Do you mean you'd use Postgres as your main store and periodically "flush" data from CouchDB to Postgres (probably as JSON)?

I don't see how that would work reliably. On the client would you source CouchDB or Postgres? Presumably you'd access CouchDB directly, but then why even use Postgres (for that subset of data, anyway).

Post reply on HN