1,822 karma · joined Feb 3, 2019 (7y ago) · 645 submissions
comment 3y ago · link · parent
1. It doesn't scale (there it is again)
2. Queuing with Postgres is super fiddly to get right
3. You're hacking a queue on top of something that isn't a queue
4. Running redis or rabbit isn't all that complicated
#1 as TFA argues, premature concern about scaling is the root of so much needless complexity. You should make scaling decisions like this: 1) assume boring tech like PG will satisfy your needs; 2) if it demonstrably does not, then find something that does.
#2 is obviously true; just look at this thread. There are battle-tested queuing libraries in most popular languages, but you do have to dig into the details of how they interact with things like pgbouncer.
#3 I guess so? But if the queue abstraction works and isn't leaky, what does it matter?
#4 can be debated. For several years I've been running a moderately complicated setup with 2 databases, redis, and kafka for several years. There's no way I'm going to add another piece of tech unless there's no other choice. The cognitive cost is too high.
The main debate is in the tradeoff between #2 and #4. Personally, if I can use an existing piece of tech to solve a problem to avoid having to ops another piece of tech, then I'm going to do that every time.
comment 3y ago · link · parent
comment 3y ago · link · parent
comment 3y ago · link · parent
Postgres is VERY committed to making sure a replication slot’s consumer doesn’t miss any data. This means that if a consumer stops consuming data from the slot, Postgres will helpfully store all that missed data… right up until the disk fills up and the database falls over. Had this happen during prototyping with two different SaaS DBs, and the only way to get it back up was to file a support ticket. (I can’t remember if metrics warned that the disk was about to fill up or not). Basically, if your replication slot consumer stops reading, that should trigger some kind of alert.
The other reason I don’t use it: the code path to get the initial snapshot of a table is totally different from the code path to read changes. Initializing the read from the replication slot so you never miss any changes is nontrivial.
It’s too bad, because replication is obviously the least hacky solution for change capture.
I use polling, but storing the txid instead of updated_at.
comment 3y ago · link · parent
comment 3y ago · link · parent
You've really changed your workflow to adapt to these new tools. The amount of mental effort seems comparable to learning a new IDE, maybe a bit less.
Instead of the chat app, I wrote a python script that uses the GPT-4 completion API. I can just pop over to the terminal and type 'chat' and it's there. As far as I can tell, it's basically the same as the app.
We are starting to see AI tooling that can fit an entire 100k line code base in its context window. I still see myself having a job five years out. Ten years out, not so much. Luckily I'll be close to retirement.
comment 3y ago · link · parent
Could elaborate more on your workflow? Do you use Copilot, or just GPT4? Are you copying and pasting large blocks of existing code to hint at how things should fit together, or do you describe how the existing code is structured in English? Do you find yourself decomposing your work differently so as to fit your new AI workflow?
comment 3y ago · link · parent
They’re just monetizing users as much as they can stand to juice revenue. No other explanation is needed.
comment 3y ago · link · parent
comment 3y ago · link · parent
I notice this all the time with software. I tend to keep hardware for 5-8 years, and by the end of that window, apps and websites start feeling sluggish. Of course they do: all the devs have modern hardware and don’t notice how crappy the experience is on old hardware. You can tell them, but they don’t feel the pain and their empathy is limited by how much it actually impacts the bottom line.
comment 3y ago · link · parent
About 5 years ago we migrated to postgres and installed pgBouncer because of course you do. Sometime last year I started seeing some weird issues like the article points out, and the more I looked into the gory details, the more shocked I became. (The fact that statement level isolation even exists is… wow)
So I did an experiment and deleted it. Things kept working just fine. We’re not living in a microservices world so application-level pooling is enough — I don’t think I’ve ever seen us use half of available connections.
comment 3y ago · link · parent
I think I was gifted this book for my 13th birthday so some of the math was a bit beyond me. But learning assembly and working out some of the more intricate algorithms like polygon clipping were both great training for a new programmer.
comment 3y ago · link · parent
I was 13 at the time, so I struggled with the math (this was pre-internet so I couldn’t just search stuff). I’d never seen matrices and wasn’t able to figure them out from that book. I distinctly remember hitting a wall in the chapter on lighting because it mentioned taking the dot product of two vectors, but I didn’t understand why that would give you the cosine of the angle between them because I’d never heard of the dot product before.
Edit: right at the bottom of page 405. I reread that sentence so many times.
comment 3y ago · link · parent
1. errors that can be handled locally (such as parsing; in other languages, these situations are often signaled with return values instead of exceptions)
2. errors that can't be handled locally (such as network errors; other languages use exceptions for these)
My argument was that worrying too much about error handling performance in #2 is premature optimization. 1ms is extreme, but the actual figure of capturing a call stack in Go -- several microseconds, by my benchmark -- puts it squarely in the "don't worry about it unless your code is performance-critical" category.
comment 3y ago · link · parent
> Errors are normal, not exceptional.
The _handling_ of errors is normal. Code that doesn't consider errors is not production code.
And granted, in Go, control flow is driven by errors more often than in C++ or Java. Sentinel error values are common. See for example all usage of error.Is, checking for io.EOF, packages that define ErrSituationA and ErrSituationB, etc.
But my argument was about errors that can't be dealt with locally, where the origination and ultimate handling are very far apart. A given flow will encounter these errors relatively rarely compared to the happy path (and if it's not rare, you probably need to fix or change something). Having an intuition about this is important for predicting your code's performance. For example:
- The SQL call failed because the network connection dropped; client gets 500 or 502, or retry.
- A call to an external service failed because the network was bad; it gets retried.
- The SQL call succeeded, but the record the client asked for wasn't found, so the client gets a 404.
- Writing to a temporary file failed because the disk is full, so some batch job fails with an error.
Apart from potential concerns about DoS, worrying too much about the performance of error handling in these relatively rare cases is absolutely premature optimization.
DoS isn't even a concern. I just benchmarked capturing a call stack in Go, and it's on the order of a few microseconds. Unless you're in performance critical code (and you're benchmarking, right?), it's fine.
comment 3y ago · link · parent
And I disagree that the cost of carrying around the callstack is something to worry about. Errors are akin to exceptions in C++/Java: no happy path should rely on errors for control flow (except io.EOF, but that won't generate a call stack). They should be rare enough that any cost below about 1ms and 10k is negligible.
comment 3y ago · link · parent
I see this all the time:
main.go:141 error: could not transmogrify the thing: a144cd21c48
And then I literally grep the code base to find the error message. That works ~50% of the time, but the other 50%, I see this: main.go:141 error: not found
And then I have to spend 5-10 minutes spelunking to try to find where that error might have originated from.But this would be amazing:
main.go:141 error: not found callstack=...comment 3y ago · link · parent
I'm iterating on a log pretty printer that accepts structured logs in a pipe and does things like color coding, adding terminal-recognized vscode:// hyperlinks for call stacks, smart wrapping based on the terminal width, and special formatting for panics and stuff.
NCurses is probably coming in a couple months.
Does anything like this already exist?
comment 3y ago · link · parent
But code written using this library is no longer Go: most Go programmers can't grok it, and it's awkward to call normal Go libraries because there's no way to know if that function you're calling is pure.
If your goal is to "make it easy and fun to write maintainable and testable code in golang" by making pure functions first-class, is there another way to do that without inventing a new language?
From experience and inspired by Carmack's classic essay on FP in C++[1], I tend toward a functional style: minimize state, treat locals as const, avoid non-const globals, enable parallelism by isolating state. Go makes it easy to write static analysis tools, so go vet could be augmented to, for example, keep track of which functions are pure, and show some yellow underlines at those places where input parameters are mutated.
I'd use something like that.
comment 3y ago · link · parent
You want to optimize for velocity gain (also known as delta-v) per unit mass of propellant. So the question is, should you eject something heavier at lower speed, or something lighter at high speed? Which is more efficient?
If you write out the equation for a rocket ejecting some propellant at some velocity, apply conservation of momentum, and solve for the ratio of delta-v to propellant mass (just a bit of high school physics), it turns out that a higher exhaust velocity makes a more efficient rocket.
As a sibling post points out, if you compare water vapor with hydrogen at the same temperature, hydrogen will have the higher velocity. Chemical rockets usually produce water and/or carbon dioxide, which are bigger molecules and therefore less efficient propellants than hydrogen. So if you have a way to heat hydrogen to the same kinds of temperatures you get in rocket exhaust — say, in a nuclear reactor — that’ll make a more efficient rocket.
There are of course considerations other than pure efficiency. Our most efficient rockets, ion engines, are indeed crazy efficient, but their thrust is measured in milli-newtons or newtons. They can’t be used to lift things off earth. They also use propellants like krypton and xenon, presumably because they’re easier to store than hydrogen.
comment 3y ago · link · parent
We’ve been running a 3 node cluster for several years, and a significant minority of the times I’ve been paged is because ZK got into a bad state that was fixed by a restart (what bad state exactly? Don’t know, don’t care, don’t have two spare weeks to spend figuring it out). Note that we have proper liveness checks on individual instances, so the issue is more complicated than that.
Migrated to 3.3 with KRaft about half a year ago, and we haven’t had a single issue since. It just runs and we resize the disks from time to time.
comment 3y ago · link · parent
What the hell happened? Is annual security training still a thing?