Why Zuoyebang Switched to Go: Inside the Zgin Backend Framework

Zuoyebang replaced its PHP monolith with the Go‑based Zgin framework to overcome microservice, performance, and cloud‑native limitations, delivering a modular, high‑performance backend that supports service governance, efficient logging, and seamless deployment across thousands of services.

Zuoyebang Tech Team
Zuoyebang Tech Team
Zuoyebang Tech Team
Why Zuoyebang Switched to Go: Inside the Zgin Backend Framework

Background: Moving to Go

Zuoyebang initially used PHP for rapid business growth, but the PHP stack (ODP) faced issues: weak microservice support, high resource consumption, and poor cloud‑native compatibility. To address these, the team adopted Go as the primary server language and created the Zgin framework, derived from Gin, focusing on stability, performance, and ecosystem integration.

Framework Position in the Technical Stack

Zgin serves as the bridge between business development and infrastructure (architecture, security, operations, DBA). It enforces development standards, improves efficiency, ensures quality, and integrates with cloud‑native service governance, observability, and containerization.

Design Philosophy

The framework standardizes the web request lifecycle, abstracts and separates service processes, and aims for excellent performance, reliability, and clear functionality. It provides common components to simplify business extensions and connects development with infrastructure.

Core Capabilities

Server Module: Enhanced Gin with custom optimizations.

Cloud‑Native Service Governance: Supports service discovery, observability, and synchronous/asynchronous communication.

Reusable Components: Ready‑to‑use, stable, performance‑tuned, and patched open‑source libraries.

Developer Efficiency: Tools for code generation, local/k8s environment sync, and other productivity aids.

Standardization & Security: Coding standards, directory layout, Go conventions, and RASP security protection.

Standardization Details

Development, directory, and Go language standards.

Deployment, runtime, and observability guidelines.

Security

Provides business‑transparent RASP security safeguards.

Architecture Diagram

HTTP Server Module

Performance Optimizations

Based on Gin, Zgin adds several optimizations:

Netpool / Mesh UDS: Leverages mesh‑proxy connections via UDS with zero‑copy, moving connection‑pool logic to the underlying infrastructure.

GC Optimization: Adaptive GOGC based on container memory, uses sync.Pool for object reuse, and reduces GC pressure.

GMP Optimization: Auto‑adjusts maxProcs to container limits and optimizes NUMA scheduling on large bare‑metal servers.

Task Extensions

Beyond the core HTTP server, Zgin supports automatic task handling (one‑off, periodic, scheduled) with request ID propagation and middleware support.

Exposed Common Interfaces

Readiness Probe: Default service readiness check, customizable by business.

pprof Interface: Unified performance profiling, addressing Go CPU profiler limitations.

Go Runtime Metrics: Exposes GC, memory, and goroutine metrics in a standard format.

Common Components

Components are grouped into three categories:

General Client Components

Includes message queues, object storage, data stores, and HTTP client libraries, all integrated with the mesh governance system.

Base Components

Selected or custom‑developed libraries (e.g., JSON, coroutine pools, logging) optimized for performance and reliability.

Logging

Zgin replaces Gin’s minimal logging with zlog, offering structured JSON logs, manual string concatenation for high‑speed encoding, sync‑pool reuse, and buffered asynchronous output, achieving up to 40% CPU reduction and 90% latency improvement in tests.

Utility Tools

Code generation scaffolding for standardized service structure.

Performance analysis tools integrating pprof and runtime metrics.

Test environment proxy for local‑to‑test traffic forwarding.

Framework Promotion & Adoption

Challenges include long onboarding cycles, version‑specific bugs, and low upgrade motivation. Solutions involve tooling, documentation, reverse package management to track usage, automated notifications, CI gatekeeping, and smooth upgrade strategies.

Problem Diagnosis

Provides platform tools for monitoring, logging, distributed tracing, and runtime analysis, enabling businesses to self‑diagnose before escalating to the framework team.

Performance Gains

Benchmark comparing native Gin vs. Zgin (2 CPU/4 GB pod):

CPU usage (lower is better): Native Gin: 1.4, 2, 3, 4 at QPS 600‑1500 Zgin: 0.8, 1.3, 1.5, 1.8, 2.5, 3 at QPS 600‑2500

Latency (T99): Native Gin: 18 ms, 23 ms, 28 ms, 100 ms at QPS 600‑1500 Zgin: 16 ms, 21 ms, 23 ms, 28 ms, 32 ms, 60 ms at QPS 600‑2500

Overall CPU savings are about 30% due to deep infrastructure optimizations.

Real‑World Service Migration

Migration of production services from native Gin to Zgin showed significant improvements in latency and resource usage (see accompanying charts).

Adoption Scale

After two years, Go became the most used backend language at Zuoyebang, with all Go projects built on Zgin, supporting over 600 service modules and more than 10,000 pods.

Summary & Outlook

The Zgin framework evolved by addressing concrete business needs, extending open‑source Gin, and delivering a cloud‑native ecosystem that supports development, deployment, operation, and maintenance, while recognizing that large‑scale adoption requires continuous governance and incremental upgrades.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

backendGo
Zuoyebang Tech Team
Written by

Zuoyebang Tech Team

Sharing technical practices from Zuoyebang

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.