←back to thread

269 points mtlynch | 2 comments | | HN request time: 0s | source
Show context
sgarland ◴[] No.43955920[source]
> Ship first, worry about scale later

This is repeated constantly, but I fear that it is internalized as “write shitty code and throw money at it later.” If you have taken the time to learn your language well, you can avoid a lot of really bad decisions that don’t cost you additional time.

Similarly, on the infra side of things (where this advice is usually doled out), maybe take the time to have a modicum of understanding about the tools you’re building on. If you’re using a DBaaS, your vendor almost certainly has monitoring built-in, often for free, or a nominal cost. USE IT, and learn what it is you’re looking at. “The DB is slow” could be anything from excessive row locks due to improperly-held transactions to actually hitting an underlying resource limit – and for the latter, 9/10 it’s a symptom of something that’s misconfigured, or not understanding your RDBMS’ operation.

For example, do you have a write-heavy table with a UUIDv4 PK, lots of columns that are heavily indexed, and some medium-large JSON blobs in it? Congratulations, you’ve created Postgres’ (and MySQL, but for different reasons) worst nightmare. Every write is amplified by the indexes, and even if you’re doing an UPDATE and are only hitting one of the indexed columns, all of them will be rewritten. The UUIDv4 PK means your WAL traffic is going to skyrocket from all the full page writes, and if your JSON blobs are big enough to be unwieldy, but not big enough to have be TOASTed, that’s another huge amplification to writes. All of this can easily result in hitting IOPS limits, network bandwidth limits, or CPU saturation from additional queries piling up while this one is dealt with, and all of it could be easily avoided by having a basic understanding of your tooling.

replies(2): >>43956126 #>>43956188 #
1. maerch ◴[] No.43956188[source]
> If you have taken the time to learn your language well, you can avoid a lot of really bad decisions that don’t cost you additional time.

From my own experience, I can say that this mindset can easily become an eternal excuse to procrastinate building and shipping. “First, I must perfect my knowledge and tools—only then will I build my perfect product.” But that’s just another form of perfectionism, and often, it’s equivalent to never shipping anything at all.

replies(1): >>43956268 #
2. sgarland ◴[] No.43956268[source]
Yes, it’s easy to accidentally or purposefully do. An example of what I’m talking about is “I’m going to cause an N+1, row lock contention, and slow writes by looping over a list of IDs while holding a transaction open, retrieving information for each, and then doing a single write.” This is something that is shockingly easy to do with an ORM if you don’t know any better, but it’s also one of the easiest problems to solve once you do.

Or, explicitly germane to a language vs. an ORM, something like concatenating strings instead of building them in whatever your language’s method of doing so is. Does it have that big of a performance hit in a vacuum? No, but it also takes no more effort to do it correctly, and small gains add up, so why not do it right from the start?