ADR-001: Apache Thrift for Internal Services

Decision Analysis and Resolution: SW360 Internal RPC Framework

Created by: SW360 Architecture Team
Original Decision: 2014
Reformatted: April 2026
Status: Accepted
Estimated read time: 10 minutes


Table of Contents

  1. Background
  2. Goal
  3. Key Principles
  4. Key Inputs, Assumptions and Restrictions
  5. Options Analysis
  6. Criteria for Making a Decision
  7. Final Decision
  8. Contributors
  9. Discussion & Brainstorming

Background

SW360 was designed as a multi-tier application for open source license compliance management with:

  • A web portal (Liferay) as the frontend
  • Backend services handling business logic
  • A document database (CouchDB) for persistence

FOSSology Integration Challenge: A critical requirement was integration with FOSSology, a license scanning tool. At the time (2014), neither FOSSology nor SW360 had REST APIs. The need arose for a communication protocol that could bridge the Java-based SW360 and the predominantly C/PHP-based FOSSology.

Internal Communication Needs: The system also needed an efficient, reliable communication protocol between the web layer and backend services for internal operations.

Why This Decision Matters Now: This decision affects:

  • All internal service-to-service communication
  • External tool integrations
  • Developer experience and onboarding
  • System performance and maintainability

Goal

The goal of this decision analysis is to:

  1. Select an internal RPC framework for SW360 that supports efficient service communication
  2. Enable integration with external tools like FOSSology
  3. Provide strong interface contracts to prevent service drift
  4. Support potential polyglot implementations in the future
  5. Document the rationale for future team members

Key Principles

#PrincipleDescription
1Efficiency FirstInternal communication should minimize overhead
2Strong ContractsInterface definitions should be explicit and versioned
3Cross-language SupportMust support Java, C++, Python, PHP for FOSSology integration
4Developer ProductivityCode generation preferred over manual serialization
5MaturityFramework must be production-ready and well-supported

Key Inputs, Assumptions and Restrictions

TypeDescription
InputFOSSology is written in C/PHP and has no REST API (2014)
InputSW360 backend is Java-based with Spring framework
InputComplex nested data structures (components, releases, licenses) must be exchanged
AssumptionInternal communication will remain on same network/machine
AssumptionExternal clients will need a separate REST API layer
RestrictionMust integrate with Liferay portal framework
RestrictionBudget does not allow commercial RPC solutions

Options Analysis

Option 1 - REST/JSON

Summary

Use RESTful HTTP APIs with JSON serialization for all internal and external communication. This is the most common approach for web services and offers broad tooling support.

Conceptual View

graph LR
    A[Liferay Portal] <-->|HTTP/JSON<br/>REST APIs| B[Backend Services]
    B -->|HTTP/JSON| C[FOSSology]

Impact / Changes Required

  • Implement REST controllers for all backend services
  • Define JSON schemas for all data transfer objects
  • Manual serialization/deserialization code
  • FOSSology would need REST API development (not available in 2014)

SWOT Analysis

CategoryAnalysis
Strengths1. Universal understanding - every developer knows REST
2. Human-readable JSON for debugging
3. Broad tooling support (Postman, curl, etc.)
4. Stateless by design
5. Works through firewalls easily
Weaknesses1. Verbose JSON increases payload size
2. No native schema/contract enforcement
3. Manual serialization code required
4. HTTP overhead for internal calls
5. Complex nested structures require careful design
Opportunities1. Could serve as both internal and external API
2. Easy to add caching layers
3. OpenAPI/Swagger for documentation
Threats1. Schema drift between services without strict governance
2. Performance issues with large payloads
3. FOSSology has no REST API (2014) - integration blocked

Option 2 - SOAP/XML

Summary

Use SOAP (Simple Object Access Protocol) with XML serialization. This was the enterprise standard for web services, offering strong typing through WSDL contracts.

Conceptual View

graph LR
    A[Liferay Portal] <-->|SOAP/XML<br/>WSDL| B[Backend Services]

Impact / Changes Required

  • Define WSDL contracts for all services
  • Generate Java stubs from WSDL
  • Heavy XML processing infrastructure
  • FOSSology integration would require SOAP support

SWOT Analysis

CategoryAnalysis
Strengths1. Strong typing through WSDL
2. Enterprise standard with proven track record
3. Built-in error handling (SOAP faults)
4. WS-Security for authentication
Weaknesses1. Extremely verbose XML payloads
2. High processing overhead
3. Complex tooling and configuration
4. Poor support in non-Java languages
5. Heavy memory footprint
Opportunities1. Enterprise integration patterns available
Threats1. Industry moving away from SOAP (2014)
2. Limited C/PHP support for FOSSology
3. Developer resistance - seen as “legacy”
4. Maintenance overhead for WSDL files

Option 3 - Apache Thrift

Summary

Use Apache Thrift, a binary RPC framework with Interface Definition Language (IDL). Thrift generates client/server code for multiple languages from a single interface definition.

Conceptual View

graph TB
    A[Liferay Portal] <-->|Thrift Binary<br/>TBinaryProtocol| B[Backend Services]
    A --> C[".thrift files<br/>(contracts)"]
    B --> C
    C -->|Code Generation| D["Java, C++, Python, PHP, ..."]
    D --> E["FOSSology (C/PHP)"]

Impact / Changes Required

  • Define Thrift IDL files for all data structures and services
  • Add Thrift compiler to build process
  • Generate Java handlers for backend services
  • FOSSology can use generated C/PHP code directly

SWOT Analysis

CategoryAnalysis
Strengths1. Efficient binary protocol - compact payloads
2. Strong IDL contracts - compile-time checking
3. Excellent cross-language support (Java, C++, Python, PHP)
4. Code generation eliminates serialization boilerplate
5. Native support for complex types (maps, sets, nested structs)
6. Optional fields for backward compatibility
7. Battle-tested at Facebook scale
Weaknesses1. Learning curve for Thrift concepts
2. Requires Thrift compiler in build process
3. Binary protocol harder to debug than JSON
4. Limited IDE support for .thrift files
5. Cannot expose directly to external clients (need REST wrapper)
Opportunities1. Enables FOSSology integration immediately
2. IDL files serve as living documentation
3. Can add new languages in future without rewriting
4. Performance optimization path available
Threats1. Smaller community than REST
2. gRPC emerging as competitor
3. Team must maintain Thrift expertise
4. Version management across services

Option 4 - gRPC/Protocol Buffers

Summary

Use Google’s gRPC framework with Protocol Buffers for serialization. Similar to Thrift but newer, with HTTP/2 transport and strong Google backing.

Conceptual View

graph LR
    A[Liferay Portal] <-->|gRPC/HTTP2<br/>Protobuf| B[Backend Services]

Impact / Changes Required

  • Define .proto files for all services
  • Add protoc compiler to build process
  • Generate Java/C++ stubs
  • Requires HTTP/2 support throughout

SWOT Analysis

CategoryAnalysis
Strengths1. Modern HTTP/2 transport with streaming
2. Efficient Protocol Buffer serialization
3. Strong Google backing and community
4. Good tooling and documentation
Weaknesses1. Immature in 2014 - gRPC 1.0 released in 2016
2. Limited language support in 2014
3. HTTP/2 not widely supported in 2014
4. No PHP support initially (critical for FOSSology)
Opportunities1. Growing ecosystem
2. Cloud-native alignment
Threats1. Production-ready version not available (2014)
2. PHP support timeline uncertain
3. Breaking changes expected before 1.0
4. FOSSology integration blocked

Criteria for Making a Decision

T-Shirt Sizing Scale

T-Shirt SizeNumeric ValueMeaning
XS1.0Worst for this aspect
S2.5Poor
S-M3.75Below Average
M5.0Average
M-L6.25Above Average
L7.5Good
L-XL8.75Very Good
XL10.0Best for this aspect

Weighted Evaluation Matrix

CriteriaDescriptionWeightREST/JSONSOAP/XMLThriftgRPC
RatingScoreRatingScoreRatingScoreRatingScore
FOSSology IntegrationMust support C/PHP languages for FOSSology10XS10.0XS10.0XL100.0XS10.0
PerformanceBinary efficiency, low overhead for internal calls8M40.0S20.0L-XL70.0L-XL70.0
Type SafetyCompile-time contract enforcement8S20.0L60.0L-XL70.0L-XL70.0
Complex Data StructuresSupport for nested objects, maps, collections7M35.0M-L43.75XL70.0L-XL61.25
Developer ExperienceLearning curve, debugging, tooling7L-XL61.25S-M26.25M-L43.75M35.0
Code GenerationAutomatic stub generation reduces boilerplate6S15.0M-L37.5XL60.0XL60.0
Production ReadinessMature, battle-tested, stable (as of 2014)9XL90.0L67.5L-XL78.75XS9.0
Community & SupportDocumentation, community help, longevity6XL60.0M30.0L45.0S15.0
Cross-Language SupportJava, C++, Python, PHP coverage8L60.0S-M30.0XL80.0S-M30.0
Backward CompatibilityAdding fields without breaking clients6M30.0M30.0L-XL52.5L-XL52.5
TOTAL421.25355.0670.0412.75

Score Summary

RankOptionTotal ScoreRecommendation
🥇 1Apache Thrift670.0SELECTED
🥈 2REST/JSON421.25External API layer
🥉 3gRPC412.75Not production-ready (2014)
4SOAP/XML355.0❌ Rejected

Final Decision

Selected Option: Apache Thrift

Rationale

Apache Thrift was selected as the internal RPC framework for SW360 based on:

  1. Highest Weighted Score (670.0) - Significantly outperformed alternatives across all criteria

  2. Critical FOSSology Integration - The highest-weighted criterion (10). Thrift’s native C/PHP support was the only option enabling FOSSology integration without requiring FOSSology to implement a new API

  3. Superior Type Safety - Thrift IDL provides compile-time guarantees that prevent service interface drift:

    service ComponentService {
        Component getComponentById(1: string id, 2: User user) 
            throws (1: SW360Exception exp);
    }
    
  4. Complex Data Structure Support - Native handling of nested structures, optional fields, and collections essential for SW360’s data model

  5. Production Readiness - Battle-tested at Facebook scale, unlike gRPC which wasn’t released until 2016

Implementation Notes

Thrift Files Location:

libraries/datahandler/src/main/thrift/
├── sw360.thrift          # Common types, enums
├── components.thrift     # Component, Release
├── projects.thrift       # Project, ClearingRequest
├── licenses.thrift       # License, Obligation
├── users.thrift          # User, UserGroup
└── ...

Service Pattern:

// Handler implements Thrift interface
public class ComponentHandler implements ComponentService.Iface {
    @Override
    public Component getComponentById(String id, User user) 
            throws SW360Exception {
        // Implementation
    }
}

External API: REST/JSON layer to be added for external client access (cannot expose Thrift directly)

Review Triggers

This decision should be revisited if:

  • FOSSology deprecates Thrift support
  • gRPC becomes the industry standard with full PHP support
  • Major Thrift vulnerabilities are discovered
  • Team expertise in Thrift becomes unsustainable

Contributors

NameRoleContribution
SW360 Architecture TeamDecision MakersRequirements analysis, criteria weighting
FOSSology TeamStakeholderIntegration requirements
Development TeamImplementersFeasibility assessment

Discussion & Brainstorming

Architecture Team - 2014

The key differentiator is FOSSology integration. Without Thrift, we would need to wait for FOSSology to implement REST APIs, which is outside our control and timeline.

Development Team - 2014

Concern: Learning curve for Thrift IDL. Mitigation: Create internal documentation and code examples. The code generation actually reduces overall development effort.

Operations - 2014

Binary protocol harder to debug. Recommendation: Implement detailed logging at service boundaries and consider JSON protocol for development environments.


Consequences Summary

Positive

  • ✅ Strong typing with compile-time checking of service interfaces
  • ✅ Efficient binary protocol for large payloads
  • ✅ Clear contracts through IDL files as documentation
  • ✅ Backward compatibility through optional fields
  • ✅ Consistent data model across all layers
  • ✅ FOSSology integration enabled immediately

Negative

  • ⚠️ Learning curve for developers new to Thrift
  • ⚠️ Build complexity with Thrift compiler dependency
  • ⚠️ Binary protocol harder to inspect than JSON
  • ⚠️ REST API needed for external client integration

Technical Debt Created

  • External REST API layer needed for non-Thrift clients
  • Thrift compiler must be maintained in CI/CD pipeline

Revision History

VersionDateAuthorChanges
1.02014Architecture TeamInitial decision
2.0April 2026Bibhuti Bhusan DashReformatted to DAR/SWOT template