Add Lambda-based compilation endpoint system #1676
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements a Lambda-based compilation endpoint system to handle
/api/compilers/<compilerid>/compile
and/api/compilers/<compilerid>/cmake
endpoints. This is part of the infrastructure work to support the compilation queue system described in compiler-explorer/compiler-explorer#7864.Key Features
• Lambda Functions: Python 3.12 Lambda functions for beta, staging, and prod environments
• SQS Integration: FIFO queues for reliable message handling with 30-minute retention
• WebSocket Response Handling: Async response retrieval from events system with configurable retry logic
• Content Negotiation: Support for both JSON and plain text requests/responses based on Accept headers
• ALB Integration: Target groups and listener rules for routing (beta active, staging/prod prepared)
• Comprehensive Testing: 23 unit tests covering all scenarios including error cases
• Terraform Infrastructure: Modular configuration split into logical files (security, ALB, SQS, Lambda)
Architecture
Implementation Details
• Timeout: 90 seconds for WebSocket response, 120 seconds Lambda timeout
• Retry Logic: Configurable retry count (default: 2) for WebSocket connections
• Request Handling: Preserves original headers and supports both JSON/plain text bodies
• Response Formatting: JSON response by default, plain text assembly when Accept: text/plain
• Environment Configuration: Separate queues and WebSocket URLs per environment
Testing
All functionality is covered by unit tests including:
Deployment
• Beta Environment: Ready for immediate deployment with active listener rules
• Staging/Production: Infrastructure ready, listener rules commented out for gradual rollout
• Makefile Integration: Build, test, and upload targets integrated with existing workflow
Related to: compiler-explorer/compiler-explorer#7864
Test plan
/beta/api/compilers/gcc/compile
endpoint🤖 Generated with Claude Code