Unlock the full potential of cloud computing with BoxLang! Discover how BoxLang’s modern, JVM-based language streamlines development, enhances productivity and simplifies scaling in a serverless environment.
2. LUIS F. MAJANO
• CEO Ortus Solutions
• Computer Engineer
• Born in El Salvador => Raised in the USA
• 2023 Leading EU Expansion team (Malaga, Spain 🇪🇸)
• Creator & Maintainer:
ColdBox MVC, TestBox BDD/TDD, CommandBox CLI, ContentBox CMS, etc.
• Creator / Chief Language Engineer BoxLang Programming Language
@lmajano @ortussolutions
3. • Serverless
• What? Why? When?
• Providers
• Use Cases
• Real Life Case
• Best Practices
Agenda
• BoxLang
• Lambda Runtime
• Lambda Template
Part 1 Part 2
5. AWS Lambda is a serverless computing service that runs
code in response to events without managing servers,
automatically scaling and charging only for execution time.
What is serverless?
7. Execution Patterns
• API Driven Patterns
• Event Driven Patterns
• Data Streaming Patterns
• Scheduling Patterns
8. Key Points about Serverless
• Me
• Focus on code abstractions
• Provider
• Auto Scaling
• Fault tolerance
• High Availability
• Metrics and Logging
• No OS updates
• Pay per use ONLY
9. Fine-Grained Pricing: Never pay for idle
• FREE Tier
• Buy in 100ms increments
• No minimums
• No per-device fees
• No idle fees
10. How Functions Work
Upload Function
(CI, Manually)
De
fi
ne Function Triggers
(API Calls, Events, Schedules)
Function Execution
(Stateless, Cold Start, Timeouts)
21. Wanna play?
• try.boxlang.io
• Internet playground for BoxLang
• First production BoxLang applications
• Powered by our MiniServer and AWS
Lambda Runtimes
22. Cool Stats
• Average executions per day: 28,000+
• Average execution time: 38ms
• Monthly Bill ????
$0.0000000000
23. AWS Lambda Best Practices
• Code is stateless
• Leverage external services: S3, ElastiCache, RDS,
etc.
• Ephemeral Disk Capacity
• 512MB by default -> 10GB if needed (But you pay)
• Max Timeout = 15 Minutes, lower it to your
convenience, or pay for it :)
24. AWS Lambda Best Practices
• Concurrent Executions: 1000
• Beware the ColdStart
• Use static constructs to avoid re-creations per
request
• Payload Size (Careful Here)
• Request: 6MB Synchronous, 256KB asynchronous
• Response: 6MB
25. Logging & Metrics
• USE IT! It’s already included
• Enable X-Ray + Lambda Service Traces
• Enable Enhanced Monitoring
• A wealth of debugging data is available!
26. Deployment Limits
• 50 MB zip or jar
fi
le
• 250MB unzipped
• Up to 5 Layers (Dependency Jars)
• Recommendations:
• Create a Fat/Shaded Jar
• Use Container Images -> 10GB
• Use our BoxLang Template!
• But, remember, focused work units is what you want.
27. Power Levels
• Had no idea at
fi
rst!
• You don’t choose CPU, you choose the memory
• More Memory => More CPU you get
• From 128bm => 10GB in 1GB increments
• Want to save money?
Choose ARM and not x86, way cheaper!
• Geek way to save money?
AWS Lambda Power Tuning: https://github.com/alexcasalboni/aws-lambda-power-tuning
28. SAM - Your new Best Friend
• Template-Driven resource management model
• Fancy words for Infrastructure as Code
• Supports anything AWS
• Included CLI
• Great for testing locally
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html
30. BoxLang is a modular dynamic language for the JVM, aiming
to make your development more productive, expressive,
functional, and available everywhere.
DYNAMIC : MODULAR : PRODUCTIVE
Part 2
33. BoxLang Lambda Runtime
• Leverages the AWS Java SDK
• BoxLang implements the AWS Runtime Handler for you
• Bootstraps the runtime (Con
fi
gurations + Modules + Dependencies)
• Tuned for fast startups
35. • Lambda Handler:
• ortus.boxlang.runtime.aws.LambdaRunner
:
:
handleRequest
• Acts as a Front Controller
• Inspects incoming Request
• Automatic logging/tracing
• Automatic error handling
• Delegates to the appropriate BoxLang Class + Function
• Automatic response handling
BoxLang Lambda Handler
36. • Implement Handlers as BoxLang Classes
• Class by Convention: Lambda.bx
• 1 method by convention: run( event, context, response )
• 1 Optional Application.bx for life-cycles or activating framework features
BoxLang Handlers
37. • Run() function by convention
• Event = Struct of the request
• Context = AWS Context Object
• Response = Struct of response data (optional)
• Return:
• Nothing (Use the response struct)
• Simple Value
• Complex Values
BoxLang Lambda
41. • We build the response object for you according to your return
• Return:
• Nothing (Use the response struct)
• statusCode: numeric
• headers: struct
• Body: anything
• Cookies : array
• Simple Value
• Complex Values
AWS Lambda Response
42. • Lambda exposed as a URL
• Run() function by convention
• Add as many public functions as you want
• Execute them via the x-bx-function header
• Routing is coming `/{functionName}`
Lambda Multi-Function Routing
43. BoxLang Lambda Template
• Turnkey Template for Lambda Development
• Unit + Integration Testing
• JUnit/TestBox + SAM
• Gradle
• Java Dependencies + Packaging + Testing
• CommandBox
• BoxLang Dependencies
• Github Actions CI
• Testing -> Packaging -> Deployment
https://github.com/ortus-boxlang/bx-aws-lambda-template
45. Getting Started
Try Boxlang
An online code playground built
on the MiniServer + AWS Lambda
Runtimes.
Docs
Learn about BoxLang, and contribute
to our extensive documentation.
Community
Join our community and get help,
tips and more.
x.com/tryboxlang
www.boxlang.io
linkedin.com/company/tryboxlang
facebook.com/tryboxlang
youtube.com/ortussolutions