How the JVM Works
We compile, run, and debug Java code all the time. But what exactly does the JVM do between compile and run?
Here's the flow:
Build: javac compiles your source code into platform-independent bytecode, stored as .class files, JARs, or modules.
Load: The class loader subsystem brings in classes as needed using parent delegation. Bootstrap handles core JDK classes, Platform covers extensions, and System loads your application code.
Link: The Verify step checks bytecode safety. Prepare allocates static fields with default values, and Resolve turns symbolic references into direct memory addresses.
Initialize: Static variables are assigned their actual values, and static initializer blocks execute. This happens only the first time the class is used.
Memory: Heap and Method Area are shared across threads. The JVM stack, PC register, and native method stack are created per thread. The garbage collector reclaims unused heap memory.
Execute: The interpreter runs bytecode directly. When a method gets called multiple times, the JIT compiler converts it to native machine code and stores it in the code cache. Native calls go through JNI to reach C/C++ libraries.
Run: Your program runs on a mix of interpreted and JIT-compiled code. Fast startup, peak performance over time.
🔥Marvel Rivals 5680 Lattice GIVEAWAY🔥
➡️ TO ENTER:
✅ Follow @RivalsNewsLeaks
✅ Retweet
✅ Comment your platform
⏰ Giveaway ends in 7 days! All platforms and regions can participate.
Load Balancer Basics
Load balancers are essential components in modern application architectures, designed to distribute incoming traffic efficiently across multiple servers. Load balancers improve application performance, availability, and scalability.
Traffic Distribution:
Load balancers evenly distribute incoming traffic among a pool of servers, ensuring optimal resource utilization and preventing any single server from becoming overwhelmed. Algorithms like round-robin or least connections are used to select the most suitable server for each request.
High Availability:
If a server fails, the load balancer automatically redirects traffic to the remaining healthy servers. This ensures that the application remains accessible even in the event of server failures, minimizing downtime and improving overall availability.
SSL Termination:
Load balancers can handle SSL/TLS encryption and decryption, offloading this CPU-intensive task from backend servers. This improves server performance and simplifies SSL certificate management.
Session Persistence:
For applications that require maintaining user sessions on a specific server, load balancers support session persistence. They ensure that subsequent requests from a user are consistently routed to the same server, preserving session integrity.
Scalability:
Load balancers facilitate horizontal scaling by allowing easy addition of servers to the pool. As traffic increases, new servers can be provisioned, and the load balancer will automatically distribute the load across all servers, enabling seamless scalability.
Health Monitoring:
Load balancers continuously monitor server health and performance. They exclude unhealthy servers from the pool, ensuring that only healthy servers handle incoming requests. This proactive monitoring maintains optimal application performance.
–
Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): https://t.co/6j06DUIbVn
Session, Cookie, JWT, Token, SSO, and OAuth 2.0 Explained in One Diagram
When you login to a website, your identity needs to be managed. Here is how different solutions work:
- Session - The server stores your identity and gives the browser a session ID cookie. This allows the server to track login state. But cookies don't work well across devices.
- Token - Your identity is encoded into a token sent to the browser. The browser sends this token on future requests for authentication. No server session storage is required. But tokens need encryption/decryption.
- JWT - JSON Web Tokens standardize identity tokens using digital signatures for trust. The signature is contained in the token so no server session is needed.
- SSO - Single Sign On uses a central authentication service. This allows a single login to work across multiple sites.
- OAuth2 - Allows limited access to your data on one site by another site, without giving away passwords.
- QR Code - Encodes a random token into a QR code for mobile login. Scanning the code logs you in without typing a password.
Over to you: QR code logins are gaining popularity. Do you know how it works?
–
Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): https://t.co/uc5M7CdXXC
Just had an amazing random interaction with a new founder explaining his startup to me.
Him: "Do you know Terraform?"
Me: "I do!"
Him: <explains TF concepts>
Me: "I've got it yeah, I started the project."
Him: "Wait, what?"
I tried to joke it off as much as possible (I really don't care), but I think he died a little bit inside. 😭 I wasn't even going to tell him, honestly, but I felt bad he was spending time explaining TF concepts that I helped create so I cut him short.
CAP, BASE, SOLID, KISS, What do these acronyms mean? Next week's topics will be listed at the end.
The diagram below explains the common acronyms in system designs.
🔹 CAP
CAP theorem states that any distributed data store can only provide two of the following three guarantees:
1. Consistency - Every read receives the most recent write or an error.
2. Availability - Every request receives a response.
3. Partition tolerance - The system continues to operate in network faults.
🔹 BASE
The ACID (Atomicity-Consistency-Isolation-Durability) model used in relational databases is too strict for NoSQL databases. The BASE principle offers more flexibility, choosing availability over consistency. It states that the states will eventually be consistent.
🔹 SOLID
SOLID principle is quite famous in OOP. There are 5 components to it.
1. SRP (Single Responsibility Principle)
2. OCP (Open Close Principle)
3. LSP (Liskov Substitution Principle)
4. ISP (Interface Segregation Principle)
5. DIP (Dependency Inversion Principle)
🔹 KISS
"Keep it simple, stupid!" is a design principle first noted by the U.S. Navy in 1960. It states that most systems work best if they are kept simple.
Over to you: Have you invented any acronyms in your career?
Next week, we will talk about:
- Service mesh
- REST API Authentication Methods
- Most popular network protocols (YouTube)
- What happens when Linux startup?
- K8S service types
–
Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): https://t.co/uc5M7CdXXC