Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Defying Serverless API Constraints (API Days 2025)

Defying Serverless API Constraints (API Days 2025)

Discover practical solutions to real-world serverless constraints faced by engineering teams that builds API projects using popular patterns such as Micro-Lambdas, Lambdaliths and Moduliths. This presentation explores creative workarounds for common and rarely discussed limitations.

Allan Chua

April 15, 2025
Tweet

More Decks by Allan Chua

Other Decks in Technology

Transcript

  1. About Me • Serverless Since 2019 • AWS Community Builders

    • AWS Singapore UG Volunteer • Hands-on CTO @ Premier Fiduciary • 4X AWS Certified Allan Chua
  2. Micro-Lambdas API Gateway GET /INVOICES GET /INVOICES/{ID} POST /INVOICES/{ID} GET

    /PAYMENTS GET /PAYMENTS/{ID} POST /PAYMENTS/{ID} Single purpose functions that serves requests for each REST endpoint. • Least Change Collisions on Code • Easier to Maintain • Easiest to Debug • Good for Small Apps and POCs • Shorter Cold Starts PROS • Code Conflicts on SAM file • Write tons of IAC YAML • Plenty of Cold Starts • Scaling Constraints CONS
  3. 5 API Gateway CF Resources (Stage, Deployment, Rest API, Domain

    Name, Path Mapping) Maximum # of APIs built on top of Micro-Lambdas per CF Stack ((500 – 5) / 3) = 165 Lambda Functions 1 API Function = 3 Resources 500 Max Resource Count
  4. Max # of Resources Inside a Cloud Formation Stack Solutioning

    Options Refactor to Lambda-Lith Group Resources into Nested CF Stacks Split Resources into Logical Stacks Refactor to Modulith
  5. Splitting Resources into Logical Groups Reactors/ BG Workers Lambda Functions

    APIs Lambda Functions API Gateway Core S3 SQS DynamoDB IAM Roles Do! Core, Reactors, BG Workers and APIs S3 SQS DynamoDB IAM Roles Don’t Lambda Functions API Gateway
  6. Reactors/ BG Workers Lambda Functions APIs Lambda Functions API Gateway

    Core S3 SQS DynamoDB IAM Roles This is decent but… • Scaling Bottleneck at the Compute Stack CONS • Larger Max Resource Constraint • Faster Deployments • Makes Compute Layer Refactorable • Less Risk of Deleting DBs PROS
  7. Ideal Solution Reactors/ BG Workers Lambda Functions Core S3 SQS

    DynamoDB IAM Roles Notification APIs API Gateway Payment APIs Invoicing APIs Billing APIs Auth APIs Notification APIs
  8. Nesting CloudFormation Stacks Superior Option for Scaling Reactors/ BG Workers

    Lambda Functions Payment APIs API Gateway Core S3 SQS DynamoDB IAM Roles Invoicing APIs API Gateway Auth APIs API Gateway Notification APIs API Gateway Correspondence APIs API Gateway Company APIs API Gateway
  9. Maximum Number of API Gateways Accurate as of April 15,

    2025 ACCOUNT-LEVEL | NON-ADJUSTABLE 600 Regional 120 Edge-optimized
  10. Routes per API Gateway GATEWAY-LEVEL | SOFT LIMIT Accurate as

    of April 15, 2025 300 36K Edge Optimized APIs 180K Regional APIs
  11. Maximum Number of IAM Roles per Account ACCOUNT-LEVEL Accurate as

    of April 15, 2025 1000 SOFT LIMIT 5000 HARD LIMIT
  12. Max # of API Gateways, IAM Roles, SAM Issues Solutioning

    Options Refactor to Lambda-Lith Merge APIs (Bounded Context) Refactor to Moduliths
  13. Lambda-Lith GET /INVOICES GET /INVOICES/{ID} POST /INVOICES/{ID} POST /PAYMENTS/{ID} GET

    /PAYMENTS/{ID} GET /PAYMENTS https://middy.js.org/ https://hono.dev/ API Gateway ANY /{proxy+} GREEDY PATH (Catch-all / Wildcard) Just like our traditional APIs where a single server process is in-charge of responding to all endpoints in a REST API.
  14. API Routing Frameworks for AWS Lambda - AWESOME for strangler

    migrations - Lowest Barrier of Entry - Gets Rid of Micro-lambda Scaling Issues - Least YAML Coding - Faster Deployment - Frequent Warm Starts - Great for Medium-sized Apps PROS - Higher Risk of Breakage - Single Point of Failure - Harder to Debug - Slower Response Times - Heavy Cold Start - Simple CRUD functions gets loaded with heavier libraries CONS
  15. Modulith API Gateway ANY /PAYMENTS/{proxy+} ANY /INVOICES/{proxy+} ANY /PURCHASE-ORDERS/{proxy+} -

    Frequent Warm Starts - Awesome for Large-scale API Development - Smaller Blast Radiuses - Low YAML Amount - Low Barrier of Entry - Low IAM Role Count - Simple CRUD APIs don’t need to load heavy SDKs used by reporting APIs PROS - AKA Modular Monoliths - 1 API Gateway - 1 Greedy Path per Module - 1 Function for each Module - Duplicated Libraries Across Functions - Lower amount of code samples & literature CONS ANY /REPORTS/{proxy+} POST /PAYMENTS/{ID} GET /PAYMENTS/{ID} GET /PAYMENTS GET /INVOICES GET /INVOICES/{ID} POST /INVOICES/{ID} GET /PURCHASE-ORDERS GET /PURCHASE-ORDERS/{ID} POST /PURCHASE-ORDERS/{ID} GET /REPORTS GET /REPORTS/{ID} POST /REPORTS/{ID}
  16. GPU Enabled Inferencing APIs • Not supported as of April

    2025 • AWS seems to be aware • Some customers mentioned AWS is working on them • Use AWS Batch or Container Services to Implement them.
  17. Conclusion • Distributed your CF Resources into Logical Groups •

    Micro-lambdas are great for small projects and prototyping. • Lambda-lith offers low entry barrier to Serverless. • Modulith Offers Extreme Code-base Scaling • Runtimes Expire and Require Routine Upgrades