One of the most important topic in Software Development is Connection Pool.
A connection pool is a simple idea that solves a very real performance problem in modern applications.
Whenever your app talks to a database, it needs a connection. Creating that connection isn’t free. It involves network setup, authentication, and resource allocation on both sides. If your app creates a new connection for every request, things slow down quickly, especially under load.
A connection pool avoids this by keeping a set of ready-to-use connections open. Instead of creating a new connection each time, your app borrows one from the pool, uses it, and then returns it. The next request can reuse the same connection.
This has a few big benefits. First, it reduces latency because you skip the setup cost. Second, it limits the total number of connections hitting the database, which protects it from overload. And third, it improves overall throughput since requests spend less time waiting.
Of course, pools need tuning. Too few connections can create bottlenecks. Too many can overwhelm the database. But when configured well, a connection pool quietly becomes one of the most important pieces of your system’s performance.
What happens if your CPU gets something wrong? If it wakes up one day and decides 2+2=5?
Well, most of us will never have to worry about that. But if you work at a company the size of Google, you do, which is why this paper on "mercurial cores" is so fascinating.
What the authors report--and supposedly this is common knowledge at the hyperscalers--is that a couple cores per several thousand machines are "mercurial." Due to subtle manufacturing defects or old age, they give wrong answers for certain instructions. These can cause all sorts of impossible-to-diagnose issues. Some rare problems at Google that were traced back to bad CPUs include:
- Mutexes not working, causing application crashes
- Silent data corruption
- Garbage collectors targeting live memory, causing application crashes
- Kernel state corruption causing kernel panics
What makes CPUs go bad? It's very hard to tell. The authors posit that issues are becoming more frequent as CPUs get more complex, but there aren't solid numbers behind that. There are certainly strong relationships between frequency, temperature, voltage, and bad CPU behavior--most mercurial CPUs only cause problems under very specific conditions, but those conditions vary from CPU to CPU. Age is another source of problems, as older CPUs are more likely to exhibit problems.
Bad CPUs are an especially serious problem because they're very hard to detect. If cosmic rays flip bits in storage or on the network, that can be detected through error coding. But there's no analogy for a CPU that allows cheap online verification of its correctness. Instead, the best detection techniques involve monitoring for symptoms. If a core exhibits exceptionally high rates of process crashes or kernel panics relative to its fellows, that's a strong indication something is wrong with it. For the most critical applications, the authors propose triple modular redundancy--redoing each of its computations on three cores and majority-voting a reliable result.
More than anything, this paper is a call to action--letting everyone know that CPUs can fail. So now, if you ever find a bug you can't diagnose, you can blame the CPU! 🙂
"Programmers are attracted to complexity like moths to a flame. The more convoluted the systems diagram, the greater the intellectual masturbation. Our commitment to resisting that is the key ingredient in this uptime success." https://t.co/sIEMZXpZ95
We lost a titan of programming languages, programming methodology, software engineering and hardware design. Niklaus Wirth passed away on the first of January. We mourn a pioneer, colleague, mentor and friend.