Skip to main content
Version: Next

Architecture

lunar.dev architecture ensures that companies can handle complex API consumption scenarios with scalability, flexibility, and resilience.

The Lunar API Consumption Gateway is the core component of Lunar.dev, designed to manage and optimize outgoing API traffic. Additionally, Lunar Interceptors offer a lightweight, optional solution for rerouting API traffic to the gateway without modifying existing codebases, providing efficient traffic management with minimal system impact.

These interceptors also feature a built-in Failsafe Mechanism to ensure continuous API traffic flow even in the event of gateway issues.

For organizations needing horizontal scalability, Lunar Pro enables the deployment of multiple gateway instances, requiring Redis to manage shared state, ensuring consistent quota usage and traffic metrics across instances. Redis plays a crucial role in enabling Lunar Pro to handle high traffic volumes seamlessly.

Lunar.dev API Consumption Gateway​

At the heart of Lunar lies Lunar.dev API Consumption Gateway. It excels in addressing complex API consumption challenges such as rate limits, retries, and account management. Lunar.dev API Consumption Gateway can be configured with Flows to optimize its functionality. By default, Lunar.dev API Consumption Gateway simply forwards requests to the host specified in the incoming requests. Flows can be defined globally, applying to all requests passing through Lunar.dev API Consumption Gateway, or on a per-endpoint/header basis. To achieve optimal performance, Lunar.dev API Consumption Gateway is intended to run on the same machine as the applications that utilize it.

Lunar Architecture

Failsafe Mechanisms​

Lunar.dev includes a Failsafe Mechanism that ensures continuous API traffic, even in case of system failure. For more details on this feature, visit the Gateway Failsafe Mechanism page [Link to "Failsafe Mechanism" page].

Flexible Traffic Routing​

Unlike traditional man-in-the-middle solutions that require routing all API traffic through a gateway, Lunar.dev allows you to selectively route only part of your traffic. This lets you control and monitor specific traffic for testing, optimization, or security, without disrupting your entire API ecosystem or forcing architectural changes.

Lunar Pro with Redis Capabilities​

To handle increased API traffic, Lunar Pro provides horizontal scaling, enabling the deployment of multiple instances of the Lunar.dev API Consumption Gateway. Redis plays a critical role in managing shared state between instances, ensuring consistency across distributed systems.

Lunar Pro Architecture

Redis for Shared State Management​

  • Redis is used as a central store to manage state across Lunar Pro instances, handling critical data such as quota usage and traffic metrics.
  • This integration allows multiple Lunar Pro instances to function seamlessly, distributing API traffic efficiently and preventing bottlenecks.

Lunar Interceptors​

Lunar Interceptors provide a hassle-free way to route API traffic through the Lunar.dev API Consumption Gateway without requiring changes to your existing codebase. These transparent interceptors are lightweight and are designed to have minimal impact on system resources. They can be configured to reroute API traffic automatically, allowing Lunar to monitor, manage, and optimize outgoing API requests effortlessly.

Additionally, interceptors come equipped with a Failsafe Mechanism, ensuring that the host application continues running even if the gateway encounters issues.

Lunar Flow​

Lunar Flows are the foundation of Lunar’s API Consumption Gateway, enabling fine-grained control over API traffic. They allow organizations to define customizable streams, filters, and processors to optimize traffic, control API usage, and enforce quotas with flexibility. Flows are modular and scalable, allowing businesses to maintain, adapt, and extend traffic control policies easily.

  • Streams: API requests and responses are processed as streams, which are divided based on specific criteria (e.g., URL, headers).
  • Filters: Apply logic to segment traffic into sub-streams, allowing for focused traffic management.
  • Processors: Modify or transform traffic in real-time, enabling functionalities like rate-limiting, request routing, or quota enforcement.

This modular structure allows organizations to seamlessly integrate traffic policies that optimize API consumption and ensure that traffic is routed based on business-critical rules.

Performance​

Lunar.dev prioritizes minimizing its impact on latency while optimizing API traffic. As API providers and consumers become more concerned with response time percentiles, Lunar ensures that its architecture adds a minimal latency footprint, even under heavy loads.

Lunar's Performance Footprint​

Lunar operates alongside your applications, processing all outgoing traffic to third-party providers. While its default behavior forwards requests and responses like a traditional gateway, its power lies in Lunar Flowsβ€”which can modify, generate, or diagnose API traffic in real-time. This functionality ensures that Lunar can meet the needs of high-traffic environments without negatively impacting performance.

Lunar UI Integration​

The Lunar.dev API Consumption Gateway includes a web-based UI built using Vue.js, providing a user-friendly interface for managing API traffic and viewing analytics. The Lunar Gateway communicates with the UI through a secure connection, using a dedicated API key that is automatically generated upon user signup, ensuring seamless and secure interaction between the UI and the gateway.

CTRL + M