Domain: Software Architecture / Distributed Systems / Financial Engineering
Persona: Senior Systems Architect
Abstract:
This presentation details a strategic architectural shift at BBVA, moving from monolithic C++ financial calculation libraries to a decoupled, multi-language service model using Google Protocol Buffers (Protobuf) and gRPC. The speaker addresses the friction involved in exposing high-performance C++ pricing engines to diverse development teams (Java, JavaScript, C#) within a banking environment.
The core of the solution involves transitioning from brittle binary or text-based interfaces (XML, CSV, CORBA) to standardized "Data Interfaces." By leveraging Protobuf for data definition and serialization, and gRPC for service orchestration, the team achieved automated code generation across languages, built-in type safety, and robust versioning. The talk highlights the use of Protobuf plugins for data validation and the utility of JSON-to-binary reflection for regression testing and debugging. Ultimately, the architecture preserves C++ for heavy computation while providing a seamless, discoverable, and validated interface for modern enterprise integration.
Summary of Technical Discussion
0:01:48 - The Interoperability Challenge: The primary problem is exposing complex C++ back-end algorithms to other languages without manually maintaining "tailor-made" solutions like SWIG, JNI, or brittle CSV/XML parsers which suffer from encoding issues and high maintenance overhead.
0:04:15 - The Dual-Wrapper Architecture: To accommodate different integration needs, the system implements two specific wrappers over the core C++ logic:
Service Interface: A gRPC access point for cross-language, network-based service calls.
Native Interface: A C-style byte array interface for inter-process communication within the same environment.
0:05:07 - Protocol Buffers as a Unified Data Language: Protobuf is utilized to define data structures (Messages). Key advantages include:
Serialization: Automatic handling of binary and JSON formats.
Testing: Ability to use JSON for human-readable regression tests while using binary for production performance.
Type Safety: Eliminates the loss of underlying type information common in manual XML/JSON parsing.
0:07:03 - Service Definition via gRPC: Using gRPC plugins, developers define Service and RPC blocks in .proto files. This generates abstract C++ classes with virtual methods, shifting the burden of serialization and network transport from the developer to the framework.
0:09:12 - Discoverability via Reflection: gRPC’s reflection capabilities allow clients to interrogate the server to discover available services and data structures dynamically. This enables the automatic generation of web-based testing interfaces without prior knowledge of the proto files.
0:10:04 - Enforcement via Data Validation Plugins: The speaker highlights the use of validation plugins to embed business rules (e.g., min_len, required, range checks) directly into the data definition. This establishes a "contract" between client and server, ensuring data integrity before logic execution.
0:12:09 - Interface Evolution and Compatibility: Protobuf provides clear rules for backward compatibility.
Safe: Renaming parameters or adding new ones.
Unsafe: Removing parameters, reassigning IDs, or changing field types, as these break the serialization algorithm.
Events: While gRPC is primarily request-response, it supports streaming, though complex subscription logic must be handled at the application level.
Performance: In the context of financial pricing (where calculations take minutes), the serialization overhead of Protobuf is negligible.
Threading: Standard gRPC implementations utilize a default threading model (often starting ~7 background threads), which can be customized via the server loop implementation.
Key Takeaways:
Standardization over Customization: Replacing language-specific bindings (JNI/PyBind) with a language-neutral IDL (Protobuf) reduces technical debt.
Contract-First Design: Using validation plugins allows for robust, self-documenting interfaces that enforce data constraints across the entire stack.
Tooling Synergies: The ability to flip between JSON (for debugging/logs) and Binary (for wire speed) is a critical advantage for enterprise-grade testing and production monitoring.