Skip to main content

dawdler-series-jdk25

version  License  jdk

Project Introduction​

dawdler-series is a one-stop solution for distributed applications and microservice architectures. Its characteristics are simple, compact, efficient, secure and easy to extend.

Simple: a complete technology stack with a low entry barrier.

Compact: the project has about 100K lines of main Java source code and about 88K lines of tests, roughly 187K lines in total (excluding about 17.9K lines of ported third-party source); the source tree is about 13MB (excluding target and .git); the core runtime jars (util, serialization, core, service-core, discovery-center-core, client, server - 7 in total) add up to about 0.66MB; the minimal runtime depends on 10 third-party groupIds (14 artifacts), and all optional plugins together total 38 groupIds.

Efficient: startup is fast - typically about 50ms to 300ms for a service. If several services are deployed in the same dawdler container they load in parallel, so startup takes as long as the slowest service. A single-machine stress test handles about 379K calls per second (see Performance Benchmark).

Secure: long-lived connections between callers and service providers are built on AIO, and the first connection requires identity authentication and module permission authentication.

Easy to extend: a wide range of extension interfaces and mechanisms are provided, such as load balancing, configuration centers, transaction executors, interceptors, listeners, service creation listeners, serialization extensions and view plugins.

Feature highlights:

MVC framework: used exactly like Spring MVC and covering 80% of its common scenarios.

Distributed session framework: a high-performance implementation of distributed sessions.

Validation framework: front-end/back-end common expression validation. The back end can print the validation rules as front-end JS validation scripts (output through debug logs, for developers' reference) and is flexibly extensible.

RPC framework and container: container-based deployment with an efficient, extremely fast and stable RPC implementation. It supports dynamic service registration, heartbeat probing, reconnection after network loss, graceful shutdown, custom serialization protocols, RPC request load balancing, container-level lifecycle listeners and filters, service creation listeners, service permission management (global users and per-module users, controlling which services a caller may invoke), a load-time weaving AOP implementation based on the AspectJ weaver (the weaving point is embedded in dawdler's custom class loader, so no javaagent is needed), and multi-service deployment (several services sharing one dawdler server).

Transaction framework: usage is essentially the same as Spring transaction and supports read-write splitting; the default rollback rule is the opposite of Spring (any Throwable rolls back by default, see the dawdler-tx-core module documentation).

Circuit breaker: circuit breaker with breaker configuration and fallback, using time-based sliding window statistics.

Distributed transaction framework: a high-performance asynchronous TCC implementation.

Database operation framework: a JDBC wrapper that also supports integrating MyBatis for database operations.

Horizontal sharding: sharding with read-write splitting support.

Cache framework: cache interfaces and implementations, with Redis and Caffeine implementations.

Unified configuration center: an extensible unified configuration center.

Distributed tracing: tracing implemented on top of Pinpoint.

Plugins for common components: redis, elastic-search, rabbitmq.

Why dawdler was built​

Background: dawdler was used early on by a Linux open-source community. Before 2008 it ran as EJB 3.0 on JBoss 4.x, and later migrated to JBoss 7.x and WildFly.

Problem 1: many issues could not be solved inside JBoss, such as long-connection heartbeats, reconnection after disconnect, service registration and discovery, custom serialization protocols, invocation performance and startup speed.

Problem 2: many applications used Spring, whose startup and runtime speed were not ideal - especially startup speed, which made debugging and development inconvenient.

Because of these problems, a version based on NIO was written in 2010, although some container features were incomplete; after 2014 the container dawdler was rewritten from scratch on top of AIO.

dawdler's stability​

The Linux open-source community built on earlier versions of dawdler ran stably on servers for four years. dawdler has also run on a group-buying mall, a mobile community, part of the components of a large domestic B2B e-commerce platform, and a payment platform (where TPS reaches thousands at peak and daily orders are about 8-10 million records - stability there has been excellent with no incidents, so you can use it with confidence). In a single-machine stress test dawdler handles about 379K calls per second.

Performance Benchmark​

Test conditions: single machine, long connections, Kryo serialization, 10-second sampling.

ArchitectureSuccessful requests in 10sSuccessful requests per secondBytes transferred per secondTotal bytes transferred
dawdler-series3791349378801.02101.87MB1.00GB

A single machine handles about 379K successful calls per second, with a throughput of about 101.87MB/s.

The beauty of dawdler​

  1. Modular deployment sharing one JVM: this can be understood as deploying multiple services into one container, so starting a single JVM is enough.
  2. Clients (consumers) do not need to define the same interface definitions that servers (service providers) provide. For example, for a UserService interface that operates on users, other RPC frameworks or EJB 3 typically solve the duplication by shipping a jar; dawdler solves this problem perfectly - dawdler clients (web side, service callers) contain no code and need no packaging at invocation time (nowadays, with maven, beans and APIs no longer need to be loaded this way at all).
  3. Controller debug mode: debug API interfaces at any time without restarting Tomcat or the dawdler container (web side only). This mechanism is completely different from Tomcat hot reload - Tomcat effectively restarts, whereas dawdler updates classes directly through its class loader.
  4. dawdler starts fast, runs efficiently, depends on few third-party jars and is small in size.
  5. Efficient AOP: bytecode weaving is performed at class load time (load-time weaving) by the AspectJ weaver inside dawdler's custom class loader, with no javaagent needed, and woven calls become direct code rather than dynamic proxies.
  6. Full-featured with a low learning cost: it is compatible with the common scenarios of Spring MVC and transaction management (note that the default transaction rollback rule is the opposite of Spring, see the dawdler-tx-core module documentation). You can use the common features of Spring MVC and transactions without Spring, and it provides capabilities for many common components - see the dawdler modules.
  7. A dynamically loaded class filter implements the gateway to improve performance (removing one gateway-to-aggregation-service call), which is very suitable for internet applications with high performance requirements.

dawdler modules (click the section titles to open each sub-module's documentation)​

1. dawdler-server​

The server side of the container.

2. dawdler-core​

The core module shared by dawdler-server and dawdler-client. It includes networking, the service discovery implementation, thread pools, annotations, compression algorithms, etc.

3. dawdler-load-plug​

Remote component loading module. Generally used to build dynamic gateways.

4. dawdler-tx-plug​

Local transaction core module, providing a transaction API essentially identical to Spring (propagation behavior / isolation level / timeout / read-only / transaction synchronization callbacks; the default rollback rule is the opposite of Spring) and managing thread-level connection context. Pure JDBC implementation.

5. dawdler-db-plug​

Server-side database transaction plugin; based on dawdler-tx-core it provides the @DBTransaction transaction aspect, read-write splitting and sharding routing.

6. dawdler-dao-plug​

A simple database access component implemented via reflection. It supports basic CRUD and read-write splitting, and injects DAOs into services. (MySQL only; for other databases MyBatis is recommended.)

7. dawdler-mybatis-plug​

A database plugin implemented with MyBatis; it injects mappers into services, makes the session a singleton and supports read-write splitting.

8. dawdler-client​

Client core code: service discovery, connection pool, dynamic proxy, AOP implementation, load balancing, etc.

9. dawdler-client-plug-web​

Client plugin: web MVC, the client for remotely loaded components, the notifier for remotely loaded components, web listeners, web interceptors, etc.

10. dawdler-client-plug-session​

Client-side high-performance distributed session implementation.

11. dawdler-client-plug-validator​

A powerful front-end/back-end common validator. It supports common expression validation for both JS and the Java back end, is extensible, and can print back-end validation rules as front-end JS validation scripts (output through debug logs, for developers' reference, not delivered to the front end automatically). The Java back end supports grouping, inheritance and exclusion; the JS side supports validation extensions and various event extensions.

12. dawdler-client-plug-velocity​

Client Velocity template plugin, now upgraded to 2.3. It provides a one-line pagination pages directive and dynamic form directives.

13. dawdler-circuit-breaker​

Circuit breaker with breaker configuration and fallback, using time-based sliding window statistics.

14. dawdler-config-center​

Unified configuration center, extensible and injectable.

15. dawdler-distributed-transaction​

Distributed transaction module: the client module is used on the web side, the server module on the dawdler side, plus the compensator module.

16. dawdler-serialization​

Serialization module.

17. dawdler-load-bean​

Classes that need to be serialized in dawdler; used internally by dawdler.

18. dawdler-util​

Common utility module.

19. dawdler-rabbitmq-plug​

RabbitMQ module support, including the client, server and RabbitMQ core modules.

20. dawdler-redis-plug​

dawdler-redis-plug Redis module support, including the client, server and Redis core modules.

21. dawdler-es-plug​

dawdler-es-plug Elasticsearch module support, including the client, server and ES core modules.

22. dawdler-pinpoint-plug​

dawdler's Pinpoint distributed tracing plugin.

23. dawdler-schedule-plug​

Based on Quartz, schedule module support including the client, server and schedule core modules.

24. dawdler-discovery-center​

The root module of the registry, providing service registration, service deregistration and service discovery. ZooKeeper and Consul implementations are currently provided.

25. dawdler-encrypt-generator​

A utility for generating the keys used to encrypt properties and unified configuration center content.

26. dawdler-dependencies​

Maven dependency declarations needed when building projects.

27. dawdler-client-api-generator​

A tool that generates swagger-ui compatible OpenAPI 3.1 JSON from Java source and its Javadoc. It is non-invasive to the source code, easy to pick up, highly efficient and very convenient to use.

28. dawdler-cache-plug​

A cache module usable on both the web side and the server side.

29. dawdler-service-plug​

Service module support, including the client, server and service core modules.

30. dawdler-kafka-plug​

Kafka module support, including the client, server and Kafka core modules.

31. dawdler-i18n-plug​

i18n module support, providing I18nOperator injection on both the web side and the server side.

32. dawdler-web-gateway​

dawdler's gateway module: a lightweight reverse proxy gateway based on a Servlet Filter and Vert.x. Routes are declared in gateway.yml; it proxies HTTP/HTTPS and WebSocket/wss, and can integrate with the registry for service discovery and load balancing. It has built-in path filters such as StripPrefix, RewritePath and SetPath, and is extensible via SPI.

33. dawdler-client-plug-jwt​

JWT authentication module: based on the dawdler-client-plug-web web architecture it provides token issuance, parsing, validation and request authentication. It needs no third-party dependencies - HMAC (HS256/384/512) and RSA (RS256/384/512) signing are implemented natively with the JDK - registers its filters automatically via SPI, and supports the unified configuration center and multiple environments.

34. dawdler-kryo-optimization​

Kryo registration optimization module: during deployment it automatically scans business entity classes implementing Serializable and registers them with Kryo under fixed ids, eliminating the overhead of RPC messages repeatedly carrying class names. Add the dependency on both the client and the server and it just works; no per-class manual registration is needed.

35. dawdler-server-logback​

The logging implementation module for the dawdler server. Based on an extension of logback and a custom SLF4J ServiceProvider, it provides per-module (per-class-loader) logging isolation, so each of the services deployed in a dawdler container loads its own logback.xml configuration independently without affecting the others.

dawdler-runtime​

See dawdler-runtime

Installation​

  1. Download dawdler-runtime-jdk25

  2. Start a registry: run sh zkServer.sh start to start ZooKeeper, or start Consul.

  3. Enter dawdler's bin directory and start it with sh dawdler.sh run (on Windows use dawdler.bat; on Linux or macOS use sh dawdler.sh).

    Running sh dawdler.sh produces the following output:

commands:
run Start dawdler in the current window 在当前窗口启动dawdler

start Start dawdler in a separate window 在后台启动dawdler

stop Stop dawdler 停止dawdler(关闭dawdler之前会从注册中心下线本容器下所有服务,不再接受请求,同时等待处理完客户端的请求之后停止服务器)

stopnow Stop dawdler immediately 立刻停止dawdler,如果客户端有请求未处理完会收到一个强制停止的异常

Quick Start​

1. Software requirements​

dawdler needs the following third-party components:

SoftwareRequiredNotes
jdk-25√openjdk25 is recommended
apache-zookeeper-3.6+xneeded when used as a registry
tomcat-10+xneeded for web services
redis5x|6x|7x+xneeded for cache services
mysql5x | 8xxneeded for database services
elastic-search 8xxneeded for ES services
rabbitmq 3.8+xneeded for messaging
kafka 2x+xneeded for messaging
consul 1.10.x+xneeded as a configuration center or registry

dawdler is built for microservices, so projects are organized as service provider -> caller (web API provider) (please learn about service decomposition principles yourself; they are not covered here).

2.1 dto layer or entity layer​

dto holds the serializable objects transferred in requests or responses.

entity holds the entity objects returned by database queries.

Usually an entity can replace a dto, but if the fields differ a lot it is still recommended to create a separate dto.

2.2 Service interface layer​

service interfaces declare the service and are used in both the provider and the caller projects.

2.3 Service provider​

Provides the concrete implementation of the service interfaces and is deployed and run under dawdler's deploys directory.

Code that accesses the database also lives here, such as MyBatis mappers; simply inject them into the ServiceImpl.

2.4 Service caller​

Calls the services provided by service providers, either via API or via dynamic proxy objects.

A web application typically injects the dynamic proxy object into a web Controller for remote calls.

2.5 Project structure diagram​

Taking an e-commerce project as an example:

--shop
--api #api interfaces; a pom-type parent module.
| --user-api
| --order-api #Holds interface definitions, dtos and entities.
| --product-api
--load-web #Remote loading services; a pom-type parent module.
| --core-load-web #For loading common components, e.g. a filter that replaces the gateway, to be loaded remotely by the web-api modules.
--service #Concrete service implementations deployed in dawdler; a pom-type parent module.
| --user-service
| --order-service #Holds service implementations, daos, mappers and service startup listeners.
| --product-service
--web-api #Provides web services, usually deployed in a web container; a pom-type parent module.
| --user-web-api
| --order-web-api
| --product-web-api

If you need help, send an email to jackson.song@dawdler.club.

Third-Party Components and Open-Source Licenses​

This project is released under the MIT license (see LICENSE) and also contains source code ported and adapted from several third-party projects. All such source code retains the upstream copyright notices and license terms; the complete list is in NOTICE:

ComponentLicenseLocation in this repository
ReflectASMBSD-3-Clause (full text in LICENSE-ReflectASM.txt)MethodAccess, FieldAccess, ConstructorAccess, AccessClassLoader and PublicConstructorAccess under club.dawdler.util.reflectasm
Spring FrameworkApache-2.0club.dawdler.util.spring (including the antpath sub-package)
NettyApache-2.0club.dawdler.util.HashedWheelTimer, club.dawdler.core.thread.DefaultThreadFactory

The class names in club.dawdler.util.reflectasm are kept consistent with ReflectASM, while the implementations have been rewritten as required by this framework. In accordance with clause 1 of BSD-3-Clause (redistributions of source code must retain the copyright notice, the list of conditions and the disclaimer), each file header keeps the complete upstream BSD-3-Clause notice after the MIT license header; the full BSD text is also distributed in the dawdler-util jar (META-INF/LICENSE-ReflectASM.txt) to satisfy clause 2 of that license for binary redistribution.