SOFABoot Documentation

repository·master·Indexed 26 days ago

https://github.com/sofastack/sofa-boot

An open-source Java development framework based on Spring Boot, enhanced by Ant Group for large-scale microservices. It provides enterprise-grade capabilities including readiness checks for deployment automation, class isolation via SOFAArk to resolve dependency conflicts, Spring context isolation for modular development, and unified logging. SOFABoot also offers pluggable Spring Boot starters for seamless integration with SOFAStack middleware.

Tokens
1.1K
Snippets
2
Records
9
Agent score
40%

What's inside SOFABoot

  1. Overview of SOFABoot capabilities

    master

    SOFABoot is a development framework based on Spring Boot, open-sourced by Ant Group. It extends Spring Boot with several enterprise-grade capabilities designed for large-scale microservice architectures:

    • Readiness Check: Enhances Spring Boot's health check by adding readiness capabilities, ensuring traffic (RPC, gateways, etc.) is only routed to instances once they are fully ready.
    • Class Isolation: Uses SOFAArk to provide classloader isolation, preventing dependency conflicts between SOFA middleware and application classes.
    • Log Space Isolation: Automatically separates middleware logs from application logs and uses fixed paths to facilitate unified monitoring.
    • SOFA Middleware Integration: Provides Spring Boot Starters and unified programming interfaces for easy, pluggable integration of SOFA middleware components.
    • Modular Development: Supports Spring Context isolation, allowing different modules to use independent Spring contexts to avoid BeanId conflicts during multi-team development.
  2. Integrate SOFAStack Middlewares

    master
    SOFABoot provides easy-to-use programming interfaces for all SOFAStack middlewares. These are implemented as self-contained Spring Boot "starters" that provide the necessary facet dependencies and are independently pluggable.
  3. Implement Class Isolation with SOFAArk

    master
    To solve class or dependency conflicts, SOFABoot supports class isolation via SOFAArk. SOFAArk is a lightweight scheme that focuses on class loading between the application and middleware modules, making it easier to turn third-party SDKs into SOFAArk modules compared to OSGi.
  4. Use Readiness Check for Deployment Automation

    master

    SOFABoot provides a built-in readiness check to ensure that service instances are fully initialized before receiving traffic. This prevents timeouts or exceptions caused by requests reaching a service before it is ready.

    Key Behaviors:

    • SOFAStack middleware services (e.g., RPC services publishing to a Service Registry) will not reveal themselves until the readiness check passes.
    • Platform PaaS can monitor the readiness status via the following endpoint to control external traffic (gateways, load balancers, etc.):

    http://localhost:8080/actuator/readiness

  5. Implement Spring Context Isolation for Modularization

    master

    SOFABoot offers a modularization approach based on Spring Context. Unlike standard JAR-based modularization (where all classes share one classloader), this method allows different modules to own distinct Spring Contexts.

    How it works:

    • Each module has its own distinct Spring Context.
    • All contexts form a simple dependency tree.
    • Bean resolution for dependency injection occurs by traversing up the tree to the root.
    • This avoids bean and configuration conflicts between different modules and reduces communication overhead in multi-module development.
  6. Quick Start with SOFABoot

    master

    To get started with SOFABoot, please refer to the official SOFAStack documentation for the comprehensive quick start guide.

    For hands-on learning, you can explore several demo projects:

    • Standard project: A basic implementation.
    • Class Isolation: Demonstrates how to use SOFAArk for classloader-based isolation.
    • Spring Context Isolation: Shows how to implement modularization using distinct Spring Contexts.
    • SOFA RPC: Demonstrates integration with SOFA RPC middleware.
    https://www.sofastack.tech/en/projects/sofa-boot/quick-start/
  7. Use Unified Logging in SOFABoot

    master

    SOFABoot provides unified logging to reduce repetitive configuration for various SDKs. It utilizes sofa-common-tools to provide basic log configurations for each SDK automatically.

    Features:

    • Automatic Configuration: Users do not need to manually configure logging for each SDK.
    • Log Separation: Every SDK uses a different logging directory to separate SDK logs from application logs, facilitating easier monitoring.
  8. Explore SOFABoot sample projects

    master

    You can find various demo projects in the sofaboot-samples repository to understand different features:

    • Basic SOFABoot sample: sofaboot-sample
    • Sample with Class Isolation: sofaboot-sample-with-isolation
    • Sample with Modular Development (Context Isolation): sofaboot-sample-with-isle
    • Sample using SOFARPC: sofaboot-sample-with-rpc
  9. Access Readiness Check status via HTTP

    master

    For PAAS systems or load balancers to control traffic entry, you can check the application's readiness status by accessing the following endpoint:

    http://localhost:8080/actuator/readiness

    http://localhost:8080/actuator/readiness