# Swift OpenAPI Lambda now support Application Load Balancer

**URL:** <https://forums.swift.org/t/swift-openapi-lambda-now-support-application-load-balancer/82866>\
**Category:** Development\
**Tags:** openapi, lambda\
**Created:** [October 26, 2025, 8:32am UTC](https://forums.swift.org/t/swift-openapi-lambda-now-support-application-load-balancer/82866 "2025-10-26T08:32:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebsto](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sebsto/32/27165_2.png) [@sebsto](https://forums.swift.org/u/sebsto)\
**Post date:** [October 26, 2025, 8:32am UTC](https://forums.swift.org/t/swift-openapi-lambda-now-support-application-load-balancer/82866/1 "2025-10-26T08:32:08Z")

</div>

We just released Swift OpenAPI Lambda transport 2.1.0, with support for exposing your functions behind an [Application Load Balancer (ALB)](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html), in addition to the existing support for [API Gateway HTTP API](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api.html).

In your code, just conform to the `OpenAPILambdaALB` (instead of the `OpenAPILambdaHttpAPI` that you use for the API Gateway).

Look at the new example in [`Examples/quoteapi-alb` directory](https://github.com/awslabs/swift-openapi-lambda/tree/2.1.0/Examples/quoteapi-alb).

```swift
@main
struct QuoteServiceALBImpl: APIProtocol, OpenAPILambdaALB {

    func register(transport: OpenAPILambdaTransport) throws {
        try self.registerHandlers(on: transport)
    }

    static func main() async throws {
        let openAPIService = QuoteServiceALBImpl()
        try await openAPIService.run()
    }

    // the functions generated by the OpenAPI plugin
    func getQuote(_ input: Operations.getQuote.Input) async throws -> Operations.getQuote.Output {
    ... 
    }
}

```

As usual, continue to share your feedback and open issues. The full change log is below.

### ALB or API Gateway?

- ALB integrates Lambda functions as a backend target, supporting low-latency and flexible routing, and basic authentication.​
- API Gateway HTTP API is a managed gateway for REST, HTTP, and WebSocket APIs, offering rich features such as request validation, usage plans, custom authorizers, and integration with AWS managed services (e.g., Cognito).

#### My mental model to choose which one to use

- **ALB fits when integrating Lambdas into broader web applications** , distributing HTTP traffic or exposing serverless functions alongside container services or EC2.​
- **API Gateway is best for building APIs** , complex microservices, or needs requiring request validation, throttling, and security integrations (OAuth, API Key, CSP).​
- **Cost** : ALB is generally cheaper at scale and for high RPS traffic, while API Gateway may be more economical for low-volume APIs due to its rich feature set.​
- **API Gateway** allows multiple API versions and SDK auto-generation, aiding mobile and client app backward compatibility.​
- **Latency** : API Gateway introduces more overhead compared to ALB, but offers more features like transformation, validation, and direct AWS integrations.
