Composable AI Architecture
Introduction
The AI market is witnessing a rapid evolution, propelled by the swift pace of technological advancement. With breakthroughs occurring frequently, staying up-to-date with the latest innovations is imperative for organizations aiming to remain competitive. Short iteration cycles and agility have become indispensable in this landscape, allowing businesses to swiftly adopt and leverage the newest advancements in AI technology.
In this dynamic environment, the concept of composability, data portability, and standard APIs emerges as crucial factors in navigating the complexities of the AI ecosystem:
๐ง Composability
The ability to assemble various AI components into tailored solutions, enabling organizations to mix and match different technologies to suit their specific needs.
๐ Data Portability
Plays a pivotal role in facilitating seamless data exchange between different AI systems and platforms, ensuring interoperability and preventing data silos.
๐ Standard APIs
Serve as the linchpin for integrating diverse AI components, enabling seamless communication and collaboration between disparate systems.
The significance of composability, data portability, and standard APIs becomes particularly pronounced in mitigating vendor lock-in and fostering flexibility. By embracing these principles, organizations can sidestep dependency on single vendors and instead opt for a best-in-class approach, selecting the most suitable solutions for their unique requirements. Overall, these principles pave the way for a more agile, adaptable, and future-proof AI ecosystem.
Cloudflare's AI platform has been designed with these principles in mind. The architecture diagram illustrates how AI applications can be built end-to-end on Cloudflare, or single services can be integrated with external infrastructure and services.
Composable AI Infrastructure
๐ Figure 1: Composable AI Architecture
The composable AI architecture enables flexible integration of various AI components and services
The composable AI infrastructure consists of four main layers that work together to create a flexible and scalable AI application architecture:
1. Compute Layer
Core Application Logic
The compute layer is the core of the application. All business logic, as well as use of other components, is defined here. The compute layer interacts with other services such as inference services, vector search, databases and data storage.
Key Features:
- Serverless solutions like Cloudflare Workers offer fast iteration and automatic scaling
- Developers can focus on the use case instead of infrastructure management
- Support for standard interfaces such as HTTP or TCP
- Workers' runtime supports both
fetch()API andconnect()API
2. Inference Services
AI Capabilities
AI inference is responsible for the AI-capabilities of the application. Operational models vary between self-hosting models or consuming Inference-as-a-service providers.
Example: Using Workers AI
// Using platform-specific bindings
const response = await env.AI.run(
'@cf/meta/llama-2-7b-chat-int8',
{
prompt: "What is AI composability?"
}
); 3. Vector Search
Similarity Matching
Certain use cases such as RAG (Retrieval-Augmented Generation) leverage vector search for similarity matching. This enables semantic search capabilities and context-aware AI responses.
Common Use Cases:
- Semantic document search
- Recommendation systems
- Context retrieval for chat applications
- Image and content similarity matching
4. Data & Storage
Persistent State Management
Databases and data storage add state to AI applications. User management, session storage and persisting data are common requirements for AI applications.
D1 - SQLite Database
- Relational data storage
- User management
- Session storage
- Structured queries
R2 - Object Storage
- Large file storage
- Model weights
- Training data
- Media files
KV - Key-Value Store
- Fast cache layer
- Configuration data
- Session tokens
- Temporary data
Durable Objects
- Stateful coordination
- Real-time collaboration
- WebSocket connections
- Consistent state
REST APIs make interacting with these services from any service/client easy to implement. Using platform-specific integrations such as Bindings for interaction between Workers and data services enables simplified development as complexity such as authentication is abstracted away.
Integration Patterns
๐ API-First Integration
Use REST APIs for cross-platform compatibility and maximum flexibility
fetch('https://api.cloudflare.com/...') โก Platform Bindings
Leverage native bindings for simplified authentication and lower latency
env.AI.run(...) ๐ Hybrid Approach
Combine Cloudflare services with external providers for best-of-breed solutions
๐ฆ Microservices
Build modular AI services that can be composed into larger applications
Best Practices
โ Design for Portability
Use standard interfaces and avoid vendor-specific features where possible to maintain flexibility
โ Implement Abstraction Layers
Create abstraction layers between your business logic and infrastructure services
โ Monitor Performance
Implement comprehensive observability across all components of your AI stack
โ Plan for Scale
Design your architecture to handle both vertical and horizontal scaling requirements
โ Secure by Default
Implement security at every layer, from API authentication to data encryption