EP125: How does Garbage Collection work?

EP125: How does Garbage Collection work?

This week’s system design refresher:
͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­
Forwarded this email? Subscribe here for more

This week’s system design refresher:

  • Linux Performance Tools! (Youtube video)

  • How does Garbage Collection work?

  • A Cheat Sheet for Designing Fault-Tolerant Systems

  • 10 System Design Tradeoffs You Cannot Ignore

  • SPONSOR US


WorkOS: Modern Identity Platform for B2B SaaS (Sponsored)

Start selling to enterprises with just a few lines of code.

→ WorkOS provides a complete user management solution along with SSO, SCIM, Audit Logs, & Fine-Grained Authorization.

→ Unlike other auth providers that rely on user-centric models, WorkOS is designed for B2B SaaS with an org modeling approach.

→ The APIs are flexible, easy-to-use, and modular. Pick and choose what you need and integrate in minutes.

→ User management is free up to 1 million MAUs and comes standard with RBAC, bot protection, MFA, & more.

Get Started Today


Linux Performance Tools!


How does Garbage Collection work?

Garbage collection is an automatic memory management feature used in programming languages to reclaim memory no longer used by the program.

No alternative text description for this image
  • Java
    Java provides several garbage collectors, each suited for different use cases:

    1. Serial Garbage Collector: Best for single-threaded environments or small applications.

    2. Parallel Garbage Collector: Also known as the "Throughput Collector."

    3. CMS (Concurrent Mark-Sweep) Garbage Collector: Low-latency collector aiming to minimize pause times.

    4. G1 (Garbage-First) Garbage Collector: Aims to balance throughput and latency.

    5. Z Garbage Collector (ZGC): A low-latency garbage collector designed for applications that require large heap sizes and minimal pause times.

  • Python
    Python's garbage collection is based on reference counting and a cyclic garbage collector:

    1. Reference Counting: Each object has a reference count; when it reaches zero, the memory is freed.

    2. Cyclic Garbage Collector: Handles circular references that can't be resolved by reference counting.

  • GoLang
    Concurrent Mark-and-Sweep Garbage Collector: Go's garbage collector operates concurrently with the application, minimizing stop-the-world pauses.


Latest articles

If you’re not a paid subscriber, here’s what you missed.

  1. A Crash Course on Architectural Scalability

  2. A Crash Course on Microservices Design Patterns

  3. A Crash Course on Domain-Driven Design

  4. "Tidying" Code

  5. A Crash Course on Relational Database Design

To receive all the full articles and support ByteByteGo, consider subscribing:


A Cheat Sheet for Designing Fault-Tolerant Systems

diagram

Designing fault-tolerant systems is crucial for ensuring high availability and reliability in various applications. Here are six top principles of designing fault-tolerant systems:

  1. Replication
    Replication involves creating multiple copies of data or services across different nodes or locations.

  2. Redundancy
    Redundancy refers to having additional components or systems that can take over in case of a failure.

  3. Load Balancing
    Load balancing distributes incoming network traffic across multiple servers to ensure no single server becomes a point of failure.

  4. Failover Mechanisms
    Failover mechanisms automatically switch to a standby system or component when the primary one fails.

  5. Graceful Degradation
    Graceful degradation ensures that a system continues to operate at reduced functionality rather than completely failing when some components fail.

  6. Monitoring and Alerting
    Continuously monitor the system's health and performance, and set up alerts for any anomalies or failures.


10 System Design Tradeoffs You Cannot Ignore

If you don’t know trade-offs, you DON'T KNOW system design.

graphical user interface
  1. Vertical vs Horizontal Scaling
    Vertical scaling is adding more resources (CPU, RAM) to an existing server.

    Horizontal scaling means adding more servers to the pool.

  2. SQL vs NoSQL
    SQL databases organize data into tables of rows and columns.

    NoSQL is ideal for applications that need a flexible schema.

  3. Batch vs Stream Processing
    Batch processing involves collecting data and processing it all at once. For example, daily billing processes.

    Stream processing processes data in real time. For example, fraud detection processes.

  4. Normalization vs Denormalization
    Normalization splits data into related tables to ensure that each piece of information is stored only once.

    Denormalization combines data into fewer tables for better query performance.

  5. Consistency vs Availability
    Consistency is the assurance of getting the most recent data every single time.

    Availability is about ensuring that the system is always up and running, even if some parts are having problems.

  6. Strong vs Eventual Consistency
    Strong consistency is when data updates are immediately reflected.

    Eventual consistency is when data updates are delayed before being available across nodes.

  7. REST vs GraphQL
    With REST endpoints, you gather data by accessing multiple endpoints.

    With GraphQL, you get more efficient data fetching with specific queries but the design cost is higher.

  8. Stateful vs Stateless
    A stateful system remembers past interactions.

    A stateless system does not keep track of past interactions.

  9. Read-Through vs Write-Through Cache
    A read-through cache loads data from the database in case of a cache miss.

    A write-through cache simultaneously writes data updates to the cache and storage.

  10. Sync vs Async Processing
    In synchronous processing, tasks are performed one after another.

    In asynchronous processing, tasks can run in the background. New tasks can be started without waiting for a new task.

Over to you: Which other tradeoffs have you encountered?


SPONSOR US

Get your product in front of more than 1,000,000 tech professionals.

Our newsletter puts your products and services directly in front of an audience that matters - hundreds of thousands of engineering leaders and senior engineers - who have influence over significant tech decisions and big purchases.

Space Fills Up Fast - Reserve Today

Ad spots typically sell out about 4 weeks in advance. To ensure your ad reaches this influential audience, reserve your space now by emailing sponsorship@bytebytego.com

 
Like
Comment
Restack
 

© 2024 ByteByteGo
548 Market Street PMB 72296, San Francisco, CA 94104
Unsubscribe

Get the appStart writing


by "ByteByteGo" <bytebytego@substack.com> - 11:35 - 17 Aug 2024