Loky Wang's Technical Documentation

website·Indexed 30 days ago

https://loky.wang

A collection of technical guides and notes covering Kubernetes (K8S) architecture, Pods, and resource scheduling; Redis clustering, CAP theorem, and master-slave replication; TDengine integration with MybatisPlus; MongoDB geospatial design for LBS; and log management stacks using EFK, Kafka, and Logstash.

Tokens
54.6K
Snippets
230
Records
338
Agent score
50%

What's inside Loky Wang's Technical Blog

  1. Overview of Java Memory Space components

    Java memory management involves several distinct storage areas with different performance and access characteristics:

    • Registers (存储器): The fastest storage area located inside the processor. It has very limited space and cannot be manipulated directly by the developer.
    • Stack (堆栈): Used for method execution and local variables.
    • Heap (堆): Used for dynamic memory allocation of objects.
    • Constant Pool (常量存储): Stores constant values and literal strings.
    • Non-RAM Storage (非RAM存储): Persistent storage outside of volatile memory.
  2. Overview of Kubernetes distributed system capabilities

    Kubernetes is a container-based distributed architecture solution derived from Google's Borg. It serves as a comprehensive platform for distributed system development and support, providing the following core capabilities:

    • Cluster management with multi-level security and admission mechanisms.
    • Multi-tenant application support.
    • Transparent service registration and discovery.
    • Built-in intelligent load balancing.
    • Automated fault detection and self-healing.
    • Rolling updates and online scaling.
    • Extensible resource scheduling and multi-granularity resource quota management.
  3. Overview of Kubernetes cluster deployment methods

    There are several ways to deploy a Kubernetes cluster depending on the environment:

    • minikube: Best for local development and testing on Windows, macOS, or Linux. It runs a single-node or multi-node cluster on a personal computer.
    • kubeadm: The standard tool for creating and managing production-ready, secure clusters in a user-friendly way.
    • Binary Installation: Downloading binaries directly from the official GitHub repository. This is more complex to set up but is recommended for high-stability production environments.
  4. Overview of MQTT Protocol Characteristics

    MQTT (Message Queuing Telemetry Transport) is an ISO-standard, lightweight messaging protocol based on the publish/subscribe model. It is primarily used in IoT and smart home environments for communication between devices and applications. Key characteristics include:

    • Transport: Typically uses TCP/IP for ordered, lossless, bidirectional connections, though UDP-based versions (MQTT-SN) exist.
    • Efficiency: Uses a small 1-byte fixed header and 2-byte heartbeat packets to minimize transmission overhead and network traffic.
    • Scalability: Supports one-to-many message publishing, allowing servers to manage numerous devices via multiple subscription topics.
  5. Configure a high-availability 3-master 3-slave cross-replication cluster

    To achieve high availability, implement a cross-replication architecture where each slave is hosted on a different physical machine than its corresponding master. This ensures the cluster remains operational even if one physical host fails. Use the CLUSTER REPLICATE command to configure a node as a slave of a specific master. Additionally, enable RDB persistence on all nodes to prevent data loss during restarts.
    # Example RDB persistence configuration in redis.conf
    save 60 10000
    save 300 10
    save 900 1
    
    # Cluster settings
    cluster-enabled yes
    cluster-config-file node_6380.conf
    cluster-node-timeout 15000
  6. Perform a manual failover in Redis Cluster

    The CLUSTER FAILOVER command is used to switch the roles of a master and its replica. This is typically used to restore the original architecture after a node has recovered from a failure. The process involves the replica promoting itself to master and the current master becoming a replica.

    Warning: In production environments with large datasets, this process may be slow because it involves data synchronization. Do not manually execute CLUSTER REPLICATE on the master during this process, as it may trigger a full data wipe (similar to SLAVEOF) and lead to total data loss for that node.

    # Connect to the replica node and execute failover
    redis-cli -h 192.168.81.210 -p 6380
    192.168.81.210:6380> CLUSTER FAILOVER
  7. Understand the Kubernetes Layered Architecture

    The Kubernetes ecosystem is organized into several functional layers:

    • Core Layer: The central functionality providing APIs for high-level applications and a plugin-based execution environment for internal applications.
    • Application Layer: Handles deployments (stateless, stateful, batch jobs, cluster apps) and routing (service discovery, DNS).
    • Management Layer: Handles system metrics (infrastructure, container, network), automation (autoscaling, dynamic provisioning), and policy management (RBAC, Quota, PSP, NetworkPolicy).
    • Interface Layer: The entry point for users via kubectl CLI, client SDKs, and cluster federation.
    • Ecosystem:
      • External: Logging, monitoring, CI/CD, Workflow, FaaS, ChatOps.
      • Internal: CRI, CNI, CSI, image registries, Cloud Providers, and cluster configuration.
  8. Manage TDengine Data Nodes (DNODE)

    Data nodes are the fundamental storage units in a TDengine cluster. It is recommended to create the DNODE via SQL first and then start the corresponding DNODE process so it can join the cluster immediately using the firstEP configuration. Each successful DNODE is assigned a unique ID.
    -- Create a data node (endpoint format 'hostname:port' or separate hostname and port)
    CREATE DNODE 'hostname:port';
    CREATE DNODE hostname PORT port_val;
    
    -- List all data nodes
    SHOW DNODES;
    
    -- Delete a data node (Recommended: delete the DNODE first, then stop the process)
    DROP DNODE dnode_id;
  9. Understand Redis Cluster architecture and data distribution

    Redis Cluster is a distributed solution (introduced in v3.0) designed to overcome the limitations of Redis Sentinel, such as low resource utilization (where only the master provides service) and performance bottlenecks on the master node.

    Key architectural concepts:

    • Data Sharding: Uses a hash sharding rule to distribute data evenly across nodes.
    • Hash Slots: The cluster consists of 16,384 hash slots. Every slot must be assigned to at least one master node for the cluster to function. Slots are distributed among nodes in roughly equal quantities (allowing for a 2% error).
    • High Availability: Each master node typically has one or more slave nodes. If a master fails, a slave is automatically promoted to master.
    • Horizontal Scaling: Capacity can be increased by adding more nodes, aggregating the memory of all participating machines.
  10. Understand MySQL Partitioning fundamentals

    MySQL partitioning is a database optimization technique that divides a large table or index into smaller, more manageable segments called partitions. Each partition can be stored, backed up, and indexed independently.

    Key benefits include:

    • Query Performance: MySQL uses 'partition pruning' to search only the partitions containing relevant data, reducing the amount of data scanned.
    • Maintenance: Individual partitions can be backed up, restored, or optimized without affecting the entire table.
    • Data Lifecycle Management: Old data (e.g., logs) can be quickly removed or archived by dropping or archiving a specific partition.
    • Scalability: Data can be distributed across multiple physical storage devices when a table exceeds the capacity of a single device.
  11. Design a MongoDB data model for mobile cell towers

    When storing mobile cell tower information, MongoDB is recommended due to the semi-structured nature of the data and the need for strong geospatial querying. The model should support basic tower info, efficient geospatial lookups (e.g., finding nearby towers), attribute filtering (operator, frequency band), and low-latency responses for positioning services.