Backend Development 8 min read

Best Practices for Application Layering: Alibaba's Architecture Guidelines and Optimized Design

The article discusses common pitfalls in application layering, presents Alibaba's clear multi‑layer architecture—including Open Interface, Terminal Display, Web, Service, Manager, and DAO layers—offers an optimized layering model with Thrift, explains domain model conversions, and provides practical recommendations for maintainable backend design.

Top Architect
Top Architect
Top Architect
Best Practices for Application Layering: Alibaba's Architecture Guidelines and Optimized Design

1. Background

Many developers treat application layering superficially, often mixing responsibilities across controller, service, and mapper layers, which leads to tangled code, poor reusability, and difficult maintenance.

2. Alibaba's Layer Specification

Open Interface Layer : Exposes Service methods as RPC or HTTP interfaces, handling gateway security and traffic control.

Terminal Display Layer : Handles template rendering for various clients (Velocity, JS, JSP, mobile).

Web Layer : Performs request routing, basic parameter validation, and simple non‑reusable business processing.

Service Layer : Contains concrete business logic with relatively low reusability.

Manager Layer : Provides reusable logic such as cache, MQ, or composite operations, and may handle data conversion for HTTP/ RPC managers.

DAO Layer : Direct data access to databases like MySQL, Oracle, HBase.

3. Optimized Layering (Considering Thrift RPC)

The added Thrift layer functions similarly to a controller. Recommended structure:

Controller/TService : Light business logic, parameter validation, exception handling.

Service : Core business processing; each controller method should map to a distinct service method to avoid duplicated orchestration logic.

Manager : Reusable logic, possibly aggregating multiple managers.

DAO : Database access, only invoked by its corresponding service.

4. Domain Model Conversions

Alibaba's guidelines define several model types:

DO (Data Object): Directly maps to database tables.

DTO (Data Transfer Object): Used for data transfer between Service/Manager and external callers.

BO (Business Object): Encapsulates business logic output from Service.

AO (Application Object): Near‑presentation layer, low reuse.

VO (View Object): Passed to view/template engines.

Query: Encapsulates query parameters, avoiding Map usage for >2 parameters.

Excessive conversions across layers can lead to performance overhead and maintenance burden.

5. Recommendations

Allow Service/Manager layers to operate on domain models, handling business logic and data assembly.

Prevent Controller/TService from passing its models directly to DAO, preserving responsibility boundaries.

Similarly, DAO should not receive models from Controller/TService.

6. Conclusion

A well‑designed layering scheme enhances code reuse, clarifies responsibilities, and simplifies maintenance, though teams may adapt the guidelines to fit their specific development practices.

backend designsoftware engineeringlayered architecturedaoService Layermanager layer
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

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.