AWS Bites – Episode 148: Lambda and Java with Mark Sailes
Release Date: September 4, 2025
Host: Tushano (AWS Bites)
Guest: Mark Sailes (ex-AWS engineer, Java & Serverless specialist)
Episode Overview
This episode of AWS Bites dives into the realities and myths regarding the use of Java on AWS Lambda in 2025. With guest Mark Sailes, a former AWS solutions architect and a hands-on expert in Java and serverless, the conversation debunks the dated notion that "Java is too old for serverless." Throughout, Mark details pragmatic strategies, optimization techniques, and how large enterprises (especially those with substantial Java investments) can thrive in serverless architectures. Key topics include Lambda cold starts, SnapStart, provisioned concurrency, dependency and framework choices, testing, and practical tips for both beginners and seasoned AWS users.
Key Discussion Points & Insights
1. Addressing the “Java is Too Old for Serverless” Myth
- Skillsets First, Not Language Wars
- [03:19] Mark: "I don't start with saying which language should I use...I look at the skills of that team and the application that we're working with and the wider context..."
- Teams entrenched in Java with major investments shouldn't rewrite everything; serverless should be made approachable for their existing skill base.
- Old Reputations Die Hard
- Java's cold start reputation lingers much like Lambda's old VPC cold starts did, but both have seen dramatic improvements.
2. When (and When Not) to Choose Java for Lambda
- [07:22] Mark: "What sort of traffic profile are you seeing? What is the kind of ceiling on cold starts that you need?"
- If your service can't tolerate cold starts over 500ms (with database connections, parameter loading, etc.), consider native compilation (e.g., GraalVM) or a faster language like Go or Rust.
- For most enterprise microservices, especially those built in Spring, migration to Lambda saves costs and operational overhead.
3. Java’s Unique Position in Serverless
- Integration Powerhouse
- [09:18] Mark: "Java's unique position is that it is the language of integration...the richest, longest history, the most developed SDKs for a variety of different tools."
- Adoption Patterns, Not Just Language Features
- The value comes not just from code capabilities but the mature ecosystem and organizational familiarity.
4. Enterprise Benefits: Security, Compliance, and Operations
- [12:08] Mark (on Log4Shell mitigation): "Lambda team...mitigate that attack by checking whenever a vulnerable class was loaded into the runtime and strip away the vulnerable code."
- Serverless shifts maintenance to AWS, letting teams benefit from rapid patching (e.g., Log4Shell, Spectre) and easier compliance.
- [13:46] Mark: "Even if it would've just been an SDK change...it’s just so much easier to do than having to patch runtimes and servers..."
5. Practical Optimization Tips for Java on Lambda
Which Java Version?
- [20:36] Mark: "Mostly you're not really tuning the JVM anymore...Java 17, Java 21...all have this flag [tiered compilation] enabled by default."
- Best practice: Use the latest LTS Java runtime supported by Lambda (e.g., Java 17 or Java 21).
Dependencies and Logging
- [20:36] Mark: "Log4j... is now one and a half megabytes...I recommend another library called Pena...50 kilobytes, does structured JSON logging, has zero external dependencies, super fast."
- Swap heavy dependencies (like log4j) for leaner options (Pena), especially in ephemeral environments.
Framework Choices
- [29:05] Mark: "Do you need a framework? Because if you don't...then you shouldn't..."
- Prefer no framework for simple event-driven functions. Use frameworks like Spring, Quarkus, or Micronaut only if you need dependency injection or already rely on such frameworks for consistency.
- [29:05] Mark: Quarkus and Micronaut shine for native compilation and reduced reflection.
- [32:46] Mark: Quarkus is standards-based, potentially easing migrations from older Java EE applications.
SnapStart & Provisioned Concurrency
- [25:10] Mark: Provisioned concurrency isn’t just about “paying to skip cold starts”—it can be cheaper at higher utilization.
- [25:10] Mark: “...provision concurrency can actually be cheaper than on demand...if you do have a lambda function that has significant traffic.”
- SnapStart (at the time of recording, free for Java/Python/.NET): "Even just turning it on without...optimizations...is going to save you latency." But slower deployments and versioning are trade-offs.
When to Enable These:
- Use SnapStart for production and pre-prod environments where latency is crucial.
- Don’t obsess over cold starts during development—use SnapStart/provisioned concurrency strategically.
Tactical Developer Tips
- Handler vs INIT Phases
- [18:36] Host/A: Many new Lambda users put all init logic in the handler, causing slow invocations; split heavy initialization into the INIT phase.
- [19:19] Mark: “Maybe that's a UX problem with lambda...for different languages it actually handles the INIT phase differently.”
6. Testing Strategies and Developer Experience
Local vs. Cloud Testing
- [34:01] Mark: Prefers heavy use of local integration tests, using tools like LocalStack and TestContainers. End-to-end and security tests are reserved for the cloud.
- [36:30] Mark: “I think mocking is on a decline...I'm much more likely to favor integration tests with test containers and LocalStack.”
Synthetic Testing for Reliability
- [38:15] Mark: Advocates for always-on, synthetic event streams for testing reliability in event-based or time-based systems. This investment pays off for enterprise-grade systems.
7. Resource Recommendations
For Beginners:
- AWS Lambda Documentation (with growing Java-focused content)
- Serverless Land’s Java section (search “effectively using Java on Lambda”)
For Experienced Engineers:
- Mark Sailes’ eBook (continually updated, practical optimization tips): sales.co.uk (see show notes)
Visual Learning:
- Mark’s Lambda SnapStart & execution model simulations—great for understanding cold starts and the Lambda lifecycle.
Notable Quotes & Moments
-
On Starbucks-sized meetings about $30/month:
[25:10] Mark: "The time we've spent discussing this problem and the salaries of everyone in the room...why are we even talking about 20, $30 a month?" -
On AWS Fast Security Response:
[12:08] Mark: "We saved so many customers from being attacked [by Log4Shell]...was a real highlight of my career." -
On “Optimization Obsession”:
[24:26] Host/A: "It's always focusing a bit too much on performance, which sometimes makes sense, but not always...it's more important to ship features and deliver value." -
On the Value of Testing Investments:
[39:36] Mark: "Any non trivial application...these are always going to be cost savings that just come back again and again." -
On Learning the Lambda Execution Model:
[44:02] Mark: "Once you understand the execution model...a lot of things click and then you start to understand what is a suitable use case, what is not a suitable use case."
Timestamps for Important Segments
- [03:19] – Why Java isn’t “too old” and when to choose Lambda
- [06:12] – GraalVM & cold start minimization for Java
- [09:18] – Java’s unique value in integrations and enterprise
- [12:08] – Lambda’s response to Log4Shell and the operational benefits of serverless
- [20:36] – JVM tuning, dependency choices, and logging best practices
- [25:10] – Cost tradeoffs: Provisioned Concurrency and SnapStart in practice
- [29:05] – Frameworks: Spring, Quarkus, Micronaut, and when to skip frameworks
- [34:01] – Testing philosophy: local vs cloud, and the decline of mocking
- [41:23] – Resource recommendations and Mark’s eBook
Resources Mentioned
- Mark Sailes’ eBook & resources: sales.co.uk (ongoing updates)
- Pena logging library (search: "Java logging library Pena")
- AWS Lambda Documentation: https://docs.aws.amazon.com/lambda/
- Serverless Land, Java Section: https://serverlessland.com
- TestContainers & LocalStack: Java integration and local testing tools
Final Takeaway
If your organization depends on Java, modern serverless, especially with Lambda’s latest features, is both viable and advantageous—provided you leverage the right tools, understand the execution nuances, and challenge old biases about latency. Mark’s pragmatic, experience-driven tips make this episode a goldmine for AWS users at every skill level.
For a more interactive/visual grasp of Lambda lifecycles and cold starts, check out the simulations linked in the show notes!
