Backend Development 14 min read

Evolution of Youzan's Node Backend Framework: From Koa to Astroboy 2.0 and Service Integration

The article recounts Youzan’s transition from a Koa‑based internal system to the Astroboy framework—first version for decoupling code, then Astroboy 2.0 built on Koa2 with a customizable upper‑layer Base Framework, extensible plugins, and a Go‑based Tether proxy that streamlines Node‑to‑Java service integration and improves performance.

Youzan Coder
Youzan Coder
Youzan Coder
Evolution of Youzan's Node Backend Framework: From Koa to Astroboy 2.0 and Service Integration

On April 21, Youzan held its first "Youzan Technical Development Day" where the author shared a year of Node practice. This article expands on that talk.

It describes the evolution of Youzan's Node backend framework, starting with a Koa‑based internal management system, moving to a project template, then to the Astroboy framework (v1.0) to decouple framework code from business code, and later to Astroboy 2.0 with performance improvements, custom upper‑layer framework capability, extensible plugin mechanism, and progressive development.

Key features of Astroboy 2.0 include:

Built on Koa2 with excellent performance.

Ability to customize an upper‑layer framework (Youzan Base Framework).

Highly extensible plugin system.

Progressive development model.

The Youzan Base Framework integrates core services such as the internal logging/monitoring system (Tianwang), health checks, full‑link monitoring, and Dubbo service calls.

Business logic can be built directly on the Base Framework for simple cases, or a custom business framework (e.g., Iron Base Framework) can be layered on top for complex scenarios.

Core concepts

Application : an instantiated project derived from the framework, composed of plugins.

Framework : Astroboy, a wrapper around Koa2.

Plugin : a modular unit (service, middleware, lib) packaged as an NPM module with a defined directory structure, enabling decoupled development.

Plugin management example (enable plugin, set path):

'astroboy-cookie': {
    enable: true,
    path: path.resolve(__dirname, '../plugins/astroboy-cookie')
}

When a plugin is stable it can be published as an NPM package:

'astroboy-cookie': {
    enable: true,
    package: 'astroboy-cookie'
}

Disabling a plugin is as simple as setting enable to false .

Node service integration

To support Youzan's service‑oriented architecture, Node acts as a thin middle layer that handles template rendering, business orchestration, and HTTP proxying to Java services.

Java services are registered in a service registry (ETCD/Zookeeper). Node originally called Java directly via HTTP or Dubbo, but this approach introduced maintenance and performance issues.

Youzan introduced a Go‑based proxy layer called Tether. Node now calls Tether over HTTP, while Tether handles service discovery, protocol translation, load balancing, and long‑connection management.

Example of a Node service invoking a Java method through the base service:

const Service = require('../base/BaseService');

class GoodsService extends Service {
    /**
     * Get goods detail by alias
     * @param {String} alias
     */
    async getGoodsDetailByAlias(alias) {
        const result = this.invoke(
            'com.youzan.ic.service.GoodsService',
            'getGoodsDetailByAlias',
            [alias]
        );
        return result;
    }
}

module.exports = GoodsService;

Node also uses an agentkeepalive HTTP agent to reuse TCP connections and reduce latency:

const Agent = require('agentkeepalive');

module.exports = new Agent({
    maxSockets: 100,
    maxFreeSockets: 10,
    timeout: 60000,
    freeSocketKeepAliveTimeout: 30000
});

Benefits of this architecture include simple HTTP‑based consumption for front‑end developers, low multi‑language integration cost, and a clear place to optimize the protocol layer.

service integrationperformance optimizationMicroservicesBackend Developmentplugin architectureNode.jsframework
Youzan Coder
Written by

Youzan Coder

Official Youzan tech channel, delivering technical insights and occasional daily updates from the Youzan tech team.

0 followers
Reader feedback

How this landed with the community

login 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.