Blog

What Backend Engineers Need to Know for Interviews — Load Balancer vs. Reverse Proxy vs. API Gateway vs. HAProxy

Backend engineers often encounter the following technologies and tools in their daily work or during interviews:

  • Load Balancer
  • Reverse Proxy
  • API Gateway
  • HAProxy

The commonality between these technologies is that they are all on the front line of handling traffic, but their uses differ, which can lead to confusion.

This article will clarify the differences between these technologies and tools to understand their respective functions and application scenarios, avoiding common misunderstandings.

Posted on  Sep 11, 2024  in  Backend Interview Preparation  by  Amo Chen  ‐ 6 min read

Understanding Go's Defer, Panic(), Recover() for Exception/Error Handling through Python's Try Except

During the process of learning Go, many might find themselves puzzled by the way Go handles exceptions/errors using defer(), panic(), recover(). Especially for developers already familiar with languages like Java, JavaScript, and Python, the try...catch, try-except mechanisms seem more intuitive and readable during development.

However, understanding Go’s defer(), panic(), recover() can be easier if we start from familiar patterns. By doing so, what initially seems complex may become much clearer.

This article will help you learn how Go handles exceptions from the perspective of Python’s try-except mechanism.

Posted on  Mar 27, 2024  in  Go Programming - Beginner Level  by  Amo Chen  ‐ 7 min read

How to Neatly Display Parallel Output in Terminal?

When using modules like multiprocessing or threading for parallel processing, have you ever wondered how to print string messages from each process or thread effectively?

Most people would simply use print() in the terminal. However, when the output is too long or too much, it might not be particularly useful. In such scenarios, it’s often best to write the outputs to a file so you can trace back any issues later.

Still, most of the time, we want to know the latest status of each executing unit, like which step it’s currently at. If these outputs continue to pile up in the terminal, it inevitably makes the terminal quite messy.

In this article, I will introduce a method to refresh and overlay outputs of parallel processing, so you can see the latest status of each unit while keeping the terminal clean and elegant!

Posted on  Mar 13, 2024  in  Python Programming - Intermediate Level  by  Amo Chen  ‐ 3 min read

Explanation of MongoDB Write Concern and Read Concern

Understanding MongoDB Write Concern and Read Concern is essential when working with MongoDB cluster environments. Lack of familiarity with these two crucial concepts may lead to unexpected operations and even result in bugs.

This article aims to introduce MongoDB Write Concern and Read Concern in an easy-to-understand manner.

Posted on  Jan 11, 2024  by  Amo Chen  ‐ 8 min read

How to Use the depends_on Setting in Docker Compose

When setting up a development environment using Docker Compose, you might encounter service dependency issues. Take a simple example: the database container usually needs to start up first before the API server container can follow. This is because the API server might need to establish a connection pool with the database before it can offer API services; otherwise, errors could occur and cause the container to fail to start.

In this situation, the API server container relies on the database container to function properly, which is what we refer to as service dependency. Without understanding service dependencies, you could frequently experience inconsistent results with docker-compose, sometimes successful and sometimes not, as services might or might not start up in time or be ready.

To address this, Docker Compose provides a solution with the depends_on setting.

This article will guide you on how to use the depends_on setting.

Posted on  Dec 14, 2023  in  Docker  by  Amo Chen  ‐ 6 min read

Python - Learning the weakref Module Through Examples

Python is a programming language equipped with a garbage collection (GC) mechanism, which is essentially an automated memory management system. In essence, it reclaims memory spaces that are no longer in use by the program, releasing them to prevent the problems associated with steadily decreasing available memory, such as program errors or failure to execute processes.

The GC mechanism is designed to lessen the burden on developers. In contrast, languages like C require manual memory deallocation (further details can be found in the free() function), and failure to release memory often leads to memory leaks. By relying on GC, developers can avoid worrying about memory management issues, thus improving development efficiency and reducing the likelihood of errors.

Python implements its garbage collection mechanism using a technique known as reference counting.

Last updated on  Jul 28, 2024  by  Amo Chen  ‐ 9 min read

Introduction to a Handy Python Package - structlog

When starting with Python’s logging module, many of us have encountered confusion, as with the following code example:

import logging

log = logging.getLogger(__name__)
log.info('Hello')

We might expect this code to print the string Hello, but it doesn’t.

This is because the default log level for Python’s logging module is WARNING, so only messages at WARNING, ERROR, or CRITICAL levels are displayed.

To properly use the logging module, setting it up is necessary, which often means consulting the Python documentation. This isn’t a problem with Python per se, but rather a design philosophy difference.

So, is there a package more intuitive and easier to use than the built-in logging module?

The answer is “yes,” and that is the structlog package, which this article introduces.

Posted on  Aug 30, 2023  in  Python Module Recommendations , Python Programming - Beginner Level  by  Amo Chen  ‐ 4 min read

Introduction to the Python Package - JMESPath (A JSON Query Language Similar to jq)

JMESPath is a Python package with functions similar to jq, enabling Python developers to query and restructure JSON data with a syntax akin to jq. This is done by converting JSON into Python’s native data types using the json module. Proper use of JMESPath can simplify code and enhance readability.

This article will introduce the methods for using JMESPath.

Posted on  Jul 12, 2023  in  Python Module Recommendations  by  Amo Chen  ‐ 5 min read