CPU Caches

Have you ever bought a bunch of stamps so you don’t have to go to the post office every time you need to mail a letter? Caches are like that, but for computers. Instead of stamps, they store copies of the data that your computer uses most often. Why do we need caches? We need caches to improve the performance of applications and systems. Caches store copies of frequently accessed data in a faster memory, so that the CPU can access it more quickly....

October 29, 2023

Expose "local" web server to internet with ngrok

I had a “local” web server that I wanted to share and collaborate with my friends. I was looking for ways to do so without the need to deploy it to the cloud. I came across ngrok reverse proxy and it is exactly what I was looking for. While the concept is nothing new (used by a few other products), ngrok makes the solution general purpose, and simple to set up, configure, and run it....

December 4, 2022

Simulate TCP and TLS Proxy using SOcket CAT

SOCAT is a command line based utility that establishes two bidirectional byte streams and transfers data between them. We can leverage SOCAT’s support for different types of sources and sinks to simulate TCP and TLS proxies. This type of simulation helps us understand the impact of a proxy (between server and client) and establish a baseline for the latency and throughput. TCP Proxy using SOCAT SOCAT can be used to simulate a TCP proxy to proxy the data between the server and the client....

July 17, 2022

Linux Performance Checklist

USE Method USE (Utilization, Saturation and Errors) is a methodology to analyze performance of any system. In summary, the idea is to look at utilization, saturation and errors for each resource in the data path to understand the system bottlenecks. Checklist Following is my reference checklist and one-liners I use for Linux performance analysis. uptime uptime provides the load average of the system for last 1, 5 and 15 mins. It’s a quick way to check the load trend....

July 7, 2022

Classloader Deadlocks!

Class-loader is an Object that is responsible for loading classes. Class-loaders locate the bytecode for a particular class, then transform that bytecode into a usable class in the runtime system. Java introduced parallel class-loaders which are multi-threaded. While loading the classes in parallel can improve performance, it can also lead to deadlocks if you are not careful. In Java 7 release, Oracle did important enhancements to avoid deadlocks. Multi-threading applications are notoriously hard to get right....

September 15, 2016

Holder Pattern

Holder pattern is used to lazy initialize singleton instances. It is used as a replacement for for the expensive initialization of singleton instances using double checked locking. public class Something { private Something() {} private static class LazyHolder { public static finalSomething INSTANCE = newSomething(); } public static Something getInstance() { return LazyHolder.INSTANCE; } } When classloader loads class Something, since there are no static variables, the initialization will complete trivially....

April 18, 2016